
"""simple docstring"""


import gc
import os
import tempfile
import unittest

import torch
import torch.nn as nn
import torch.nn.functional as F
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer

from diffusers import AutoencoderKL, DDIMScheduler, StableDiffusionPipeline, UNetaDConditionModel
from diffusers.loaders import AttnProcsLayers, LoraLoaderMixin
from diffusers.models.attention_processor import (
    Attention,
    AttnProcessor,
    AttnProcessor2_0,
    LoRAAttnProcessor,
    LoRAAttnProcessor2_0,
    LoRAXFormersAttnProcessor,
    XFormersAttnProcessor,
)
from diffusers.utils import TEXT_ENCODER_ATTN_MODULE, floats_tensor, torch_device






def  _snake_case			(						snake_case__				:       nn.Module       ):
	A  				=				{}
	for name in unet.attn_processors.keys():
		A  				=				None if name.endswith('attn1.processor'       ) else unet.config.cross_attention_dim
		if name.startswith('mid_block'       ):
			A  				=				unet.config.block_out_channels[-1]
		elif name.startswith('up_blocks'       ):
			A  				=				int(name[len('up_blocks.'       )]       )
			A  				=				list(reversed(unet.config.block_out_channels       )       )[block_id]
		elif name.startswith('down_blocks'       ):
			A  				=				int(name[len('down_blocks.'       )]       )
			A  				=				unet.config.block_out_channels[block_id]
		A  				=				(
		    LoRAAttnProcessor2_0 if hasattr(snake_case__		, 'scaled_dot_product_attention'       ) else LoRAAttnProcessor
		)
		A  				=				lora_attn_processor_class(
		    hidden_size=snake_case__		, cross_attention_dim=snake_case__       )
	A  				=				AttnProcsLayers(snake_case__       )
	return lora_attn_procs, unet_lora_layers






def  _snake_case			(						snake_case__				:       nn.Module       ):
	A  				=				{}
	A  				=				(
	    LoRAAttnProcessor2_0 if hasattr(snake_case__		, 'scaled_dot_product_attention'       ) else LoRAAttnProcessor
	)
	for name, module in text_encoder.named_modules():
		if name.endswith(snake_case__       ):
			A  				=				lora_attn_processor_class(
			    hidden_size=module.out_proj.out_features		, cross_attention_dim=snake_case__       )
	return text_lora_attn_procs






def  _snake_case			(						snake_case__				:       nn.Module       ):
	A  				=				create_text_encoder_lora_attn_procs(snake_case__       )
	A  				=				AttnProcsLayers(snake_case__       )
	return text_encoder_lora_layers






def  _snake_case			(						snake_case__				:       Union[str, Any]		, snake_case__				:       List[Any]=False       ):
	for _, attn_proc in text_lora_attn_procs.items():
		# set up.weights
		for layer_name, layer_module in attn_proc.named_modules():
			if layer_name.endswith('_lora'       ):
				A  				=				(
				    torch.randn_like(layer_module.up.weight       )
				    if randn_weight
				    else torch.zeros_like(layer_module.up.weight       )
				)
				A  				=				torch.nn.Parameter(snake_case__       )







