




"""simple docstring"""



import warnings
from contextlib import contextmanager

from ....processing_utils import ProcessorMixin




class      UpperCAmelCase_  (						A_							):
    lowercase__						 =				'''MCTCTFeatureExtractor'''
    lowercase__						 =				'''AutoTokenizer'''




    def __init__(   self						:	int     ,			snake_case_						:	str     ,			snake_case_						:	str				)				->							Optional[int]:




     '''simple docstring'''

     super().__init__(snake_case_     ,			snake_case_				)
     A__	=    self.feature_extractor
     A__	=    False




    def __call__(   self						:	List[str]     ,			*snake_case_						:	List[str]     ,			**snake_case_						:	List[str]				)				->							Union[str, Any]:




     '''simple docstring'''

     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__	=    kwargs.pop("raw_speech"				)
     else:
      A__	=    kwargs.pop("audio"     ,			snake_case_				)
     A__	=    kwargs.pop("sampling_rate"     ,			snake_case_				)
     A__	=    kwargs.pop("text"     ,			snake_case_				)
     if len(snake_case_				) > 0:
      A__	=    args[0]
      A__	=    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__	=    self.feature_extractor(snake_case_     ,			*snake_case_     ,			sampling_rate=snake_case_     ,			**snake_case_				)
     if text is not None:
      A__	=    self.tokenizer(snake_case_     ,			**snake_case_				)

     if text is None:
      return inputs
     elif audio is None:
      return encodings
     else:
      A__	=    encodings["input_ids"]
      return inputs




    def 							__magic_name__							(   self						:	List[Any]     ,			*snake_case_						:	List[Any]     ,			**snake_case_						:	Union[str, Any]				)				->							int:




     '''simple docstring'''

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




    def 							__magic_name__							(   self						:	Tuple     ,			*snake_case_						:	str     ,			**snake_case_						:	Union[str, Any]				)				->							List[Any]:




     '''simple docstring'''

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

     A__	=    kwargs.pop("input_features"     ,			snake_case_				)
     A__	=    kwargs.pop("labels"     ,			snake_case_				)
     if len(snake_case_				) > 0:
      A__	=    args[0]
      A__	=    args[1:]

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

     if labels is None:
      return input_features
     elif input_features is None:
      return labels
     else:
      A__	=    labels["input_ids"]
      return input_features




    def 							__magic_name__							(   self						:	Dict     ,			*snake_case_						:	Union[str, Any]     ,			**snake_case_						:	List[str]				)				->							Union[str, Any]:




     '''simple docstring'''

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




    @contextmanager
    def 							__magic_name__							(   self						:	Optional[int]				)				->							Union[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."				)
     A__	=    True
     A__	=    self.tokenizer
     yield
     A__	=    self.feature_extractor
     A__	=    False











"""simple docstring"""



import baseaa







def   _SCREAMING_SNAKE_CASE       (							lowercase_						)						->		bytes:
 return baseaa.aaaencode(string.encode("utf-8"						)						)







def   _SCREAMING_SNAKE_CASE       (							lowercase_						)						->		str:
 return baseaa.aaadecode(lowercase_						).decode("utf-8"						)


if __name__ == "__main__":
      import doctest

      doctest.testmod()





