
import warnings
from contextlib import contextmanager

from ....processing_utils import ProcessorMixin



class 		UpperCamelCase__  (	__lowercase   ):
   _SCREAMING_SNAKE_CASE				:							List[str]     	=				"MCTCTFeatureExtractor"
   _SCREAMING_SNAKE_CASE				:							int     	=				"AutoTokenizer"
   def __init__(self			: Any ,    snake_case_			: List[Any] ,    snake_case_			: List[Any]       ):
    super().__init__(snake_case_ ,    snake_case_       )
    __a			:  List[str]		    =  self.feature_extractor
    __a			:  List[str]		    =  False
   def __call__(self			: Dict ,    *snake_case_			: Union[str, Any] ,    **snake_case_			: Tuple       ):
    # For backward compatibility
    if self._in_target_context_manager:
     return self.current_processor(*snake_case_ ,    **snake_case_       )

    if "raw_speech" in kwargs:
     warnings.warn('''Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead.'''       )
     __a			:  List[str]		    =  kwargs.pop('''raw_speech'''       )
    else:
     __a			:  Any		    =  kwargs.pop('''audio''' ,    snake_case_       )
    __a			:  List[str]		    =  kwargs.pop('''sampling_rate''' ,    snake_case_       )
    __a			:  Dict		    =  kwargs.pop('''text''' ,    snake_case_       )
    if len(snake_case_       ) > 0:
     __a			:  Optional[int]		    =  args[0]
     __a			:  Optional[int]		    =  args[1:]

    if audio is None and text is None:
     raise ValueError('''You need to specify either an `audio` or `text` input to process.'''       )

    if audio is not None:
     __a			:  int		    =  self.feature_extractor(snake_case_ ,    *snake_case_ ,    sampling_rate=snake_case_ ,    **snake_case_       )
    if text is not None:
     __a			:  Union[str, Any]		    =  self.tokenizer(snake_case_ ,    **snake_case_       )

    if text is None:
     return inputs
    elif audio is None:
     return encodings
    else:
     __a			:  Optional[Any]		    =  encodings['''input_ids''']
     return inputs
   def 				lowerCAmelCase      (self			: int ,    *snake_case_			: List[str] ,    **snake_case_			: int       ):
    return self.tokenizer.batch_decode(*snake_case_ ,    **snake_case_       )
   def 				lowerCAmelCase      (self			: Union[str, Any] ,    *snake_case_			: Optional[Any] ,    **snake_case_			: int       ):
    # For backward compatibility
    if self._in_target_context_manager:
     return self.current_processor.pad(*snake_case_ ,    **snake_case_       )

    __a			:  List[Any]		    =  kwargs.pop('''input_features''' ,    snake_case_       )
    __a			:  Dict		    =  kwargs.pop('''labels''' ,    snake_case_       )
    if len(snake_case_       ) > 0:
     __a			:  str		    =  args[0]
     __a			:  List[str]		    =  args[1:]

    if input_features is not None:
     __a			:  Union[str, Any]		    =  self.feature_extractor.pad(snake_case_ ,    *snake_case_ ,    **snake_case_       )
    if labels is not None:
     __a			:  Optional[int]		    =  self.tokenizer.pad(snake_case_ ,    **snake_case_       )

    if labels is None:
     return input_features
    elif input_features is None:
     return labels
    else:
     __a			:  Dict		    =  labels['''input_ids''']
     return input_features
   def 				lowerCAmelCase      (self			: Optional[int] ,    *snake_case_			: Any ,    **snake_case_			: Tuple       ):
    return self.tokenizer.decode(*snake_case_ ,    **snake_case_       )







   @contextmanager
   def 				lowerCAmelCase      (self			: Any       ):
    warnings.warn(
        '''`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your '''
        '''labels by using the argument `text` of the regular `__call__` method (either in the same call as '''
        '''your audio inputs, or in a separate call.'''       )
    __a			:  List[Any]		    =  True
    __a			:  Optional[int]		    =  self.tokenizer
    yield
    __a			:  Dict		    =  self.feature_extractor
    __a			:  Any		    =  False