class 			lowerCAmelCase_			( unittest.TestCase      ):



						'''simple docstring'''


						def   _SCREAMING_SNAKE_CASE (	self       : Dict )       ->				str:
							torch.manual_seed(0 )
							A  				=				UNetaDConditionModel(
							    block_out_channels=(32, 64)					,layers_per_block=2					,sample_size=32					,in_channels=4					,out_channels=4					,down_block_types=('DownBlock2D', 'CrossAttnDownBlock2D')					,up_block_types=('CrossAttnUpBlock2D', 'UpBlock2D')					,cross_attention_dim=32					,)
							A  				=				DDIMScheduler(
							    beta_start=0.0_00_85					,beta_end=0.0_12					,beta_schedule='scaled_linear'					,clip_sample=A_					,set_alpha_to_one=A_					,steps_offset=1					,)
							torch.manual_seed(0 )
							A  				=				AutoencoderKL(
							    block_out_channels=[32, 64]					,in_channels=3					,out_channels=3					,down_block_types=['DownEncoderBlock2D', 'DownEncoderBlock2D']					,up_block_types=['UpDecoderBlock2D', 'UpDecoderBlock2D']					,latent_channels=4					,)
							A  				=				CLIPTextConfig(
							    bos_token_id=0					,eos_token_id=2					,hidden_size=32					,intermediate_size=37					,layer_norm_eps=1e-05					,num_attention_heads=4					,num_hidden_layers=5					,pad_token_id=1					,vocab_size=1000					,)
							A  				=				CLIPTextModel(A_ )
							A  				=				CLIPTokenizer.from_pretrained('hf-internal-testing/tiny-random-clip' )

							A				, A  				=				create_unet_lora_layers(A_ )
							A  				=				create_text_encoder_lora_layers(A_ )

							A  				=				{
							    'unet': unet,
							    'scheduler': scheduler,
							    'vae': vae,
							    'text_encoder': text_encoder,
							    'tokenizer': tokenizer,
							    'safety_checker': None,
							    'feature_extractor': None,
							}
							A  				=				{
							    'unet_lora_layers': unet_lora_layers,
							    'text_encoder_lora_layers': text_encoder_lora_layers,
							    'unet_lora_attn_procs': unet_lora_attn_procs,
							}
							return pipeline_components, lora_components


						def   _SCREAMING_SNAKE_CASE (	self       : Union[str, Any] )       ->				Tuple:
							A  				=				1
							A  				=				10
							A  				=				4
							A  				=				(32, 32)

							A  				=				torch.manual_seed(0 )
							A  				=				floats_tensor((batch_size, num_channels) + sizes )
							A  				=				torch.randint(1					,A_					,size=(batch_size, sequence_length)					,generator=A_ )

							A  				=				{
							    'prompt': 'A painting of a squirrel eating a burger',
							    'generator': generator,
							    'num_inference_steps': 2,
							    'guidance_scale': 6.0,
							    'output_type': 'numpy',
							}

							return noise, input_ids, pipeline_inputs

							# copied from: https://colab.research.google.com/gist/sayakpaul/df2ef6e1ae6d8c10a49d859883b10860/scratchpad.ipynb


						def   _SCREAMING_SNAKE_CASE (	self       : int )       ->				Dict:
							A  				=				77

							A  				=				torch.randint(2					,56					,size=(1, max_seq_length)					,generator=torch.manual_seed(0 ) )

							A  				=				{}
							A  				=				inputs
							return prepared_inputs


						def   _SCREAMING_SNAKE_CASE (	self       : Optional[int]					,A_       : List[Any] )       ->				Optional[Any]:
							A				, A  				=				self.get_dummy_components()
							LoraLoaderMixin.save_lora_weights(
							    save_directory=A_					,unet_lora_layers=lora_components['unet_lora_layers']					,text_encoder_lora_layers=lora_components['text_encoder_lora_layers']					,)
							self.assertTrue(os.path.isfile(os.path.join(A_					,'pytorch_lora_weights.bin' ) ) )


						def   _SCREAMING_SNAKE_CASE (	self       : Union[str, Any] )       ->				Any:
							A				, A  				=				self.get_dummy_components()
							A  				=				StableDiffusionPipeline(**A_ )
							A  				=				sd_pipe.to(A_ )
							sd_pipe.set_progress_bar_config(disable=A_ )

							A				, A				, A  				=				self.get_dummy_inputs()

							A  				=				sd_pipe(**A_ ).images
							A  				=				original_images[0, -3:, -3:, -1]

							with tempfile.TemporaryDirectory() as tmpdirname:
								LoraLoaderMixin.save_lora_weights(
								    save_directory=A_					,unet_lora_layers=lora_components['unet_lora_layers']					,text_encoder_lora_layers=lora_components['text_encoder_lora_layers']					,)
								self.assertTrue(os.path.isfile(os.path.join(A_					,'pytorch_lora_weights.bin' ) ) )
								sd_pipe.load_lora_weights(A_ )

							A  				=				sd_pipe(**A_ ).images
							A  				=				lora_images[0, -3:, -3:, -1]

							# Outputs shouldn't match.
							self.assertFalse(torch.allclose(torch.from_numpy(A_ )					,torch.from_numpy(A_ ) ) )


						def   _SCREAMING_SNAKE_CASE (	self       : List[str] )       ->				List[Any]:
							A				, A  				=				self.get_dummy_components()
							A  				=				StableDiffusionPipeline(**A_ )
							A  				=				sd_pipe.to(A_ )
							sd_pipe.set_progress_bar_config(disable=A_ )

							A				, A				, A  				=				self.get_dummy_inputs()

							A  				=				sd_pipe(**A_ ).images
							A  				=				original_images[0, -3:, -3:, -1]

							with tempfile.TemporaryDirectory() as tmpdirname:
								LoraLoaderMixin.save_lora_weights(
								    save_directory=A_					,unet_lora_layers=lora_components['unet_lora_layers']					,text_encoder_lora_layers=lora_components['text_encoder_lora_layers']					,safe_serialization=A_					,)
								self.assertTrue(os.path.isfile(os.path.join(A_					,'pytorch_lora_weights.safetensors' ) ) )
								sd_pipe.load_lora_weights(A_ )

							A  				=				sd_pipe(**A_ ).images
							A  				=				lora_images[0, -3:, -3:, -1]

							# Outputs shouldn't match.
							self.assertFalse(torch.allclose(torch.from_numpy(A_ )					,torch.from_numpy(A_ ) ) )


						def   _SCREAMING_SNAKE_CASE (	self       : Optional[Any] )       ->				Any:
							A				, A  				=				self.get_dummy_components()
							A  				=				lora_components['unet_lora_attn_procs']
							A  				=				StableDiffusionPipeline(**A_ )
							A  				=				sd_pipe.to(A_ )
							sd_pipe.set_progress_bar_config(disable=A_ )

							A				, A				, A  				=				self.get_dummy_inputs()

							A  				=				sd_pipe(**A_ ).images
							A  				=				original_images[0, -3:, -3:, -1]

							with tempfile.TemporaryDirectory() as tmpdirname:
								A  				=				sd_pipe.unet
								unet.set_attn_processor(A_ )
								unet.save_attn_procs(A_ )
								self.assertTrue(os.path.isfile(os.path.join(A_					,'pytorch_lora_weights.bin' ) ) )
								sd_pipe.load_lora_weights(A_ )

							A  				=				sd_pipe(**A_ ).images
							A  				=				lora_images[0, -3:, -3:, -1]

							# Outputs shouldn't match.
							self.assertFalse(torch.allclose(torch.from_numpy(A_ )					,torch.from_numpy(A_ ) ) )


						def   _SCREAMING_SNAKE_CASE (	self       : int )       ->				List[str]:
							A				, A  				=				self.get_dummy_components()
							A  				=				StableDiffusionPipeline(**A_ )

							A  				=				self.get_dummy_tokens()

							# inference without lora
							A  				=				pipe.text_encoder(**A_ )[0]
							assert outputs_without_lora.shape == (1, 77, 32)

							# create lora_attn_procs with zeroed out up.weights
							A  				=				create_text_encoder_lora_attn_procs(pipe.text_encoder )
							set_lora_up_weights(A_					,randn_weight=A_ )

							# monkey patch
							pipe._modify_text_encoder(A_ )

							# verify that it's okay to release the text_attn_procs which holds the LoRAAttnProcessor.
							del text_attn_procs
							gc.collect()

							# inference with lora
							A  				=				pipe.text_encoder(**A_ )[0]
							assert outputs_with_lora.shape == (1, 77, 32)

							assert torch.allclose(
							    A_					,A_ ), "lora_up_weight are all zero, so the lora outputs should be the same to without lora outputs"

							# create lora_attn_procs with randn up.weights
							A  				=				create_text_encoder_lora_attn_procs(pipe.text_encoder )
							set_lora_up_weights(A_					,randn_weight=A_ )

							# monkey patch
							pipe._modify_text_encoder(A_ )

							# verify that it's okay to release the text_attn_procs which holds the LoRAAttnProcessor.
							del text_attn_procs
							gc.collect()

							# inference with lora
							A  				=				pipe.text_encoder(**A_ )[0]
							assert outputs_with_lora.shape == (1, 77, 32)

							assert not torch.allclose(
							    A_					,A_ ), "lora_up_weight are not zero, so the lora outputs should be different to without lora outputs"


						def   _SCREAMING_SNAKE_CASE (	self       : Optional[int] )       ->				Optional[Any]:
							A				, A  				=				self.get_dummy_components()
							A  				=				StableDiffusionPipeline(**A_ )

							A  				=				self.get_dummy_tokens()

							# inference without lora
							A  				=				pipe.text_encoder(**A_ )[0]
							assert outputs_without_lora.shape == (1, 77, 32)

							# create lora_attn_procs with randn up.weights
							A  				=				create_text_encoder_lora_attn_procs(pipe.text_encoder )
							set_lora_up_weights(A_					,randn_weight=A_ )

							# monkey patch
							pipe._modify_text_encoder(A_ )

							# verify that it's okay to release the text_attn_procs which holds the LoRAAttnProcessor.
							del text_attn_procs
							gc.collect()

							# inference with lora
							A  				=				pipe.text_encoder(**A_ )[0]
							assert outputs_with_lora.shape == (1, 77, 32)

							assert not torch.allclose(
							    A_					,A_ ), "lora outputs should be different to without lora outputs"

							# remove monkey patch
							pipe._remove_text_encoder_monkey_patch()

							# inference with removed lora
							A  				=				pipe.text_encoder(**A_ )[0]
							assert outputs_without_lora_removed.shape == (1, 77, 32)

							assert torch.allclose(
							    A_					,A_ ), "remove lora monkey patch should restore the original outputs"


						def   _SCREAMING_SNAKE_CASE (	self       : str )       ->				Union[str, Any]:
							A				, A  				=				self.get_dummy_components()
							A  				=				StableDiffusionPipeline(**A_ )
							A  				=				sd_pipe.to(A_ )
							sd_pipe.set_progress_bar_config(disable=A_ )

							A				, A				, A  				=				self.get_dummy_inputs()

							with tempfile.TemporaryDirectory() as tmpdirname:
								LoraLoaderMixin.save_lora_weights(
								    save_directory=A_					,unet_lora_layers=lora_components['unet_lora_layers']					,text_encoder_lora_layers=lora_components['text_encoder_lora_layers']					,)
								self.assertTrue(os.path.isfile(os.path.join(A_					,'pytorch_lora_weights.bin' ) ) )
								sd_pipe.load_lora_weights(A_ )

							A  				=				sd_pipe(**A_ ).images
							A  				=				lora_images[0, -3:, -3:, -1]

							A  				=				sd_pipe(**A_					,cross_attention_kwargs={'scale': 0.5} ).images
							A  				=				lora_images_with_scale[0, -3:, -3:, -1]

							# Outputs shouldn't match.
							self.assertFalse(
							    torch.allclose(torch.from_numpy(A_ )					,torch.from_numpy(A_ ) ) )


						def   _SCREAMING_SNAKE_CASE (	self       : Optional[int] )       ->				Tuple:
							with tempfile.TemporaryDirectory() as tmpdirname:
								self.create_lora_weight_file(A_ )

								A				, A  				=				self.get_dummy_components()
								A  				=				StableDiffusionPipeline(**A_ )
								A  				=				sd_pipe.to(A_ )
								sd_pipe.set_progress_bar_config(disable=A_ )

								# check if vanilla attention processors are used
								for _, module in sd_pipe.unet.named_modules():
									if isinstance(A_					,A_ ):
										self.assertIsInstance(module.processor					,(AttnProcessor, AttnProcessor2_0) )

            # load LoRA weight file
								sd_pipe.load_lora_weights(A_ )

								# check if lora attention processors are used
								for _, module in sd_pipe.unet.named_modules():
									if isinstance(A_					,A_ ):
										A  				=				(
										    LoRAAttnProcessor2_0 if hasattr(A_					,'scaled_dot_product_attention' ) else LoRAAttnProcessor
										)
										self.assertIsInstance(module.processor					,A_ )


						@unittest.skipIf(torch_device != 'cuda'					,'This test is supposed to run on GPU' )
						def   _SCREAMING_SNAKE_CASE (	self       : List[Any] )       ->				List[Any]:
							with tempfile.TemporaryDirectory() as tmpdirname:
								self.create_lora_weight_file(A_ )

								A				, A  				=				self.get_dummy_components()
								A  				=				StableDiffusionPipeline(**A_ )
								A  				=				sd_pipe.to(A_ )
								sd_pipe.set_progress_bar_config(disable=A_ )

								# enable XFormers
								sd_pipe.enable_xformers_memory_efficient_attention()

								# check if xFormers attention processors are used
								for _, module in sd_pipe.unet.named_modules():
									if isinstance(A_					,A_ ):
										self.assertIsInstance(module.processor					,A_ )

            # load LoRA weight file
								sd_pipe.load_lora_weights(A_ )

								# check if lora attention processors are used
								for _, module in sd_pipe.unet.named_modules():
									if isinstance(A_					,A_ ):
										self.assertIsInstance(module.processor					,A_ )




						@unittest.skipIf(torch_device != 'cuda'					,'This test is supposed to run on GPU' )
						def   _SCREAMING_SNAKE_CASE (	self       : int )       ->				int:
							A				, A  				=				self.get_dummy_components()
							A  				=				StableDiffusionPipeline(**A_ )
							A  				=				sd_pipe.to(A_ )
							sd_pipe.set_progress_bar_config(disable=A_ )

							A				, A				, A  				=				self.get_dummy_inputs()

							# enable XFormers
							sd_pipe.enable_xformers_memory_efficient_attention()

							A  				=				sd_pipe(**A_ ).images
							A  				=				original_images[0, -3:, -3:, -1]

							with tempfile.TemporaryDirectory() as tmpdirname:
								LoraLoaderMixin.save_lora_weights(
								    save_directory=A_					,unet_lora_layers=lora_components['unet_lora_layers']					,text_encoder_lora_layers=lora_components['text_encoder_lora_layers']					,)
								self.assertTrue(os.path.isfile(os.path.join(A_					,'pytorch_lora_weights.bin' ) ) )
								sd_pipe.load_lora_weights(A_ )

							A  				=				sd_pipe(**A_ ).images
							A  				=				lora_images[0, -3:, -3:, -1]

							# Outputs shouldn't match.
							self.assertFalse(torch.allclose(torch.from_numpy(A_ )					,torch.from_numpy(A_ ) ) )

