




'''simple docstring'''
import timeit
from typing import Callable, Optional

from ..configuration_utils import PretrainedConfig
from ..models.auto.modeling_auto import MODEL_MAPPING, MODEL_WITH_LM_HEAD_MAPPING
from ..utils import is_pyanvml_available, is_torch_available, logging
from .benchmark_utils import (
    Benchmark,
    Memory,
    MemorySummary,
    measure_peak_memory_cpu,
    start_memory_tracing,
    stop_memory_tracing,
)


if is_torch_available():
  import torch

  from .benchmark_args import PyTorchBenchmarkArguments


if is_pyanvml_available():
  import pyanvml.pyanvml as nvml


A							:				Optional[int]			     =	logging.get_logger(__name__)






class 	SCREAMING_SNAKE_CASE(    __A					):
       snake_case_			:					PyTorchBenchmarkArguments
       snake_case_			:					PretrainedConfig
       snake_case_			:					str   = "PyTorch"

       @property
       def    snake_case__      (   self					)   -> Any:

           """simple docstring"""



           return torch.__version__

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

           """simple docstring"""



           __lowercase          =						self._prepare_inference_func(lowerCamelCase__ ,		lowerCamelCase__ ,		lowerCamelCase__					)
           return self._measure_speed(_inference					)

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

           """simple docstring"""



           __lowercase          =						self._prepare_inference_func(lowerCamelCase__ ,		lowerCamelCase__ ,		lowerCamelCase__					)
           return self._measure_memory(_inference					)

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

           """simple docstring"""



           __lowercase          =						self._prepare_train_func(lowerCamelCase__ ,		lowerCamelCase__ ,		lowerCamelCase__					)
           return self._measure_speed(_train					)

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

           """simple docstring"""



           __lowercase          =						self._prepare_train_func(lowerCamelCase__ ,		lowerCamelCase__ ,		lowerCamelCase__					)
           return self._measure_memory(_train					)

       def    snake_case__      (   self ,		lowerCamelCase__ ,		lowerCamelCase__ ,		lowerCamelCase__					)   -> Callable[[], None]:

           """simple docstring"""



           __lowercase          =						self.config_dict[model_name]

           if self.args.torchscript:
               __lowercase          =						True

           __lowercase          =						(
               hasattr(lowerCamelCase__ ,		"""architectures"""					)
               and isinstance(config.architectures ,		lowerCamelCase__					)
               and len(config.architectures					) > 0
           )
           if not self.args.only_pretrain_model and has_model_class_in_config:
               try:
                   __lowercase          =						config.architectures[0]
                   __lowercase          =						__import__("""transformers""" ,		fromlist=[model_class]					)
                   __lowercase          =						getattr(lowerCamelCase__ ,		lowerCamelCase__					)
                   __lowercase          =						model_cls(lowerCamelCase__					)
               except ImportError:
                   raise ImportError(
                       F'{model_class} does not exist. If you just want to test the pretrained model, you might want to'
                       """ set `--only_pretrain_model` or `args.only_pretrain_model=True`."""					)
           else:
               __lowercase          =						MODEL_MAPPING[config.__class__](lowerCamelCase__					)

           model.eval()
           model.to(self.args.device					)

           # encoder-decoder has vocab size saved differently
           __lowercase          =						config.vocab_size if hasattr(lowerCamelCase__ ,		"""vocab_size"""					) else config.encoder.vocab_size
           __lowercase          =						torch.randint(lowerCamelCase__ ,		(batch_size, sequence_length) ,		dtype=torch.long ,		device=self.args.device					)

           if self.args.fpaa:
               logger.info("""Running training in Mixed Precision..."""					)
               if not self.args.is_gpu:
                   raise ValueError("""Mixed precision is possible only for GPU."""					)
               # amp seems to have memory leaks so that memory usage
               # is measured using .half() for now https://github.com/NVIDIA/apex/issues/439
               model.half()

           if self.args.torchscript:
               with torch.no_grad():
                   __lowercase          =						torch.jit.trace(lowerCamelCase__ ,		lowerCamelCase__					)
           else:
               __lowercase          =						model

           def encoder_decoder_forward():
               with torch.no_grad():
                   __lowercase          =						inference_model(lowerCamelCase__ ,		decoder_input_ids=lowerCamelCase__					)
               return outputs

           def encoder_forward():
               with torch.no_grad():
                   __lowercase          =						inference_model(lowerCamelCase__					)
               return outputs

           __lowercase          =						encoder_decoder_forward if config.is_encoder_decoder else encoder_forward
           return _forward

       def    snake_case__      (   self ,		lowerCamelCase__ ,		lowerCamelCase__ ,		lowerCamelCase__					)   -> Callable[[], None]:

           """simple docstring"""



           __lowercase          =						self.config_dict[model_name]

           __lowercase          =						(
               hasattr(lowerCamelCase__ ,		"""architectures"""					)
               and isinstance(config.architectures ,		lowerCamelCase__					)
               and len(config.architectures					) > 0
           )
           if not self.args.only_pretrain_model and has_model_class_in_config:
               try:
                   __lowercase          =						config.architectures[0]
                   __lowercase          =						__import__("""transformers""" ,		fromlist=[model_class]					)
                   __lowercase          =						getattr(lowerCamelCase__ ,		lowerCamelCase__					)
                   __lowercase          =						model_cls(lowerCamelCase__					)
               except ImportError:
                   raise ImportError(
                       F'{model_class} does not exist. If you just want to test the pretrained model, you might want to'
                       """ set `--only_pretrain_model` or `args.only_pretrain_model=True`."""					)
           else:
               __lowercase          =						MODEL_WITH_LM_HEAD_MAPPING[config.__class__](lowerCamelCase__					)

           if self.args.torchscript:
               raise NotImplementedError("""Training for torchscript is currently not implemented"""					)
           else:
               __lowercase          =						model

           model.train()
           model.to(self.args.device					)

           # encoder-decoder has vocab size saved differently
           __lowercase          =						config.vocab_size if hasattr(lowerCamelCase__ ,		"""vocab_size"""					) else config.encoder.vocab_size
           __lowercase          =						torch.randint(lowerCamelCase__ ,		(batch_size, sequence_length) ,		dtype=torch.long ,		device=self.args.device					)

           if self.args.fpaa:
               logger.info("""Running training in Mixed Precision..."""					)
               if not self.args.is_gpu:
                   raise ValueError("""Mixed precision is possible only for GPU."""					)

               # amp seems to have memory leaks so that memory usage
               # is measured using .half() for now https://github.com/NVIDIA/apex/issues/439
               model.half()

           def compute_loss_and_backprob_encoder():
               __lowercase          =						train_model(lowerCamelCase__ ,		labels=lowerCamelCase__					)[0]
               loss.backward()
               return loss

           def compute_loss_and_backprob_encoder_decoder():
               __lowercase          =						train_model(lowerCamelCase__ ,		decoder_input_ids=lowerCamelCase__ ,		labels=lowerCamelCase__					)[0]
               loss.backward()
               return loss

           __lowercase          =						(
               compute_loss_and_backprob_encoder_decoder
               if config.is_encoder_decoder
               else compute_loss_and_backprob_encoder
           )
           return _train

       def    snake_case__      (   self ,		lowerCamelCase__					)   -> float:

           """simple docstring"""



           try:
               if self.args.is_tpu or self.args.torchscript:
                   # run additional 10 times to stabilize compilation for tpu and torchscript
                   logger.info("""Do inference on TPU or torchscript. Running model 5 times to stabilize compilation"""					)
                   timeit.repeat(
                       lowerCamelCase__ ,		repeat=1 ,		number=5 ,		)

               # as written in https://docs.python.org/2/library/timeit.html#timeit.Timer.repeat, min should be taken rather than the average
               __lowercase          =						timeit.repeat(
                   lowerCamelCase__ ,		repeat=self.args.repeat ,		number=10 ,		)

               if self.args.is_tpu and self.args.torch_xla_tpu_print_metrics:
                   import torch_xla.debug.metrics as met

                   self.print_fn(met.metrics_report()					)

               return min(lowerCamelCase__					) / 10.0
           except RuntimeError as e:
               self.print_fn(F'Doesn\'t fit on GPU. {e}'					)
               return "N/A"




       def    snake_case__      (   self ,		lowerCamelCase__					)   -> [Memory, MemorySummary]:

           """simple docstring"""



           try:
               if self.args.trace_memory_line_by_line:
                   __lowercase          =						start_memory_tracing("""transformers"""					)

               if self.args.is_tpu:
                   # tpu
                   raise NotImplementedError(
                       """Memory Benchmarking is currently not implemented for TPU. Please disable memory benchmarking with"""
                       """ `--no-memory` or `args.memory=False`"""					)
               elif self.args.is_gpu:
                   if not is_pyanvml_available():
                       logger.warning(
                           """py3nvml not installed, we won't log GPU memory usage. """
                           """Install py3nvml (pip install py3nvml) to log information about GPU."""					)
                       __lowercase          =						"""N/A"""
                   else:
                       logger.info(
                           """Measuring total GPU usage on GPU device. Make sure to not have additional processes running"""
                           """ on the same GPU."""					)
                       # init nvml
                       nvml.nvmlInit()
                       func()
                       __lowercase          =						nvml.nvmlDeviceGetHandleByIndex(self.args.device_idx					)
                       __lowercase          =						nvml.nvmlDeviceGetMemoryInfo(lowerCamelCase__					)
                       __lowercase          =						meminfo.used
                       __lowercase          =						Memory(lowerCamelCase__					)
                       # shutdown nvml
                       nvml.nvmlShutdown()
               else:
                   # cpu
                   __lowercase          =						measure_peak_memory_cpu(lowerCamelCase__					)
                   __lowercase          =						Memory(lowerCamelCase__					) if isinstance(lowerCamelCase__ ,		lowerCamelCase__					) else memory_bytes

               if self.args.trace_memory_line_by_line:
                   __lowercase          =						stop_memory_tracing(lowerCamelCase__					)
               else:
                   __lowercase          =						None

               return memory, summary
           except RuntimeError as e:
               self.print_fn(F'Doesn\'t fit on GPU. {e}'					)
               return "N/A", None










'''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__)




