import tempfile

import torch

from diffusers import (
    DEISMultistepScheduler,
    DPMSolverMultistepScheduler,
    DPMSolverSinglestepScheduler,
    UniPCMultistepScheduler,
)

from .test_schedulers import SchedulerCommonTest






class     __UpperCAmelCase(    A__				):






 """simple docstring"""




 __magic_name__          =   (DPMSolverMultistepScheduler,)
 __magic_name__          =   (("""num_inference_steps""", 25),)
 def  UpperCAmelCase   (    self ,       **__magic_name__      ):

        """simple docstring"""

        A_							:       Union[str, Any]	      =				{
            '''num_train_timesteps''': 1000,
            '''beta_start''': 0.00_01,
            '''beta_end''': 0.02,
            '''beta_schedule''': '''linear''',
            '''solver_order''': 2,
            '''prediction_type''': '''epsilon''',
            '''thresholding''': False,
            '''sample_max_value''': 1.0,
            '''algorithm_type''': '''dpmsolver++''',
            '''solver_type''': '''midpoint''',
            '''lower_order_final''': False,
            '''lambda_min_clipped''': -float('''inf'''      ),
            '''variance_type''': None,
        }

        config.update(**__magic_name__      )
        return config
 def  UpperCAmelCase   (    self ,       __magic_name__=0 ,       **__magic_name__      ):

        """simple docstring"""

        A_							:       Dict	      =				dict(self.forward_default_kwargs      )
        A_							:       Union[str, Any]	      =				kwargs.pop('''num_inference_steps''' ,       __magic_name__      )
        A_							:       Tuple	      =				self.dummy_sample
        A_							:       Tuple	      =				0.1 * sample
        A_							:       Tuple	      =				[residual + 0.2, residual + 0.15, residual + 0.10]

        for scheduler_class in self.scheduler_classes:
               A_							:       Optional[Any]	      =				self.get_scheduler_config(**__magic_name__      )
               A_							:       Tuple	      =				scheduler_class(**__magic_name__      )
               scheduler.set_timesteps(__magic_name__      )
               # copy over dummy past residuals
               A_							:       Any	      =				dummy_past_residuals[: scheduler.config.solver_order]

               with tempfile.TemporaryDirectory() as tmpdirname:
                      scheduler.save_config(__magic_name__      )
                      A_							:       Tuple	      =				scheduler_class.from_pretrained(__magic_name__      )
                      new_scheduler.set_timesteps(__magic_name__      )
                      # copy over dummy past residuals
                      A_							:       Dict	      =				dummy_past_residuals[: new_scheduler.config.solver_order]

               A_      ,							A_							:       Optional[Any]	      =				sample, sample
               for t in range(__magic_name__ ,       time_step + scheduler.config.solver_order + 1      ):
                      A_							:       Union[str, Any]	      =				scheduler.step(__magic_name__ ,       __magic_name__ ,       __magic_name__ ,       **__magic_name__      ).prev_sample
                      A_							:       Any	      =				new_scheduler.step(__magic_name__ ,       __magic_name__ ,       __magic_name__ ,       **__magic_name__      ).prev_sample

                      assert torch.sum(torch.abs(output - new_output      )      ) < 1e-5, "Scheduler outputs are not identical"
 def  UpperCAmelCase   (    self      ):

        """simple docstring"""

        pass
 def  UpperCAmelCase   (    self ,       __magic_name__=0 ,       **__magic_name__      ):

        """simple docstring"""

        A_							:       Union[str, Any]	      =				dict(self.forward_default_kwargs      )
        A_							:       Union[str, Any]	      =				kwargs.pop('''num_inference_steps''' ,       __magic_name__      )
        A_							:       Optional[int]	      =				self.dummy_sample
        A_							:       str	      =				0.1 * sample
        A_							:       Dict	      =				[residual + 0.2, residual + 0.15, residual + 0.10]

        for scheduler_class in self.scheduler_classes:
               A_							:       List[Any]	      =				self.get_scheduler_config()
               A_							:       int	      =				scheduler_class(**__magic_name__      )
               scheduler.set_timesteps(__magic_name__      )

               # copy over dummy past residuals (must be after setting timesteps)
               A_							:       List[Any]	      =				dummy_past_residuals[: scheduler.config.solver_order]

               with tempfile.TemporaryDirectory() as tmpdirname:
                      scheduler.save_config(__magic_name__      )
                      A_							:       Union[str, Any]	      =				scheduler_class.from_pretrained(__magic_name__      )
                      # copy over dummy past residuals
                      new_scheduler.set_timesteps(__magic_name__      )

                      # copy over dummy past residual (must be after setting timesteps)
                      A_							:       Optional[int]	      =				dummy_past_residuals[: new_scheduler.config.solver_order]

               A_							:       str	      =				scheduler.step(__magic_name__ ,       __magic_name__ ,       __magic_name__ ,       **__magic_name__      ).prev_sample
               A_							:       Union[str, Any]	      =				new_scheduler.step(__magic_name__ ,       __magic_name__ ,       __magic_name__ ,       **__magic_name__      ).prev_sample

               assert torch.sum(torch.abs(output - new_output      )      ) < 1e-5, "Scheduler outputs are not identical"
 def  UpperCAmelCase   (    self ,       __magic_name__=None ,       **__magic_name__      ):

        """simple docstring"""

        if scheduler is None:
               A_							:       Any	      =				self.scheduler_classes[0]
               A_							:       Dict	      =				self.get_scheduler_config(**__magic_name__      )
               A_							:       Any	      =				scheduler_class(**__magic_name__      )

        A_							:       List[Any]	      =				10
        A_							:       List[str]	      =				self.dummy_model()
        A_							:       Tuple	      =				self.dummy_sample_deter
        scheduler.set_timesteps(__magic_name__      )

        for i, t in enumerate(scheduler.timesteps      ):
               A_							:       Optional[int]	      =				model(__magic_name__ ,       __magic_name__      )
               A_							:       Optional[int]	      =				scheduler.step(__magic_name__ ,       __magic_name__ ,       __magic_name__      ).prev_sample

        return sample
 def  UpperCAmelCase   (    self      ):

        """simple docstring"""

        A_							:       str	      =				dict(self.forward_default_kwargs      )

        A_							:       Optional[Any]	      =				kwargs.pop('''num_inference_steps''' ,       __magic_name__      )

        for scheduler_class in self.scheduler_classes:
               A_							:       Union[str, Any]	      =				self.get_scheduler_config()
               A_							:       int	      =				scheduler_class(**__magic_name__      )

               A_							:       Tuple	      =				self.dummy_sample
               A_							:       List[Any]	      =				0.1 * sample

               if num_inference_steps is not None and hasattr(__magic_name__ ,       '''set_timesteps'''      ):
                      scheduler.set_timesteps(__magic_name__      )
               elif num_inference_steps is not None and not hasattr(__magic_name__ ,       '''set_timesteps'''      ):
                      A_							:       Optional[int]	      =				num_inference_steps

               # copy over dummy past residuals (must be done after set_timesteps)
               A_							:       List[Any]	      =				[residual + 0.2, residual + 0.15, residual + 0.10]
               A_							:       Union[str, Any]	      =				dummy_past_residuals[: scheduler.config.solver_order]

               A_							:       Optional[Any]	      =				scheduler.timesteps[5]
               A_							:       int	      =				scheduler.timesteps[6]

               A_							:       List[str]	      =				scheduler.step(__magic_name__ ,       __magic_name__ ,       __magic_name__ ,       **__magic_name__      ).prev_sample
               A_							:       str	      =				scheduler.step(__magic_name__ ,       __magic_name__ ,       __magic_name__ ,       **__magic_name__      ).prev_sample

               self.assertEqual(output_a.shape ,       sample.shape      )
               self.assertEqual(output_a.shape ,       output_a.shape      )
 def  UpperCAmelCase   (    self      ):

        """simple docstring"""

        for timesteps in [25, 50, 100, 999, 1000]:
               self.check_over_configs(num_train_timesteps=__magic_name__      )
 def  UpperCAmelCase   (    self      ):

        """simple docstring"""

        self.check_over_configs(thresholding=__magic_name__      )
        for order in [1, 2, 3]:
               for solver_type in ["midpoint", "heun"]:
                      for threshold in [0.5, 1.0, 2.0]:
                             for prediction_type in ["epsilon", "sample"]:
                                    self.check_over_configs(
                                        thresholding=__magic_name__ ,       prediction_type=__magic_name__ ,       sample_max_value=__magic_name__ ,       algorithm_type='''dpmsolver++''' ,       solver_order=__magic_name__ ,       solver_type=__magic_name__ ,       )
 def  UpperCAmelCase   (    self      ):

        """simple docstring"""

        for prediction_type in ["epsilon", "v_prediction"]:
               self.check_over_configs(prediction_type=__magic_name__      )
 def  UpperCAmelCase   (    self      ):

        """simple docstring"""

        for algorithm_type in ["dpmsolver", "dpmsolver++", "sde-dpmsolver", "sde-dpmsolver++"]:
               for solver_type in ["midpoint", "heun"]:
                      for order in [1, 2, 3]:
                             for prediction_type in ["epsilon", "sample"]:
                                    if algorithm_type in ["sde-dpmsolver", "sde-dpmsolver++"]:
                                           if order == 3:
                                                  continue
                                    else:
                                           self.check_over_configs(
                                               solver_order=__magic_name__ ,       solver_type=__magic_name__ ,       prediction_type=__magic_name__ ,       algorithm_type=__magic_name__ ,       )
                                    A_							:       int	      =				self.full_loop(
                                        solver_order=__magic_name__ ,       solver_type=__magic_name__ ,       prediction_type=__magic_name__ ,       algorithm_type=__magic_name__ ,       )
                                    assert not torch.isnan(__magic_name__      ).any(), "Samples have nan numbers"
 def  UpperCAmelCase   (    self      ):

        """simple docstring"""

        self.check_over_configs(lower_order_final=__magic_name__      )
        self.check_over_configs(lower_order_final=__magic_name__      )
 def  UpperCAmelCase   (    self      ):

        """simple docstring"""

        self.check_over_configs(lambda_min_clipped=-float('''inf'''      )      )
        self.check_over_configs(lambda_min_clipped=-5.1      )
 def  UpperCAmelCase   (    self      ):

        """simple docstring"""

        self.check_over_configs(variance_type=__magic_name__      )
        self.check_over_configs(variance_type='''learned_range'''      )
 def  UpperCAmelCase   (    self      ):

        """simple docstring"""

        for num_inference_steps in [1, 2, 3, 5, 10, 50, 100, 999, 1000]:
               self.check_over_forward(num_inference_steps=__magic_name__ ,       time_step=0      )
 def  UpperCAmelCase   (    self      ):

        """simple docstring"""

        A_							:       Optional[int]	      =				self.full_loop()
        A_							:       Tuple	      =				torch.mean(torch.abs(__magic_name__      )      )

        assert abs(result_mean.item() - 0.33_01      ) < 1e-3
 def  UpperCAmelCase   (    self      ):

        """simple docstring"""

        A_							:       Tuple	      =				self.full_loop(thresholding=__magic_name__ ,       dynamic_thresholding_ratio=0.87 ,       sample_max_value=0.5      )
        A_							:       Any	      =				torch.mean(torch.abs(__magic_name__      )      )

        assert abs(result_mean.item() - 1.13_64      ) < 1e-3
 def  UpperCAmelCase   (    self      ):

        """simple docstring"""

        A_							:       List[str]	      =				self.full_loop(prediction_type='''v_prediction'''      )
        A_							:       Union[str, Any]	      =				torch.mean(torch.abs(__magic_name__      )      )

        assert abs(result_mean.item() - 0.22_51      ) < 1e-3
 def  UpperCAmelCase   (    self      ):

        """simple docstring"""

        A_							:       List[Any]	      =				self.full_loop(prediction_type='''v_prediction''' ,       use_karras_sigmas=__magic_name__      )
        A_							:       Tuple	      =				torch.mean(torch.abs(__magic_name__      )      )

        assert abs(result_mean.item() - 0.20_96      ) < 1e-3
 def  UpperCAmelCase   (    self      ):

        """simple docstring"""

        A_							:       int	      =				DPMSolverMultistepScheduler(**self.get_scheduler_config()      )
        A_							:       List[Any]	      =				self.full_loop(scheduler=__magic_name__      )
        A_							:       str	      =				torch.mean(torch.abs(__magic_name__      )      )

        assert abs(result_mean.item() - 0.33_01      ) < 1e-3

        A_							:       List[str]	      =				DPMSolverSinglestepScheduler.from_config(scheduler.config      )
        A_							:       int	      =				UniPCMultistepScheduler.from_config(scheduler.config      )
        A_							:       Any	      =				DEISMultistepScheduler.from_config(scheduler.config      )
        A_							:       List[Any]	      =				DPMSolverMultistepScheduler.from_config(scheduler.config      )

        A_							:       str	      =				self.full_loop(scheduler=__magic_name__      )
        A_							:       int	      =				torch.mean(torch.abs(__magic_name__      )      )

        assert abs(result_mean.item() - 0.33_01      ) < 1e-3
 def  UpperCAmelCase   (    self      ):

        """simple docstring"""

        A_							:       int	      =				self.scheduler_classes[0]
        A_							:       List[str]	      =				self.get_scheduler_config(thresholding=__magic_name__ ,       dynamic_thresholding_ratio=0      )
        A_							:       str	      =				scheduler_class(**__magic_name__      )

        A_							:       Optional[Any]	      =				10
        A_							:       str	      =				self.dummy_model()
        A_							:       str	      =				self.dummy_sample_deter.half()
        scheduler.set_timesteps(__magic_name__      )

        for i, t in enumerate(scheduler.timesteps      ):
               A_							:       Optional[Any]	      =				model(__magic_name__ ,       __magic_name__      )
               A_							:       int	      =				scheduler.step(__magic_name__ ,       __magic_name__ ,       __magic_name__      ).prev_sample

        assert sample.dtype == torch.floataa
 def  UpperCAmelCase   (    self ,       **__magic_name__      ):

        """simple docstring"""

        for scheduler_class in self.scheduler_classes:
               A_							:       Optional[Any]	      =				self.get_scheduler_config(**__magic_name__      )
               A_							:       int	      =				scheduler_class(**__magic_name__      )

               scheduler.set_timesteps(scheduler.config.num_train_timesteps      )
               assert len(scheduler.timesteps.unique()      ) == scheduler.num_inference_steps



from typing import TYPE_CHECKING

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


_lowerCAmelCase        =       {
    '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:
    _lowerCAmelCase        =       [
        '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:
    _lowerCAmelCase        =       [
        '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:
    _lowerCAmelCase        =       [
        '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

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


