



import itertools
import random
import unittest

import numpy as np

from transformers import EncodecFeatureExtractor
from transformers.testing_utils import require_torch
from transformers.utils.import_utils import is_torch_available

from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin


if is_torch_available():
  import torch


a_								=   random.Random()





def 						a__     (						_UpperCamelCase     :	Dict	,_UpperCamelCase     :	str=1.0	,_UpperCamelCase     :	str=None	,_UpperCamelCase     :	Optional[Any]=None							):
   if rng is None:
      __lowerCamelCase  							=      global_rng

   __lowerCamelCase  							=      []
   for batch_idx in range(shape[0]							):
      values.append([]							)
      for _ in range(shape[1]							):
         values[-1].append(rng.random() * scale							)

   return values



@require_torch
class 	__lowerCAmelCase       (		unittest.TestCase				):




 def __init__(  self		,			__UpperCAmelCase		,			__UpperCAmelCase=7		,			__UpperCAmelCase=400		,			__UpperCAmelCase=2000		,			__UpperCAmelCase=1		,			__UpperCAmelCase=0.0		,			__UpperCAmelCase=24000		,			__UpperCAmelCase=True		,			):



    '''simple docstring'''
    __lowerCamelCase  							=      parent
    __lowerCamelCase  							=      batch_size
    __lowerCamelCase  							=      min_seq_length
    __lowerCamelCase  							=      max_seq_length
    __lowerCamelCase  							=      (self.max_seq_length - self.min_seq_length) // (self.batch_size - 1)
    __lowerCamelCase  							=      feature_size
    __lowerCamelCase  							=      padding_value
    __lowerCamelCase  							=      sampling_rate
    __lowerCamelCase  							=      return_attention_mask




 def     lowerCamelCase (  self			):



    '''simple docstring'''
    return {
        "feature_size": self.feature_size,
        "padding_value": self.padding_value,
        "sampling_rate": self.sampling_rate,
        "return_attention_mask": self.return_attention_mask,
    }




 def     lowerCamelCase (  self		,			__UpperCAmelCase=False		,			__UpperCAmelCase=False			):



    '''simple docstring'''
    def _flatten(__UpperCAmelCase			):
       return list(itertools.chain(*__UpperCAmelCase			)			)

    if equal_length:
       __lowerCamelCase  							=      floats_list((self.batch_size, self.max_seq_length)			)
    else:
       # make sure that inputs increase in size
       __lowerCamelCase  							=      [
           _flatten(floats_list((x, self.feature_size)			)			)
           for x in range(self.min_seq_length		,			self.max_seq_length		,			self.seq_length_diff			)
       ]

    if numpify:
       __lowerCamelCase  							=      [np.asarray(__UpperCAmelCase			) for x in audio_inputs]

    return audio_inputs



