




'''simple docstring'''
import inspect
import unittest

from transformers import ResNetConfig
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_backbone_common import BackboneTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
  import torch
  from torch import nn

  from transformers import ResNetBackbone, ResNetForImageClassification, ResNetModel
  from transformers.models.resnet.modeling_resnet import RESNET_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
  from PIL import Image

  from transformers import AutoImageProcessor






class 	SCREAMING_SNAKE_CASE:

       def __init__(   self ,		lowerCamelCase__ ,		lowerCamelCase__=3 ,		lowerCamelCase__=32 ,		lowerCamelCase__=3 ,		lowerCamelCase__=10 ,		lowerCamelCase__=[10, 20, 30, 40] ,		lowerCamelCase__=[1, 1, 2, 1] ,		lowerCamelCase__=True ,		lowerCamelCase__=True ,		lowerCamelCase__="relu" ,		lowerCamelCase__=3 ,		lowerCamelCase__=None ,		lowerCamelCase__=["stage2", "stage3", "stage4"] ,		lowerCamelCase__=[2, 3, 4] ,		)   -> Optional[int]:

           """simple docstring"""



           __lowercase          =						parent
           __lowercase          =						batch_size
           __lowercase          =						image_size
           __lowercase          =						num_channels
           __lowercase          =						embeddings_size
           __lowercase          =						hidden_sizes
           __lowercase          =						depths
           __lowercase          =						is_training
           __lowercase          =						use_labels
           __lowercase          =						hidden_act
           __lowercase          =						num_labels
           __lowercase          =						scope
           __lowercase          =						len(lowerCamelCase__					)
           __lowercase          =						out_features
           __lowercase          =						out_indices

       def    snake_case__      (   self					)   -> Dict:

           """simple docstring"""



           __lowercase          =						floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]					)

           __lowercase          =						None
           if self.use_labels:
               __lowercase          =						ids_tensor([self.batch_size] ,		self.num_labels					)

           __lowercase          =						self.get_config()

           return config, pixel_values, labels

       def    snake_case__      (   self					)   -> Optional[int]:

           """simple docstring"""



           return ResNetConfig(
               num_channels=self.num_channels ,		embeddings_size=self.embeddings_size ,		hidden_sizes=self.hidden_sizes ,		depths=self.depths ,		hidden_act=self.hidden_act ,		num_labels=self.num_labels ,		out_features=self.out_features ,		out_indices=self.out_indices ,		)

       def    snake_case__      (   self ,		lowerCamelCase__ ,		lowerCamelCase__ ,		lowerCamelCase__					)   -> List[Any]:

           """simple docstring"""



           __lowercase          =						ResNetModel(config=lowerCamelCase__					)
           model.to(lowerCamelCase__					)
           model.eval()
           __lowercase          =						model(lowerCamelCase__					)
           # expected last hidden states: B, C, H // 32, W // 32
           self.parent.assertEqual(
               result.last_hidden_state.shape ,		(self.batch_size, self.hidden_sizes[-1], self.image_size // 32, self.image_size // 32) ,		)

       def    snake_case__      (   self ,		lowerCamelCase__ ,		lowerCamelCase__ ,		lowerCamelCase__					)   -> str:

           """simple docstring"""



           __lowercase          =						self.num_labels
           __lowercase          =						ResNetForImageClassification(lowerCamelCase__					)
           model.to(lowerCamelCase__					)
           model.eval()
           __lowercase          =						model(lowerCamelCase__ ,		labels=lowerCamelCase__					)
           self.parent.assertEqual(result.logits.shape ,		(self.batch_size, self.num_labels)					)

       def    snake_case__      (   self ,		lowerCamelCase__ ,		lowerCamelCase__ ,		lowerCamelCase__					)   -> Optional[Any]:

           """simple docstring"""



           __lowercase          =						ResNetBackbone(config=lowerCamelCase__					)
           model.to(lowerCamelCase__					)
           model.eval()
           __lowercase          =						model(lowerCamelCase__					)

           # verify feature maps
           self.parent.assertEqual(len(result.feature_maps					) ,		len(config.out_features					)					)
           self.parent.assertListEqual(list(result.feature_maps[0].shape					) ,		[self.batch_size, self.hidden_sizes[1], 4, 4]					)

           # verify channels
           self.parent.assertEqual(len(model.channels					) ,		len(config.out_features					)					)
           self.parent.assertListEqual(model.channels ,		config.hidden_sizes[1:]					)

           # verify backbone works with out_features=None
           __lowercase          =						None
           __lowercase          =						ResNetBackbone(config=lowerCamelCase__					)
           model.to(lowerCamelCase__					)
           model.eval()
           __lowercase          =						model(lowerCamelCase__					)

           # verify feature maps
           self.parent.assertEqual(len(result.feature_maps					) ,		1					)
           self.parent.assertListEqual(list(result.feature_maps[0].shape					) ,		[self.batch_size, self.hidden_sizes[-1], 1, 1]					)

           # verify channels
           self.parent.assertEqual(len(model.channels					) ,		1					)
           self.parent.assertListEqual(model.channels ,		[config.hidden_sizes[-1]]					)




       def    snake_case__      (   self					)   -> Union[str, Any]:

           """simple docstring"""



           __lowercase          =						self.prepare_config_and_inputs()
           __lowercase    ,__lowercase    ,__lowercase          =						config_and_inputs
           __lowercase          =						{"""pixel_values""": pixel_values}
           return config, inputs_dict






@require_torch
class 	SCREAMING_SNAKE_CASE(    __A       ,				__A       ,				unittest.TestCase					):
       snake_case_			:					int   = (
           (
               ResNetModel,
               ResNetForImageClassification,
               ResNetBackbone,
           )
           if is_torch_available()
           else ()
       )
       snake_case_			:					Optional[int]   = (
           {"""feature-extraction""": ResNetModel, """image-classification""": ResNetForImageClassification}
           if is_torch_available()
           else {}
       )

       snake_case_			:					List[str]   = True
       snake_case_			:					Union[str, Any]   = False
       snake_case_			:					int   = False
       snake_case_			:					str   = False
       snake_case_			:					List[Any]   = False

       def    snake_case__      (   self					)   -> str:

           """simple docstring"""



           __lowercase          =						ResNetModelTester(self					)
           __lowercase          =						ConfigTester(self ,		config_class=lowerCamelCase__ ,		has_text_modality=lowerCamelCase__					)

       def    snake_case__      (   self					)   -> List[Any]:

           """simple docstring"""



           self.create_and_test_config_common_properties()
           self.config_tester.create_and_test_config_to_json_string()
           self.config_tester.create_and_test_config_to_json_file()
           self.config_tester.create_and_test_config_from_and_save_pretrained()
           self.config_tester.create_and_test_config_with_num_labels()
           self.config_tester.check_config_can_be_init_without_params()
           self.config_tester.check_config_arguments_init()

       def    snake_case__      (   self					)   -> List[str]:

           """simple docstring"""



           return

       @unittest.skip(reason="""ResNet does not use inputs_embeds"""					)
       def    snake_case__      (   self					)   -> List[Any]:

           """simple docstring"""



           pass

       @unittest.skip(reason="""ResNet does not support input and output embeddings"""					)
       def    snake_case__      (   self					)   -> Optional[Any]:

           """simple docstring"""



           pass

       def    snake_case__      (   self					)   -> List[Any]:

           """simple docstring"""



           __lowercase    ,__lowercase          =						self.model_tester.prepare_config_and_inputs_for_common()

           for model_class in self.all_model_classes:
               __lowercase          =						model_class(lowerCamelCase__					)
               __lowercase          =						inspect.signature(model.forward					)
               # signature.parameters is an OrderedDict => so arg_names order is deterministic
               __lowercase          =						[*signature.parameters.keys()]

               __lowercase          =						["""pixel_values"""]
               self.assertListEqual(arg_names[:1] ,		lowerCamelCase__					)

       def    snake_case__      (   self					)   -> List[str]:

           """simple docstring"""



           __lowercase          =						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_model(*lowerCamelCase__					)

       def    snake_case__      (   self					)   -> Tuple:

           """simple docstring"""



           __lowercase          =						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_backbone(*lowerCamelCase__					)

       def    snake_case__      (   self					)   -> Any:

           """simple docstring"""



           __lowercase    ,__lowercase          =						self.model_tester.prepare_config_and_inputs_for_common()

           for model_class in self.all_model_classes:
               __lowercase          =						model_class(config=lowerCamelCase__					)
               for name, module in model.named_modules():
                   if isinstance(lowerCamelCase__ ,		(nn.BatchNormad, nn.GroupNorm)					):
                       self.assertTrue(
                           torch.all(module.weight == 1					) ,		msg=F'Parameter {name} of model {model_class} seems not properly initialized' ,		)
                       self.assertTrue(
                           torch.all(module.bias == 0					) ,		msg=F'Parameter {name} of model {model_class} seems not properly initialized' ,		)

       def    snake_case__      (   self					)   -> Optional[Any]:

           """simple docstring"""



           def check_hidden_states_output(lowerCamelCase__ ,		lowerCamelCase__ ,		lowerCamelCase__					):
               __lowercase          =						model_class(lowerCamelCase__					)
               model.to(lowerCamelCase__					)
               model.eval()

               with torch.no_grad():
                   __lowercase          =						model(**self._prepare_for_class(lowerCamelCase__ ,		lowerCamelCase__					)					)

               __lowercase          =						outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states

               __lowercase          =						self.model_tester.num_stages
               self.assertEqual(len(lowerCamelCase__					) ,		expected_num_stages + 1					)

               # ResNet's feature maps are of shape (batch_size, num_channels, height, width)
               self.assertListEqual(
                   list(hidden_states[0].shape[-2:]					) ,		[self.model_tester.image_size // 4, self.model_tester.image_size // 4] ,		)

           __lowercase    ,__lowercase          =						self.model_tester.prepare_config_and_inputs_for_common()
           __lowercase          =						["""basic""", """bottleneck"""]
           for model_class in self.all_model_classes:
               for layer_type in layers_type:
                   __lowercase          =						layer_type
                   __lowercase          =						True
                   check_hidden_states_output(lowerCamelCase__ ,		lowerCamelCase__ ,		lowerCamelCase__					)

                   # check that output_hidden_states also work using config
                   del inputs_dict["output_hidden_states"]
                   __lowercase          =						True

                   check_hidden_states_output(lowerCamelCase__ ,		lowerCamelCase__ ,		lowerCamelCase__					)

       @unittest.skip(reason="""ResNet does not use feedforward chunking"""					)
       def    snake_case__      (   self					)   -> Tuple:

           """simple docstring"""



           pass

       def    snake_case__      (   self					)   -> Tuple:

           """simple docstring"""



           __lowercase          =						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_image_classification(*lowerCamelCase__					)




       @slow
       def    snake_case__      (   self					)   -> List[str]:

           """simple docstring"""



           for model_name in RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
               __lowercase          =						ResNetModel.from_pretrained(lowerCamelCase__					)
               self.assertIsNotNone(lowerCamelCase__					)

def     snake_case_  (       ):



    """simple docstring"""




    __lowercase          =						Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""      )
    return image






@require_torch
@require_vision
class 	SCREAMING_SNAKE_CASE(    unittest.TestCase					):

       @cached_property
       def    snake_case__      (   self					)   -> List[str]:

           """simple docstring"""



           return (
               AutoImageProcessor.from_pretrained(RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[0]					)
               if is_vision_available()
               else None
           )




       @slow
       def    snake_case__      (   self					)   -> Optional[Any]:

           """simple docstring"""



           __lowercase          =						ResNetForImageClassification.from_pretrained(RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[0]					).to(lowerCamelCase__					)

           __lowercase          =						self.default_image_processor
           __lowercase          =						prepare_img()
           __lowercase          =						image_processor(images=lowerCamelCase__ ,		return_tensors="""pt"""					).to(lowerCamelCase__					)

           # forward pass
           with torch.no_grad():
               __lowercase          =						model(**lowerCamelCase__					)

           # verify the logits
           __lowercase          =						torch.Size((1, 1000)					)
           self.assertEqual(outputs.logits.shape ,		lowerCamelCase__					)

           __lowercase          =						torch.tensor([-11.10_69, -9.78_77, -8.37_77]					).to(lowerCamelCase__					)

           self.assertTrue(torch.allclose(outputs.logits[0, :3] ,		lowerCamelCase__ ,		atol=1E-4					)					)






@require_torch
class 	SCREAMING_SNAKE_CASE(    __A       ,				unittest.TestCase					):
       snake_case_			:					Union[str, Any]   = (ResNetBackbone,) if is_torch_available() else ()
       snake_case_			:					List[str]   = False
       snake_case_			:					Union[str, Any]   = ResNetConfig

       def    snake_case__      (   self					)   -> Optional[Any]:

           """simple docstring"""



           __lowercase          =						ResNetModelTester(self					)










'''simple docstring'''
from typing import TYPE_CHECKING

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


A							:				List[str]			     =	{
    """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:
  A							:				Optional[Any]			     =	[
      """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:
  A							:				Dict			     =	[
      """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:
  A							:				Tuple			     =	[
      """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

  A							:				Optional[Any]			     =	_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)