"""simple docstring"""


from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_torch_available,
)


_lowercase											=			{
    '''auto_factory''': ['''get_values'''],
    '''configuration_auto''': ['''ALL_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''CONFIG_MAPPING''', '''MODEL_NAMES_MAPPING''', '''AutoConfig'''],
    '''feature_extraction_auto''': ['''FEATURE_EXTRACTOR_MAPPING''', '''AutoFeatureExtractor'''],
    '''image_processing_auto''': ['''IMAGE_PROCESSOR_MAPPING''', '''AutoImageProcessor'''],
    '''processing_auto''': ['''PROCESSOR_MAPPING''', '''AutoProcessor'''],
    '''tokenization_auto''': ['''TOKENIZER_MAPPING''', '''AutoTokenizer'''],
}

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		_lowercase											=			[
		    '''MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING''',
		    '''MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING''',
		    '''MODEL_FOR_AUDIO_XVECTOR_MAPPING''',
		    '''MODEL_FOR_BACKBONE_MAPPING''',
		    '''MODEL_FOR_CAUSAL_IMAGE_MODELING_MAPPING''',
		    '''MODEL_FOR_CAUSAL_LM_MAPPING''',
		    '''MODEL_FOR_CTC_MAPPING''',
		    '''MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING''',
		    '''MODEL_FOR_DEPTH_ESTIMATION_MAPPING''',
		    '''MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING''',
		    '''MODEL_FOR_IMAGE_SEGMENTATION_MAPPING''',
		    '''MODEL_FOR_INSTANCE_SEGMENTATION_MAPPING''',
		    '''MODEL_FOR_MASKED_IMAGE_MODELING_MAPPING''',
		    '''MODEL_FOR_MASKED_LM_MAPPING''',
		    '''MODEL_FOR_MASK_GENERATION_MAPPING''',
		    '''MODEL_FOR_MULTIPLE_CHOICE_MAPPING''',
		    '''MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING''',
		    '''MODEL_FOR_OBJECT_DETECTION_MAPPING''',
		    '''MODEL_FOR_PRETRAINING_MAPPING''',
		    '''MODEL_FOR_QUESTION_ANSWERING_MAPPING''',
		    '''MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING''',
		    '''MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING''',
		    '''MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING''',
		    '''MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING''',
		    '''MODEL_FOR_TABLE_QUESTION_ANSWERING_MAPPING''',
		    '''MODEL_FOR_TEXT_ENCODING_MAPPING''',
		    '''MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING''',
		    '''MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING''',
		    '''MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING''',
		    '''MODEL_FOR_VISION_2_SEQ_MAPPING''',
		    '''MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING''',
		    '''MODEL_MAPPING''',
		    '''MODEL_WITH_LM_HEAD_MAPPING''',
		    '''MODEL_FOR_ZERO_SHOT_IMAGE_CLASSIFICATION_MAPPING''',
		    '''MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING''',
		    '''AutoModel''',
		    '''AutoBackbone''',
		    '''AutoModelForAudioClassification''',
		    '''AutoModelForAudioFrameClassification''',
		    '''AutoModelForAudioXVector''',
		    '''AutoModelForCausalLM''',
		    '''AutoModelForCTC''',
		    '''AutoModelForDepthEstimation''',
		    '''AutoModelForImageClassification''',
		    '''AutoModelForImageSegmentation''',
		    '''AutoModelForInstanceSegmentation''',
		    '''AutoModelForMaskGeneration''',
		    '''AutoModelForTextEncoding''',
		    '''AutoModelForMaskedImageModeling''',
		    '''AutoModelForMaskedLM''',
		    '''AutoModelForMultipleChoice''',
		    '''AutoModelForNextSentencePrediction''',
		    '''AutoModelForObjectDetection''',
		    '''AutoModelForPreTraining''',
		    '''AutoModelForQuestionAnswering''',
		    '''AutoModelForSemanticSegmentation''',
		    '''AutoModelForSeq2SeqLM''',
		    '''AutoModelForSequenceClassification''',
		    '''AutoModelForSpeechSeq2Seq''',
		    '''AutoModelForTableQuestionAnswering''',
		    '''AutoModelForTokenClassification''',
		    '''AutoModelForUniversalSegmentation''',
		    '''AutoModelForVideoClassification''',
		    '''AutoModelForVision2Seq''',
		    '''AutoModelForVisualQuestionAnswering''',
		    '''AutoModelForDocumentQuestionAnswering''',
		    '''AutoModelWithLMHead''',
		    '''AutoModelForZeroShotImageClassification''',
		    '''AutoModelForZeroShotObjectDetection''',
		]

