code: 
  
  
  """simple docstring"""
  
  
  
  
  import os
  import warnings
  from pathlib import Path
  from typing import Optional, Union
  
  from .dynamic_module_utils import custom_object_save
  from .tokenization_utils_base import PreTrainedTokenizerBase
  from .utils import PushToHubMixin, copy_func, direct_transformers_import, logging
  
  
  __SCREAMING_SNAKE_CASE					=						logging.get_logger(__name__)
  
  # Dynamically import the Transformers module to grab the attribute classes of the processor form their names.
  __SCREAMING_SNAKE_CASE					=						direct_transformers_import(Path(__file__).parent)
  
  
  __SCREAMING_SNAKE_CASE					=						{
      """AutoTokenizer""": """PreTrainedTokenizerBase""",
      """AutoFeatureExtractor""": """FeatureExtractionMixin""",
      """AutoImageProcessor""": """ImageProcessingMixin""",
  }
  
  
  
  
  
  class __snake_case		(					__UpperCAmelCase      ):
  
  
  
  
  
  
  
  			"""simple docstring"""
  
  
  
  
  			lowerCAmelCase_				:   Optional[int]     	=			["""feature_extractor""", """tokenizer"""]
  			# Names need to be attr_class for attr in attributes
  			lowerCAmelCase_				:   Optional[Any]     	=			None
  			lowerCAmelCase_				:   str     	=			None
  			lowerCAmelCase_				:   Dict     	=			None
  
  
  
  
  			def __init__(		self							:int				,  *UpperCamelCase__							:List[Any]				,  **UpperCamelCase__							:Any       ):
  
  
  
  										for key in kwargs:
  																	if key not in self.attributes:
  																								raise TypeError(f'Unexpected keyword argument {key}.'       )
  										for arg, attribute_name in zip(lowerCamelCase__				,  self.attributes       ):
  																	if attribute_name in kwargs:
  																								raise TypeError(f'Got multiple values for argument {attribute_name}.'       )
  																	else:
  																								_a          =				arg
  
  										if len(lowerCamelCase__       ) != len(self.attributes       ):
  																	raise ValueError(
  																	    f'This processor requires {len(self.attributes       )} arguments: {", ".join(self.attributes       )}. Got '
  																	    f'{len(lowerCamelCase__       )} arguments instead.'       )
  
  										# Check each arg is of the proper class (this will also catch a user initializing in the wrong order)
  										for attribute_name, arg in kwargs.items():
  																	_a          =				getattr(self				,  f'{attribute_name}_class'       )
  																	# Nothing is ever going to be an instance of "AutoXxx", in that case we check the base class.
  																	_a          =				AUTO_TO_BASE_CLASS_MAPPING.get(lowerCamelCase__				,  lowerCamelCase__       )
  																	if isinstance(lowerCamelCase__				,  lowerCamelCase__       ):
  																								_a          =				tuple(getattr(lowerCamelCase__				,  lowerCamelCase__       ) for n in class_name if n is not None       )
  																	else:
  																								_a          =				getattr(lowerCamelCase__				,  lowerCamelCase__       )
  
  																	if not isinstance(lowerCamelCase__				,  lowerCamelCase__       ):
  																								raise ValueError(
  																								    f'Received a {type(lowerCamelCase__       ).__name__} for argument {attribute_name}, but a {class_name} was expected.'       )
  
  																	setattr(self				,  lowerCamelCase__				,  lowerCamelCase__       )
  
  
  
  
  			def __repr__(		self							:Union[str, Any]       ):
  										_a          =				[f'- {name}: {repr(getattr(self				,  lowerCamelCase__       )       )}' for name in self.attributes]
  										_a          =				"\n".join(lowerCamelCase__       )
  										return f'{self.__class__.__name__}:\n{attributes_repr}'
  
  
  
  
  			def SCREAMING_SNAKE_CASE_      (		self							:List[str]				,  UpperCamelCase__							:Union[str, Any]				,  UpperCamelCase__							:Union[str, Any] = False				,  **UpperCamelCase__							:Dict       ):
  										os.makedirs(lowerCamelCase__				,  exist_ok=lowerCamelCase__       )
  
  										if push_to_hub:
  																	_a          =				kwargs.pop("commit_message"				,  lowerCamelCase__       )
  																	_a          =				kwargs.pop("repo_id"				,  save_directory.split(os.path.sep       )[-1]       )
  																	_a          =				self._create_repo(lowerCamelCase__				,  **lowerCamelCase__       )
  																	_a          =				self._get_files_timestamps(lowerCamelCase__       )
  										# If we have a custom config, we copy the file defining it in the folder and set the attributes so it can be
  										# loaded from the Hub.
  										if self._auto_class is not None:
  																	_a          =				[getattr(self				,  lowerCamelCase__       ) for attribute_name in self.attributes]
  																	_a          =				[(a.init_kwargs if isinstance(lowerCamelCase__				,  lowerCamelCase__       ) else a) for a in attrs]
  																	custom_object_save(self				,  lowerCamelCase__				,  config=lowerCamelCase__       )
  
  										for attribute_name in self.attributes:
  																	_a          =				getattr(self				,  lowerCamelCase__       )
  																	# Include the processor class in the attribute config so this processor can then be reloaded with the
  																	# `AutoProcessor` API.
  																	if hasattr(lowerCamelCase__				,  "_set_processor_class"       ):
  																								attribute._set_processor_class(self.__class__.__name__       )
  																	attribute.save_pretrained(lowerCamelCase__       )
  
  										if self._auto_class is not None:
  																	# We added an attribute to the init_kwargs of the tokenizers, which needs to be cleaned up.
  																	for attribute_name in self.attributes:
  																								_a          =				getattr(self				,  lowerCamelCase__       )
  																								if isinstance(lowerCamelCase__				,  lowerCamelCase__       ):
  																															del attribute.init_kwargs["auto_map"]
  
  										if push_to_hub:
  																	self._upload_modified_files(
  																	    lowerCamelCase__				,  lowerCamelCase__				,  lowerCamelCase__				,  commit_message=lowerCamelCase__				,  token=kwargs.get("use_auth_token"       )				,  )
  
  
  
  
  			@classmethod
  			def SCREAMING_SNAKE_CASE_      (		cls							:str				,  UpperCamelCase__							:Tuple				,  UpperCamelCase__							:str = None				,  UpperCamelCase__							:List[str] = False				,  UpperCamelCase__							:Optional[int] = False				,  UpperCamelCase__							:List[str] = None				,  UpperCamelCase__							:Dict = "main"				,  **UpperCamelCase__							:str				,  ):
  										_a          =				cache_dir
  										_a          =				force_download
  										_a          =				local_files_only
  										_a          =				revision
  
  										_a          =				kwargs.pop("use_auth_token"				,  lowerCamelCase__       )
  										if use_auth_token is not None:
  																	warnings.warn(
  																	    "The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers."				,  lowerCamelCase__       )
  																	if token is not None:
  																								raise ValueError(
  																								    "`token` and `use_auth_token` are both specified. Please set only the argument `token`."       )
  																	_a          =				use_auth_token
  
  										if token is not None:
  																	# change to `token` in a follow-up PR
  																	_a          =				token
  
  										_a          =				cls._get_arguments_from_pretrained(lowerCamelCase__				,  **lowerCamelCase__       )
  										return cls(*lowerCamelCase__       )
  
  
  
  
  			@classmethod
  			def SCREAMING_SNAKE_CASE_      (		cls							:Optional[Any]				,  UpperCamelCase__							:List[Any]="AutoProcessor"       ):
  
  
  
  										if not isinstance(lowerCamelCase__				,  lowerCamelCase__       ):
  																	_a          =				auto_class.__name__
  
  										import transformers.models.auto as auto_module
  
  										if not hasattr(lowerCamelCase__				,  lowerCamelCase__       ):
  																	raise ValueError(f'{auto_class} is not a valid auto class.'       )
  
  										_a          =				auto_class
  
  
  
  
  			@classmethod
  			def SCREAMING_SNAKE_CASE_      (		cls							:Union[str, Any]				,  UpperCamelCase__							:Union[str, Any]				,  **UpperCamelCase__							:Dict       ):
  										_a          =				[]
  										for attribute_name in cls.attributes:
  																	_a          =				getattr(cls				,  f'{attribute_name}_class'       )
  																	if isinstance(lowerCamelCase__				,  lowerCamelCase__       ):
  																								_a          =				tuple(getattr(lowerCamelCase__				,  lowerCamelCase__       ) if n is not None else None for n in class_name       )
  																								_a          =				kwargs.get("use_fast"				,  lowerCamelCase__       )
  																								if use_fast and classes[1] is not None:
  																															_a          =				classes[1]
  																								else:
  																															_a          =				classes[0]
  																	else:
  																								_a          =				getattr(lowerCamelCase__				,  lowerCamelCase__       )
  
  																	args.append(attribute_class.from_pretrained(lowerCamelCase__				,  **lowerCamelCase__       )       )
  										return args
  
  
  
  
  			@property
  			def SCREAMING_SNAKE_CASE_      (		self							:Optional[int]       ):
  										_a          =				getattr(self				,  self.attributes[0]       )
  										return getattr(lowerCamelCase__				,  "model_input_names"				,  lowerCamelCase__       )
  
  
  
  
  
  
  __SCREAMING_SNAKE_CASE					=						copy_func(ProcessorMixin.push_to_hub)
  if ProcessorMixin.push_to_hub.__doc__ is not None:
  			__SCREAMING_SNAKE_CASE					=						ProcessorMixin.push_to_hub.__doc__.format(
  			    object="""processor""", object_class="""AutoProcessor""", object_files="""processor files"""
  			)
  
