import warnings
from contextlib import contextmanager

from ....processing_utils import ProcessorMixin






class 		_lowerCamelCase		( UpperCamelCase_     ):
    __a						=   "MCTCTFeatureExtractor"
    __a						=   "AutoTokenizer"
    def __init__(	self			,			lowerCAmelCase			,			lowerCAmelCase )							->       Tuple:
     super().__init__(lowerCAmelCase			,			lowerCAmelCase )
     SCREAMING_SNAKE_CASE__: List[Any]=   self.feature_extractor
     SCREAMING_SNAKE_CASE__: Optional[int]=   False
    def __call__(	self			,			*lowerCAmelCase			,			**lowerCAmelCase )							->       List[str]:
     # For backward compatibility
     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.''' )
      SCREAMING_SNAKE_CASE__: str=   kwargs.pop('''raw_speech''' )
     else:
      SCREAMING_SNAKE_CASE__: str=   kwargs.pop('''audio'''			,			lowerCAmelCase )
     SCREAMING_SNAKE_CASE__: Any=   kwargs.pop('''sampling_rate'''			,			lowerCAmelCase )
     SCREAMING_SNAKE_CASE__: Union[str, Any]=   kwargs.pop('''text'''			,			lowerCAmelCase )
     if len(lowerCAmelCase ) > 0:
      SCREAMING_SNAKE_CASE__: Dict=   args[0]
      SCREAMING_SNAKE_CASE__: 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:
      SCREAMING_SNAKE_CASE__: Dict=   self.feature_extractor(lowerCAmelCase			,			*lowerCAmelCase			,			sampling_rate=lowerCAmelCase			,			**lowerCAmelCase )
     if text is not None:
      SCREAMING_SNAKE_CASE__: Tuple=   self.tokenizer(lowerCAmelCase			,			**lowerCAmelCase )

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

     SCREAMING_SNAKE_CASE__: Optional[int]=   kwargs.pop('''input_features'''			,			lowerCAmelCase )
     SCREAMING_SNAKE_CASE__: str=   kwargs.pop('''labels'''			,			lowerCAmelCase )
     if len(lowerCAmelCase ) > 0:
      SCREAMING_SNAKE_CASE__: Optional[int]=   args[0]
      SCREAMING_SNAKE_CASE__: Optional[int]=   args[1:]

     if input_features is not None:
      SCREAMING_SNAKE_CASE__: int=   self.feature_extractor.pad(lowerCAmelCase			,			*lowerCAmelCase			,			**lowerCAmelCase )
     if labels is not None:
      SCREAMING_SNAKE_CASE__: List[Any]=   self.tokenizer.pad(lowerCAmelCase			,			**lowerCAmelCase )

     if labels is None:
      return input_features
     elif input_features is None:
      return labels
     else:
      SCREAMING_SNAKE_CASE__: Tuple=   labels['''input_ids''']
      return input_features
    def     UpperCamelCase_					(	self			,			*lowerCAmelCase			,			**lowerCAmelCase )							->       int:
     return self.tokenizer.decode(*lowerCAmelCase			,			**lowerCAmelCase )



    @contextmanager
    def     UpperCamelCase_					(	self )							->       str:
     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.''' )
     SCREAMING_SNAKE_CASE__: Union[str, Any]=   True
     SCREAMING_SNAKE_CASE__: List[Any]=   self.tokenizer
     yield
     SCREAMING_SNAKE_CASE__: Optional[Any]=   self.feature_extractor
     SCREAMING_SNAKE_CASE__: List[str]=   False





from typing import TYPE_CHECKING

# rely on isort to merge the imports
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


__snake_case   							=						{
    '''configuration_autoformer''': [
        '''AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''AutoformerConfig''',
    ],
}

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    __snake_case   							=						[
        '''AUTOFORMER_PRETRAINED_MODEL_ARCHIVE_LIST''',
        '''AutoformerForPrediction''',
        '''AutoformerModel''',
        '''AutoformerPreTrainedModel''',
    ]


if TYPE_CHECKING:
    from .configuration_autoformer import (
        AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
        AutoformerConfig,
    )

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_autoformer import (
            AUTOFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
            AutoformerForPrediction,
            AutoformerModel,
            AutoformerPreTrainedModel,
        )

else:
    import sys

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