try:
		if not is_tf_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		_lowercase											=			[
		    '''TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING''',
		    '''TF_MODEL_FOR_CAUSAL_LM_MAPPING''',
		    '''TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING''',
		    '''TF_MODEL_FOR_MASK_GENERATION_MAPPING''',
		    '''TF_MODEL_FOR_MASKED_IMAGE_MODELING_MAPPING''',
		    '''TF_MODEL_FOR_MASKED_LM_MAPPING''',
		    '''TF_MODEL_FOR_MULTIPLE_CHOICE_MAPPING''',
		    '''TF_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING''',
		    '''TF_MODEL_FOR_PRETRAINING_MAPPING''',
		    '''TF_MODEL_FOR_QUESTION_ANSWERING_MAPPING''',
		    '''TF_MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING''',
		    '''TF_MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING''',
		    '''TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING''',
		    '''TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING''',
		    '''TF_MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING''',
		    '''TF_MODEL_FOR_TABLE_QUESTION_ANSWERING_MAPPING''',
		    '''TF_MODEL_FOR_TEXT_ENCODING_MAPPING''',
		    '''TF_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING''',
		    '''TF_MODEL_FOR_VISION_2_SEQ_MAPPING''',
		    '''TF_MODEL_FOR_ZERO_SHOT_IMAGE_CLASSIFICATION_MAPPING''',
		    '''TF_MODEL_MAPPING''',
		    '''TF_MODEL_WITH_LM_HEAD_MAPPING''',
		    '''TFAutoModel''',
		    '''TFAutoModelForAudioClassification''',
		    '''TFAutoModelForCausalLM''',
		    '''TFAutoModelForImageClassification''',
		    '''TFAutoModelForMaskedImageModeling''',
		    '''TFAutoModelForMaskedLM''',
		    '''TFAutoModelForMaskGeneration''',
		    '''TFAutoModelForMultipleChoice''',
		    '''TFAutoModelForNextSentencePrediction''',
		    '''TFAutoModelForPreTraining''',
		    '''TFAutoModelForDocumentQuestionAnswering''',
		    '''TFAutoModelForQuestionAnswering''',
		    '''TFAutoModelForSemanticSegmentation''',
		    '''TFAutoModelForSeq2SeqLM''',
		    '''TFAutoModelForSequenceClassification''',
		    '''TFAutoModelForSpeechSeq2Seq''',
		    '''TFAutoModelForTableQuestionAnswering''',
		    '''TFAutoModelForTextEncoding''',
		    '''TFAutoModelForTokenClassification''',
		    '''TFAutoModelForVision2Seq''',
		    '''TFAutoModelForZeroShotImageClassification''',
		    '''TFAutoModelWithLMHead''',
		]