@require_torch
class 	__lowerCAmelCase       (		lowerCAmelCase__					,		unittest.TestCase				):
 lowerCAmelCase__       =					EncodecFeatureExtractor




 def     lowerCamelCase (  self			):



    '''simple docstring'''
    __lowerCamelCase  							=      EnCodecFeatureExtractionTester(self			)




 def     lowerCamelCase (  self			):



    '''simple docstring'''
    # Tests that all call wrap to encode_plus and batch_encode_plus
    __lowerCamelCase  							=      self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()			)
    # create three inputs of length 800, 1000, and 1200
    __lowerCamelCase  							=      [floats_list((1, x)			)[0] for x in range(800		,			1400		,			200			)]
    __lowerCamelCase  							=      [np.asarray(__UpperCAmelCase			) for audio_input in audio_inputs]

    # Test not batched input
    __lowerCamelCase  							=      feat_extract(audio_inputs[0]		,			return_tensors='''np'''			).input_values
    __lowerCamelCase  							=      feat_extract(np_audio_inputs[0]		,			return_tensors='''np'''			).input_values
    self.assertTrue(np.allclose(__UpperCAmelCase		,			__UpperCAmelCase		,			atol=1E-3			)			)

    # Test batched
    __lowerCamelCase  							=      feat_extract(__UpperCAmelCase		,			padding=__UpperCAmelCase		,			return_tensors='''np'''			).input_values
    __lowerCamelCase  							=      feat_extract(__UpperCAmelCase		,			padding=__UpperCAmelCase		,			return_tensors='''np'''			).input_values
    for enc_seq_a, enc_seq_a in zip(__UpperCAmelCase		,			__UpperCAmelCase			):
       self.assertTrue(np.allclose(__UpperCAmelCase		,			__UpperCAmelCase		,			atol=1E-3			)			)




 def     lowerCamelCase (  self			):



    '''simple docstring'''
    __lowerCamelCase  							=      self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()			)
    __lowerCamelCase  							=      np.random.rand(100			).astype(np.floataa			)
    __lowerCamelCase  							=      np_audio_inputs.tolist()

    for inputs in [py_audio_inputs, np_audio_inputs]:
       __lowerCamelCase  							=      feature_extractor.pad([{'''input_values''': inputs}]		,			return_tensors='''np'''			)
       self.assertTrue(np_processed.input_values.dtype == np.floataa			)
       __lowerCamelCase  							=      feature_extractor.pad([{'''input_values''': inputs}]		,			return_tensors='''pt'''			)
       self.assertTrue(pt_processed.input_values.dtype == torch.floataa			)




 def     lowerCamelCase (  self		,			__UpperCAmelCase			):



    '''simple docstring'''
    from datasets import load_dataset

    __lowerCamelCase  							=      load_dataset('''hf-internal-testing/librispeech_asr_dummy'''		,			'''clean'''		,			split='''validation'''			)
    # automatic decoding with librispeech
    __lowerCamelCase  							=      ds.sort('''id'''			).select(range(__UpperCAmelCase			)			)[:num_samples]['''audio''']

    return [x["array"] for x in audio_samples]




 def     lowerCamelCase (  self			):



    '''simple docstring'''
    # fmt: off
    __lowerCamelCase  							=      torch.tensor(
        [2.3_8_0_4E-0_3, 2.0_7_5_2E-0_3, 1.9_8_3_6E-0_3, 2.1_0_5_7E-0_3, 1.6_1_7_4E-0_3,
         3.0_5_1_8E-0_4, 9.1_5_5_3E-0_5, 3.3_5_6_9E-0_4, 9.7_6_5_6E-0_4, 1.8_3_1_1E-0_3,
         2.0_1_4_2E-0_3, 2.1_0_5_7E-0_3, 1.7_3_9_5E-0_3, 4.5_7_7_6E-0_4, -3.9_6_7_3E-0_4,
         4.5_7_7_6E-0_4, 1.0_0_7_1E-0_3, 9.1_5_5_3E-0_5, 4.8_8_2_8E-0_4, 1.1_5_9_7E-0_3,
         7.3_2_4_2E-0_4, 9.4_6_0_4E-0_4, 1.8_0_0_5E-0_3, 1.8_3_1_1E-0_3, 8.8_5_0_1E-0_4,
         4.2_7_2_5E-0_4, 4.8_8_2_8E-0_4, 7.3_2_4_2E-0_4, 1.0_9_8_6E-0_3, 2.1_0_5_7E-0_3]			)
    # fmt: on
    __lowerCamelCase  							=      self._load_datasamples(1			)
    __lowerCamelCase  							=      EncodecFeatureExtractor()
    __lowerCamelCase  							=      feature_extractor(__UpperCAmelCase		,			return_tensors='''pt'''			).input_values
    self.assertEquals(input_values.shape		,			(1, 1, 93680)			)
    self.assertTrue(torch.allclose(input_values[0, 0, :30]		,			__UpperCAmelCase		,			atol=1E-6			)			)




 def     lowerCamelCase (  self			):



    '''simple docstring'''
    # fmt: off
    __lowerCamelCase  							=      torch.tensor(
        [2.3_8_0_4E-0_3, 2.0_7_5_2E-0_3, 1.9_8_3_6E-0_3, 2.1_0_5_7E-0_3, 1.6_1_7_4E-0_3,
         3.0_5_1_8E-0_4, 9.1_5_5_3E-0_5, 3.3_5_6_9E-0_4, 9.7_6_5_6E-0_4, 1.8_3_1_1E-0_3,
         2.0_1_4_2E-0_3, 2.1_0_5_7E-0_3, 1.7_3_9_5E-0_3, 4.5_7_7_6E-0_4, -3.9_6_7_3E-0_4,
         4.5_7_7_6E-0_4, 1.0_0_7_1E-0_3, 9.1_5_5_3E-0_5, 4.8_8_2_8E-0_4, 1.1_5_9_7E-0_3,
         7.3_2_4_2E-0_4, 9.4_6_0_4E-0_4, 1.8_0_0_5E-0_3, 1.8_3_1_1E-0_3, 8.8_5_0_1E-0_4,
         4.2_7_2_5E-0_4, 4.8_8_2_8E-0_4, 7.3_2_4_2E-0_4, 1.0_9_8_6E-0_3, 2.1_0_5_7E-0_3]			)
    # fmt: on
    __lowerCamelCase  							=      self._load_datasamples(1			)
    __lowerCamelCase  							=      [np.tile(input_audio[0][None]		,			reps=(2, 1)			)]
    input_audio[0][1] *= 0.5
    __lowerCamelCase  							=      EncodecFeatureExtractor(feature_size=2			)
    __lowerCamelCase  							=      feature_extractor(__UpperCAmelCase		,			return_tensors='''pt'''			).input_values
    self.assertEquals(input_values.shape		,			(1, 2, 93680)			)
    self.assertTrue(torch.allclose(input_values[0, 0, :30]		,			__UpperCAmelCase		,			atol=1E-6			)			)
    self.assertTrue(torch.allclose(input_values[0, 1, :30]		,			EXPECTED_INPUT_VALUES * 0.5		,			atol=1E-6			)			)




 def     lowerCamelCase (  self			):



    '''simple docstring'''
    __lowerCamelCase  							=      self._load_datasamples(2			)
    # would be easier if the stride was like
    __lowerCamelCase  							=      EncodecFeatureExtractor(feature_size=1		,			chunk_length_s=1		,			overlap=0.01			)

    # pad and trunc raise an error ?
    with self.assertRaisesRegex(
        __UpperCAmelCase		,			'''^Both padding and truncation were set. Make sure you only set one.$'''		,			):
       __lowerCamelCase  							=      feature_extractor(
           __UpperCAmelCase		,			padding='''max_length'''		,			truncation=__UpperCAmelCase		,			return_tensors='''pt'''			).input_values

    # truncate to chunk
    __lowerCamelCase  							=      feature_extractor(__UpperCAmelCase		,			truncation=__UpperCAmelCase		,			return_tensors='''pt'''			).input_values
    self.assertEquals(truncated_outputs.shape		,			(2, 1, 71520)			)  # 2 chunks

    # force truncate to max_length
    __lowerCamelCase  							=      feature_extractor(
        __UpperCAmelCase		,			truncation=__UpperCAmelCase		,			max_length=48000		,			return_tensors='''pt'''			).input_values
    self.assertEquals(truncated_outputs.shape		,			(2, 1, 48000)			)

    # pad to chunk
    __lowerCamelCase  							=      feature_extractor(__UpperCAmelCase		,			padding=__UpperCAmelCase		,			return_tensors='''pt'''			).input_values
    self.assertEquals(padded_outputs.shape		,			(2, 1, 95280)			)

    # pad to chunk
    __lowerCamelCase  							=      feature_extractor(__UpperCAmelCase		,			return_tensors='''pt'''			).input_values
    self.assertEquals(truncated_outputs.shape		,			(2, 1, 95280)			)

    # force pad to max length
    __lowerCamelCase  							=      feature_extractor(
        __UpperCAmelCase		,			padding='''max_length'''		,			max_length=100000		,			return_tensors='''pt'''			).input_values
    self.assertEquals(truncated_outputs.shape		,			(2, 1, 100000)			)

    # force no pad
    with self.assertRaisesRegex(
        __UpperCAmelCase		,			'''^Unable to create tensor, you should probably activate padding with \'padding=True\' to have batched tensors with the same length.$'''		,			):
       __lowerCamelCase  							=      feature_extractor(__UpperCAmelCase		,			padding=__UpperCAmelCase		,			return_tensors='''pt'''			).input_values

    __lowerCamelCase  							=      feature_extractor(input_audio[0]		,			padding=__UpperCAmelCase		,			return_tensors='''pt'''			).input_values
    self.assertEquals(truncated_outputs.shape		,			(1, 1, 93680)			)

    # no pad if no chunk_length_s
    __lowerCamelCase  							=      None
    with self.assertRaisesRegex(
        __UpperCAmelCase		,			'''^Unable to create tensor, you should probably activate padding with \'padding=True\' to have batched tensors with the same length.$'''		,			):
       __lowerCamelCase  							=      feature_extractor(__UpperCAmelCase		,			padding=__UpperCAmelCase		,			return_tensors='''pt'''			).input_values

    __lowerCamelCase  							=      feature_extractor(input_audio[0]		,			padding=__UpperCAmelCase		,			return_tensors='''pt'''			).input_values
    self.assertEquals(truncated_outputs.shape		,			(1, 1, 93680)			)

    # no pad if no overlap
    __lowerCamelCase  							=      2
    __lowerCamelCase  							=      None
    with self.assertRaisesRegex(
        __UpperCAmelCase		,			'''^Unable to create tensor, you should probably activate padding with \'padding=True\' to have batched tensors with the same length.$'''		,			):
       __lowerCamelCase  							=      feature_extractor(__UpperCAmelCase		,			padding=__UpperCAmelCase		,			return_tensors='''pt'''			).input_values

    __lowerCamelCase  							=      feature_extractor(input_audio[0]		,			padding=__UpperCAmelCase		,			return_tensors='''pt'''			).input_values
    self.assertEquals(truncated_outputs.shape		,			(1, 1, 93680)			)











from typing import TYPE_CHECKING

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


a_								=   {
    """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_								=   [
      """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_								=   [
      """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_								=   [
      """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_								=   _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)