style_context: 
  
  
  """simple docstring"""
  
  
  
  
  import warnings
  from contextlib import contextmanager
  
  from ...processing_utils import ProcessorMixin
  
  
  
  
  
  class __snake_case		(					_SCREAMING_SNAKE_CASE      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
  
     lowerCAmelCase_				:   str     	=			'AutoFeatureExtractor'
     lowerCAmelCase_				:   List[Any]     	=			'Speech2Text2Tokenizer'
  
  
  
  
     def __init__(		self							:int				,  UpperCamelCase__							:List[str]				,  UpperCamelCase__							:Union[str, Any]       ):
            super().__init__(UpperCamelCase__				,  UpperCamelCase__       )
            _a          =				self.feature_extractor
            _a          =				False
  
  
  
  
     def __call__(		self							:List[str]				,  *UpperCamelCase__							:List[str]				,  **UpperCamelCase__							:Dict       ):
            # For backward compatibility
            if self._in_target_context_manager:
                   return self.current_processor(*UpperCamelCase__				,  **UpperCamelCase__       )
  
            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"				,  UpperCamelCase__       )
            _a          =				kwargs.pop("sampling_rate"				,  UpperCamelCase__       )
            _a          =				kwargs.pop("text"				,  UpperCamelCase__       )
            if len(UpperCamelCase__       ) > 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(UpperCamelCase__				,  *UpperCamelCase__				,  sampling_rate=UpperCamelCase__				,  **UpperCamelCase__       )
            if text is not None:
                   _a          =				self.tokenizer(UpperCamelCase__				,  **UpperCamelCase__       )
  
            if text is None:
                   return inputs
            elif audio is None:
                   return encodings
            else:
                   _a          =				encodings["input_ids"]
                   return inputs
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:Union[str, Any]				,  *UpperCamelCase__							:int				,  **UpperCamelCase__							:Optional[Any]       ):
            return self.tokenizer.batch_decode(*UpperCamelCase__				,  **UpperCamelCase__       )
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:Optional[Any]				,  *UpperCamelCase__							:List[Any]				,  **UpperCamelCase__							:List[Any]       ):
            return self.tokenizer.decode(*UpperCamelCase__				,  **UpperCamelCase__       )
  
  
  
  
     @contextmanager
     def SCREAMING_SNAKE_CASE_      (		self							:Dict       ):
            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
  