try:
		if not is_flax_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		_lowercase											=			[
		    '''FLAX_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING''',
		    '''FLAX_MODEL_FOR_CAUSAL_LM_MAPPING''',
		    '''FLAX_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING''',
		    '''FLAX_MODEL_FOR_MASKED_LM_MAPPING''',
		    '''FLAX_MODEL_FOR_MULTIPLE_CHOICE_MAPPING''',
		    '''FLAX_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING''',
		    '''FLAX_MODEL_FOR_PRETRAINING_MAPPING''',
		    '''FLAX_MODEL_FOR_QUESTION_ANSWERING_MAPPING''',
		    '''FLAX_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING''',
		    '''FLAX_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING''',
		    '''FLAX_MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING''',
		    '''FLAX_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING''',
		    '''FLAX_MODEL_FOR_VISION_2_SEQ_MAPPING''',
		    '''FLAX_MODEL_MAPPING''',
		    '''FlaxAutoModel''',
		    '''FlaxAutoModelForCausalLM''',
		    '''FlaxAutoModelForImageClassification''',
		    '''FlaxAutoModelForMaskedLM''',
		    '''FlaxAutoModelForMultipleChoice''',
		    '''FlaxAutoModelForNextSentencePrediction''',
		    '''FlaxAutoModelForPreTraining''',
		    '''FlaxAutoModelForQuestionAnswering''',
		    '''FlaxAutoModelForSeq2SeqLM''',
		    '''FlaxAutoModelForSequenceClassification''',
		    '''FlaxAutoModelForSpeechSeq2Seq''',
		    '''FlaxAutoModelForTokenClassification''',
		    '''FlaxAutoModelForVision2Seq''',
		]


