


import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin
from .feature_extraction_wavaveca import WavaVecaFeatureExtractor
from .tokenization_wavaveca import WavaVecaCTCTokenizer




class A  (   UpperCamelCase_     ):
      UpperCamelCase__							:  Tuple      ='Wav2Vec2FeatureExtractor'
      UpperCamelCase__							:  Any      ='AutoTokenizer'






      def __init__(					self						:     Tuple			,   lowercase_						:     List[str]			,   lowercase_						:     Union[str, Any] )					->						List[str]:
             """simple docstring"""




             super().__init__(lowercase_			,   lowercase_ )
             _lowerCamelCase       :		Union[str, Any]		=self.feature_extractor
             _lowerCamelCase       :		List[str]		=False






      @classmethod
      def        lowerCamelCase       (					cls						:     List[Any]			,   lowercase_						:     int			,   **lowercase_						:     List[str] )					->						Dict:
             """simple docstring"""




             try:
                    return super().from_pretrained(lowercase_			,   **lowercase_ )
             except OSError:
                    warnings.warn(
                        F'''Loading a tokenizer inside {cls.__name__} from a config that does not'''
                        ' include a `tokenizer_class` attribute is deprecated and will be '
                        'removed in v5. Please add `\'tokenizer_class\': \'Wav2Vec2CTCTokenizer\'`'
                        ' attribute to either your `config.json` or `tokenizer_config.json` '
                        'file to suppress this warning: '			,   lowercase_			,   )

                    _lowerCamelCase       :		Optional[int]		=WavaVecaFeatureExtractor.from_pretrained(lowercase_			,   **lowercase_ )
                    _lowerCamelCase       :		str		=WavaVecaCTCTokenizer.from_pretrained(lowercase_			,   **lowercase_ )

                    return cls(feature_extractor=lowercase_			,   tokenizer=lowercase_ )






      def __call__(					self						:     Optional[int]			,   *lowercase_						:     List[str]			,   **lowercase_						:     List[str] )					->						Optional[int]:
             """simple docstring"""




             if self._in_target_context_manager:
                    return self.current_processor(*lowercase_			,   **lowercase_ )

             if "raw_speech" in kwargs:
                    warnings.warn('Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead.' )
                    _lowerCamelCase       :		Any		=kwargs.pop('raw_speech' )
             else:
                    _lowerCamelCase       :		str		=kwargs.pop('audio'			,   lowercase_ )
             _lowerCamelCase       :		Optional[int]		=kwargs.pop('sampling_rate'			,   lowercase_ )
             _lowerCamelCase       :		Tuple		=kwargs.pop('text'			,   lowercase_ )
             if len(lowercase_ ) > 0:
                    _lowerCamelCase       :		Dict		=args[0]
                    _lowerCamelCase       :		List[Any]		=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:
                    _lowerCamelCase       :		Any		=self.feature_extractor(lowercase_			,   *lowercase_			,   sampling_rate=lowercase_			,   **lowercase_ )
             if text is not None:
                    _lowerCamelCase       :		List[str]		=self.tokenizer(lowercase_			,   **lowercase_ )

             if text is None:
                    return inputs
             elif audio is None:
                    return encodings
             else:
                    _lowerCamelCase       :		int		=encodings['input_ids']
                    return inputs






      def        lowerCamelCase       (					self						:     Any			,   *lowercase_						:     int			,   **lowercase_						:     Optional[Any] )					->						Optional[Any]:
             """simple docstring"""




             if self._in_target_context_manager:
                    return self.current_processor.pad(*lowercase_			,   **lowercase_ )

             _lowerCamelCase       :		Optional[int]		=kwargs.pop('input_features'			,   lowercase_ )
             _lowerCamelCase       :		str		=kwargs.pop('labels'			,   lowercase_ )
             if len(lowercase_ ) > 0:
                    _lowerCamelCase       :		List[Any]		=args[0]
                    _lowerCamelCase       :		List[Any]		=args[1:]

             if input_features is not None:
                    _lowerCamelCase       :		str		=self.feature_extractor.pad(lowercase_			,   *lowercase_			,   **lowercase_ )
             if labels is not None:
                    _lowerCamelCase       :		int		=self.tokenizer.pad(lowercase_			,   **lowercase_ )

             if labels is None:
                    return input_features
             elif input_features is None:
                    return labels
             else:
                    _lowerCamelCase       :		List[str]		=labels['input_ids']
                    return input_features






      def        lowerCamelCase       (					self						:     int			,   *lowercase_						:     Tuple			,   **lowercase_						:     Dict )					->						Any:
             """simple docstring"""




             return self.tokenizer.batch_decode(*lowercase_			,   **lowercase_ )






      def        lowerCamelCase       (					self						:     Tuple			,   *lowercase_						:     Any			,   **lowercase_						:     Union[str, Any] )					->						Dict:
             """simple docstring"""




             return self.tokenizer.decode(*lowercase_			,   **lowercase_ )






      @contextmanager
      def        lowerCamelCase       (					self						:     str )					->						Any:
             """simple docstring"""




             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.' )
             _lowerCamelCase       :		int		=True
             _lowerCamelCase       :		Tuple		=self.tokenizer
             yield
             _lowerCamelCase       :		Union[str, Any]		=self.feature_extractor
             _lowerCamelCase       :		Union[str, Any]		=False






from typing import TYPE_CHECKING

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


if is_sentencepiece_available():
 from ..ta.tokenization_ta import TaTokenizer
else:
 from ...utils.dummy_sentencepiece_objects import TaTokenizer

lowerCamelCase											=       TaTokenizer

if is_tokenizers_available():
 from ..ta.tokenization_ta_fast import TaTokenizerFast
else:
 from ...utils.dummy_tokenizers_objects import TaTokenizerFast

lowerCamelCase											=       TaTokenizerFast

lowerCamelCase											=       {'configuration_mt5': ['MT5Config', 'MT5OnnxConfig']}

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase											=       [
     'MT5EncoderModel',
     'MT5ForConditionalGeneration',
     'MT5ForQuestionAnswering',
     'MT5Model',
     'MT5PreTrainedModel',
     'MT5Stack',
 ]

try:
 if not is_tf_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase											=       ['TFMT5EncoderModel', 'TFMT5ForConditionalGeneration', 'TFMT5Model']

try:
 if not is_flax_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase											=       ['FlaxMT5EncoderModel', 'FlaxMT5ForConditionalGeneration', 'FlaxMT5Model']


if TYPE_CHECKING:
 from .configuration_mta import MTaConfig, MTaOnnxConfig

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_mta import (
      MTaEncoderModel,
      MTaForConditionalGeneration,
      MTaForQuestionAnswering,
      MTaModel,
      MTaPreTrainedModel,
      MTaStack,
  )

 try:
  if not is_tf_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_tf_mta import TFMTaEncoderModel, TFMTaForConditionalGeneration, TFMTaModel

 try:
  if not is_flax_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_flax_mta import FlaxMTaEncoderModel, FlaxMTaForConditionalGeneration, FlaxMTaModel

else:
 import sys

 lowerCamelCase											=       _LazyModule(
     __name__,
     globals()['__file__'],
     _import_structure,
     extra_objects={'MT5Tokenizer': MTaTokenizer, 'MT5TokenizerFast': MTaTokenizerFast},
     module_spec=__spec__,
 )