from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


lowercase__          ={
    'configuration_data2vec_audio': ['DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Data2VecAudioConfig'],
    'configuration_data2vec_text': [
        'DATA2VEC_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'Data2VecTextConfig',
        'Data2VecTextOnnxConfig',
    ],
    'configuration_data2vec_vision': [
        'DATA2VEC_VISION_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'Data2VecVisionConfig',
        'Data2VecVisionOnnxConfig',
    ],
}

try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase__          =[
          'DATA2VEC_AUDIO_PRETRAINED_MODEL_ARCHIVE_LIST',
          'Data2VecAudioForAudioFrameClassification',
          'Data2VecAudioForCTC',
          'Data2VecAudioForSequenceClassification',
          'Data2VecAudioForXVector',
          'Data2VecAudioModel',
          'Data2VecAudioPreTrainedModel',
      ]
      lowercase__          =[
          'DATA2VEC_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST',
          'Data2VecTextForCausalLM',
          'Data2VecTextForMaskedLM',
          'Data2VecTextForMultipleChoice',
          'Data2VecTextForQuestionAnswering',
          'Data2VecTextForSequenceClassification',
          'Data2VecTextForTokenClassification',
          'Data2VecTextModel',
          'Data2VecTextPreTrainedModel',
      ]
      lowercase__          =[
          'DATA2VEC_VISION_PRETRAINED_MODEL_ARCHIVE_LIST',
          'Data2VecVisionForImageClassification',
          'Data2VecVisionForMaskedImageModeling',
          'Data2VecVisionForSemanticSegmentation',
          'Data2VecVisionModel',
          'Data2VecVisionPreTrainedModel',
      ]

if is_tf_available():
      lowercase__          =[
          'TFData2VecVisionForImageClassification',
          'TFData2VecVisionForSemanticSegmentation',
          'TFData2VecVisionModel',
          'TFData2VecVisionPreTrainedModel',
      ]

if TYPE_CHECKING:
      from .configuration_dataavec_audio import DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP, DataaVecAudioConfig
      from .configuration_dataavec_text import (
          DATA2VEC_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP,
          DataaVecTextConfig,
          DataaVecTextOnnxConfig,
      )
      from .configuration_dataavec_vision import (
          DATA2VEC_VISION_PRETRAINED_CONFIG_ARCHIVE_MAP,
          DataaVecVisionConfig,
          DataaVecVisionOnnxConfig,
      )

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_dataavec_audio import (
                DATA2VEC_AUDIO_PRETRAINED_MODEL_ARCHIVE_LIST,
                DataaVecAudioForAudioFrameClassification,
                DataaVecAudioForCTC,
                DataaVecAudioForSequenceClassification,
                DataaVecAudioForXVector,
                DataaVecAudioModel,
                DataaVecAudioPreTrainedModel,
            )
            from .modeling_dataavec_text import (
                DATA2VEC_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST,
                DataaVecTextForCausalLM,
                DataaVecTextForMaskedLM,
                DataaVecTextForMultipleChoice,
                DataaVecTextForQuestionAnswering,
                DataaVecTextForSequenceClassification,
                DataaVecTextForTokenClassification,
                DataaVecTextModel,
                DataaVecTextPreTrainedModel,
            )
            from .modeling_dataavec_vision import (
                DATA2VEC_VISION_PRETRAINED_MODEL_ARCHIVE_LIST,
                DataaVecVisionForImageClassification,
                DataaVecVisionForMaskedImageModeling,
                DataaVecVisionForSemanticSegmentation,
                DataaVecVisionModel,
                DataaVecVisionPreTrainedModel,
            )
      if is_tf_available():
            from .modeling_tf_dataavec_vision import (
                TFDataaVecVisionForImageClassification,
                TFDataaVecVisionForSemanticSegmentation,
                TFDataaVecVisionModel,
                TFDataaVecVisionPreTrainedModel,
            )

else:
      import sys

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