if TYPE_CHECKING:
		from .auto_factory import get_values
		from .configuration_auto import ALL_PRETRAINED_CONFIG_ARCHIVE_MAP, CONFIG_MAPPING, MODEL_NAMES_MAPPING, AutoConfig
		from .feature_extraction_auto import FEATURE_EXTRACTOR_MAPPING, AutoFeatureExtractor
		from .image_processing_auto import IMAGE_PROCESSOR_MAPPING, AutoImageProcessor
		from .processing_auto import PROCESSOR_MAPPING, AutoProcessor
		from .tokenization_auto import TOKENIZER_MAPPING, AutoTokenizer

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_auto import (
				    MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING,
				    MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING,
				    MODEL_FOR_AUDIO_XVECTOR_MAPPING,
				    MODEL_FOR_BACKBONE_MAPPING,
				    MODEL_FOR_CAUSAL_IMAGE_MODELING_MAPPING,
				    MODEL_FOR_CAUSAL_LM_MAPPING,
				    MODEL_FOR_CTC_MAPPING,
				    MODEL_FOR_DEPTH_ESTIMATION_MAPPING,
				    MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING,
				    MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING,
				    MODEL_FOR_IMAGE_SEGMENTATION_MAPPING,
				    MODEL_FOR_INSTANCE_SEGMENTATION_MAPPING,
				    MODEL_FOR_MASK_GENERATION_MAPPING,
				    MODEL_FOR_MASKED_IMAGE_MODELING_MAPPING,
				    MODEL_FOR_MASKED_LM_MAPPING,
				    MODEL_FOR_MULTIPLE_CHOICE_MAPPING,
				    MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING,
				    MODEL_FOR_OBJECT_DETECTION_MAPPING,
				    MODEL_FOR_PRETRAINING_MAPPING,
				    MODEL_FOR_QUESTION_ANSWERING_MAPPING,
				    MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING,
				    MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING,
				    MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
				    MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING,
				    MODEL_FOR_TABLE_QUESTION_ANSWERING_MAPPING,
				    MODEL_FOR_TEXT_ENCODING_MAPPING,
				    MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING,
				    MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING,
				    MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING,
				    MODEL_FOR_VISION_2_SEQ_MAPPING,
				    MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING,
				    MODEL_FOR_ZERO_SHOT_IMAGE_CLASSIFICATION_MAPPING,
				    MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING,
				    MODEL_MAPPING,
				    MODEL_WITH_LM_HEAD_MAPPING,
				    AutoBackbone,
				    AutoModel,
				    AutoModelForAudioClassification,
				    AutoModelForAudioFrameClassification,
				    AutoModelForAudioXVector,
				    AutoModelForCausalLM,
				    AutoModelForCTC,
				    AutoModelForDepthEstimation,
				    AutoModelForDocumentQuestionAnswering,
				    AutoModelForImageClassification,
				    AutoModelForImageSegmentation,
				    AutoModelForInstanceSegmentation,
				    AutoModelForMaskedImageModeling,
				    AutoModelForMaskedLM,
				    AutoModelForMaskGeneration,
				    AutoModelForMultipleChoice,
				    AutoModelForNextSentencePrediction,
				    AutoModelForObjectDetection,
				    AutoModelForPreTraining,
				    AutoModelForQuestionAnswering,
				    AutoModelForSemanticSegmentation,
				    AutoModelForSeqaSeqLM,
				    AutoModelForSequenceClassification,
				    AutoModelForSpeechSeqaSeq,
				    AutoModelForTableQuestionAnswering,
				    AutoModelForTextEncoding,
				    AutoModelForTokenClassification,
				    AutoModelForUniversalSegmentation,
				    AutoModelForVideoClassification,
				    AutoModelForVisionaSeq,
				    AutoModelForVisualQuestionAnswering,
				    AutoModelForZeroShotImageClassification,
				    AutoModelForZeroShotObjectDetection,
				    AutoModelWithLMHead,
				)

		try:
				if not is_tf_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_tf_auto import (
				    TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING,
				    TF_MODEL_FOR_CAUSAL_LM_MAPPING,
				    TF_MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING,
				    TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING,
				    TF_MODEL_FOR_MASK_GENERATION_MAPPING,
				    TF_MODEL_FOR_MASKED_IMAGE_MODELING_MAPPING,
				    TF_MODEL_FOR_MASKED_LM_MAPPING,
				    TF_MODEL_FOR_MULTIPLE_CHOICE_MAPPING,
				    TF_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING,
				    TF_MODEL_FOR_PRETRAINING_MAPPING,
				    TF_MODEL_FOR_QUESTION_ANSWERING_MAPPING,
				    TF_MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING,
				    TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING,
				    TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
				    TF_MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING,
				    TF_MODEL_FOR_TABLE_QUESTION_ANSWERING_MAPPING,
				    TF_MODEL_FOR_TEXT_ENCODING_MAPPING,
				    TF_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING,
				    TF_MODEL_FOR_VISION_2_SEQ_MAPPING,
				    TF_MODEL_FOR_ZERO_SHOT_IMAGE_CLASSIFICATION_MAPPING,
				    TF_MODEL_MAPPING,
				    TF_MODEL_WITH_LM_HEAD_MAPPING,
				    TFAutoModel,
				    TFAutoModelForAudioClassification,
				    TFAutoModelForCausalLM,
				    TFAutoModelForDocumentQuestionAnswering,
				    TFAutoModelForImageClassification,
				    TFAutoModelForMaskedImageModeling,
				    TFAutoModelForMaskedLM,
				    TFAutoModelForMaskGeneration,
				    TFAutoModelForMultipleChoice,
				    TFAutoModelForNextSentencePrediction,
				    TFAutoModelForPreTraining,
				    TFAutoModelForQuestionAnswering,
				    TFAutoModelForSemanticSegmentation,
				    TFAutoModelForSeqaSeqLM,
				    TFAutoModelForSequenceClassification,
				    TFAutoModelForSpeechSeqaSeq,
				    TFAutoModelForTableQuestionAnswering,
				    TFAutoModelForTextEncoding,
				    TFAutoModelForTokenClassification,
				    TFAutoModelForVisionaSeq,
				    TFAutoModelForZeroShotImageClassification,
				    TFAutoModelWithLMHead,
				)

		try:
				if not is_flax_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_flax_auto import (
				    FLAX_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING,
				    FLAX_MODEL_FOR_CAUSAL_LM_MAPPING,
				    FLAX_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING,
				    FLAX_MODEL_FOR_MASKED_LM_MAPPING,
				    FLAX_MODEL_FOR_MULTIPLE_CHOICE_MAPPING,
				    FLAX_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING,
				    FLAX_MODEL_FOR_PRETRAINING_MAPPING,
				    FLAX_MODEL_FOR_QUESTION_ANSWERING_MAPPING,
				    FLAX_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING,
				    FLAX_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
				    FLAX_MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING,
				    FLAX_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING,
				    FLAX_MODEL_FOR_VISION_2_SEQ_MAPPING,
				    FLAX_MODEL_MAPPING,
				    FlaxAutoModel,
				    FlaxAutoModelForCausalLM,
				    FlaxAutoModelForImageClassification,
				    FlaxAutoModelForMaskedLM,
				    FlaxAutoModelForMultipleChoice,
				    FlaxAutoModelForNextSentencePrediction,
				    FlaxAutoModelForPreTraining,
				    FlaxAutoModelForQuestionAnswering,
				    FlaxAutoModelForSeqaSeqLM,
				    FlaxAutoModelForSequenceClassification,
				    FlaxAutoModelForSpeechSeqaSeq,
				    FlaxAutoModelForTokenClassification,
				    FlaxAutoModelForVisionaSeq,
				)

else:
		import sys

		_lowercase											=			_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)