'''simple docstring'''




import warnings
from contextlib import contextmanager

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





class 							SCREAMING_SNAKE_CASE (					__a			):
  """simple docstring"""







  __A  =		"""Wav2Vec2FeatureExtractor"""
  __A  =		"""AutoTokenizer"""



  def __init__(	self :       Tuple       ,       __lowerCAmelCase :       Tuple       ,       __lowerCAmelCase :       List[Any]       ):


        """simple docstring"""



        super().__init__(__lowerCAmelCase       ,       __lowerCAmelCase       )
        _lowerCAmelCase		 = self.feature_extractor
        _lowerCAmelCase		 = False



  @classmethod
  def 	a (	cls :       Dict       ,       __lowerCAmelCase :       Dict       ,       **__lowerCAmelCase :       Union[str, Any]       ):


        """simple docstring"""



        try:
              return super().from_pretrained(__lowerCAmelCase       ,       **__lowerCAmelCase       )
        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: '       ,       __lowerCAmelCase       ,       )

              _lowerCAmelCase		 = WavaVecaFeatureExtractor.from_pretrained(__lowerCAmelCase       ,       **__lowerCAmelCase       )
              _lowerCAmelCase		 = WavaVecaCTCTokenizer.from_pretrained(__lowerCAmelCase       ,       **__lowerCAmelCase       )

              return cls(feature_extractor=__lowerCAmelCase       ,       tokenizer=__lowerCAmelCase       )



  def __call__(	self :       Optional[Any]       ,       *__lowerCAmelCase :       Union[str, Any]       ,       **__lowerCAmelCase :       Dict       ):


        """simple docstring"""



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

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

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



  def 	a (	self :       Optional[Any]       ,       *__lowerCAmelCase :       Optional[Any]       ,       **__lowerCAmelCase :       Dict       ):


        """simple docstring"""



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

        _lowerCAmelCase		 = kwargs.pop('input_features'       ,       __lowerCAmelCase       )
        _lowerCAmelCase		 = kwargs.pop('labels'       ,       __lowerCAmelCase       )
        if len(__lowerCAmelCase       ) > 0:
              _lowerCAmelCase		 = args[0]
              _lowerCAmelCase		 = args[1:]

        if input_features is not None:
              _lowerCAmelCase		 = self.feature_extractor.pad(__lowerCAmelCase       ,       *__lowerCAmelCase       ,       **__lowerCAmelCase       )
        if labels is not None:
              _lowerCAmelCase		 = self.tokenizer.pad(__lowerCAmelCase       ,       **__lowerCAmelCase       )

        if labels is None:
              return input_features
        elif input_features is None:
              return labels
        else:
              _lowerCAmelCase		 = labels['input_ids']
              return input_features



  def 	a (	self :       Optional[int]       ,       *__lowerCAmelCase :       Any       ,       **__lowerCAmelCase :       List[str]       ):


        """simple docstring"""



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



  def 	a (	self :       List[Any]       ,       *__lowerCAmelCase :       Dict       ,       **__lowerCAmelCase :       Any       ):


        """simple docstring"""



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



  @contextmanager
  def 	a (	self :       List[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		 = True
        _lowerCAmelCase		 = self.tokenizer
        yield
        _lowerCAmelCase		 = self.feature_extractor
        _lowerCAmelCase		 = False













"""simple docstring"""


from typing import TYPE_CHECKING

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


__SCREAMING_SNAKE_CASE   =   {
    'configuration_transfo_xl': ['TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TransfoXLConfig'],
    'tokenization_transfo_xl': ['TransfoXLCorpus', 'TransfoXLTokenizer'],
}

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__SCREAMING_SNAKE_CASE   =   [
		    'TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_LIST',
		    'AdaptiveEmbedding',
		    'TransfoXLForSequenceClassification',
		    'TransfoXLLMHeadModel',
		    'TransfoXLModel',
		    'TransfoXLPreTrainedModel',
		    'load_tf_weights_in_transfo_xl',
		]

try:
		if not is_tf_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__SCREAMING_SNAKE_CASE   =   [
		    'TF_TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_LIST',
		    'TFAdaptiveEmbedding',
		    'TFTransfoXLForSequenceClassification',
		    'TFTransfoXLLMHeadModel',
		    'TFTransfoXLMainLayer',
		    'TFTransfoXLModel',
		    'TFTransfoXLPreTrainedModel',
		]


if TYPE_CHECKING:
		from .configuration_transfo_xl import TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP, TransfoXLConfig
		from .tokenization_transfo_xl import TransfoXLCorpus, TransfoXLTokenizer

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_transfo_xl import (
				    TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_LIST,
				    AdaptiveEmbedding,
				    TransfoXLForSequenceClassification,
				    TransfoXLLMHeadModel,
				    TransfoXLModel,
				    TransfoXLPreTrainedModel,
				    load_tf_weights_in_transfo_xl,
				)

		try:
				if not is_tf_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_tf_transfo_xl import (
				    TF_TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_LIST,
				    TFAdaptiveEmbedding,
				    TFTransfoXLForSequenceClassification,
				    TFTransfoXLLMHeadModel,
				    TFTransfoXLMainLayer,
				    TFTransfoXLModel,
				    TFTransfoXLPreTrainedModel,
				)

else:
		import sys

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