


import warnings
from contextlib import contextmanager

from ....processing_utils import ProcessorMixin
class 				SCREAMING_SNAKE_CASE__						(       lowercase__    ):
      snake_case__       :  Optional[Any]       =		'''MCTCTFeatureExtractor'''
      snake_case__       :  List[Any]       =		'''AutoTokenizer'''
      def __init__( self       : Dict  ,							SCREAMING_SNAKE_CASE__       : Optional[Any]  ,							SCREAMING_SNAKE_CASE__       : Any  )	->    Dict:
             super().__init__(SCREAMING_SNAKE_CASE__  ,							SCREAMING_SNAKE_CASE__  )
             a_      :	List[str]							=						self.feature_extractor
             a_      :	str							=						False
      def __call__( self       : int  ,							*SCREAMING_SNAKE_CASE__       : Tuple  ,							**SCREAMING_SNAKE_CASE__       : Tuple  )	->    Optional[int]:
             # For backward compatibility
             if self._in_target_context_manager:
                    return self.current_processor(*SCREAMING_SNAKE_CASE__  ,							**SCREAMING_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'  ,							SCREAMING_SNAKE_CASE__  )
             a_      :	List[Any]							=						kwargs.pop('sampling_rate'  ,							SCREAMING_SNAKE_CASE__  )
             a_      :	str							=						kwargs.pop('text'  ,							SCREAMING_SNAKE_CASE__  )
             if len(SCREAMING_SNAKE_CASE__  ) > 0:
                    a_      :	Optional[Any]							=						args[0]
                    a_      :	Optional[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:
                    a_      :	Tuple							=						self.feature_extractor(SCREAMING_SNAKE_CASE__  ,							*SCREAMING_SNAKE_CASE__  ,							sampling_rate=SCREAMING_SNAKE_CASE__  ,							**SCREAMING_SNAKE_CASE__  )
             if text is not None:
                    a_      :	List[Any]							=						self.tokenizer(SCREAMING_SNAKE_CASE__  ,							**SCREAMING_SNAKE_CASE__  )

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

             a_      :	Union[str, Any]							=						kwargs.pop('input_features'  ,							SCREAMING_SNAKE_CASE__  )
             a_      :	List[Any]							=						kwargs.pop('labels'  ,							SCREAMING_SNAKE_CASE__  )
             if len(SCREAMING_SNAKE_CASE__  ) > 0:
                    a_      :	int							=						args[0]
                    a_      :	Union[str, Any]							=						args[1:]

             if input_features is not None:
                    a_      :	Tuple							=						self.feature_extractor.pad(SCREAMING_SNAKE_CASE__  ,							*SCREAMING_SNAKE_CASE__  ,							**SCREAMING_SNAKE_CASE__  )
             if labels is not None:
                    a_      :	int							=						self.tokenizer.pad(SCREAMING_SNAKE_CASE__  ,							**SCREAMING_SNAKE_CASE__  )

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

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






UpperCAmelCase_   :				Optional[int]						      = '\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n'

UpperCAmelCase_   :				List[str]						      = [{'type': 'code', 'content': INSTALL_CONTENT}]
UpperCAmelCase_   :				int						      = {
    '{processor_class}': 'FakeProcessorClass',
    '{model_class}': 'FakeModelClass',
    '{object_class}': 'FakeObjectClass',
}


