code: 
  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
  
  
  _snake_case			:       Dict      =						logging.get_logger(__name__)
  
  # Dynamically import the Transformers module to grab the attribute classes of the processor form their names.
  _snake_case			:       Optional[int]      =						direct_transformers_import(Path(__file__).parent)
  
  
  _snake_case			:       Tuple      =						{
      "AutoTokenizer": "PreTrainedTokenizerBase",
      "AutoFeatureExtractor": "FeatureExtractionMixin",
      "AutoImageProcessor": "ImageProcessingMixin",
  }
  
  
  
  
  
  class      UpperCamelCase_			(			__a		):
  
  
  
  
  
  
  
  						'''simple docstring'''
  
  
  
  						UpperCamelCase			:     Any							      =				['''feature_extractor''', '''tokenizer''']
  						# Names need to be attr_class for attr in attributes
  						UpperCamelCase			:     Tuple							      =				None
  						UpperCamelCase			:     List[Any]							      =				None
  						UpperCamelCase			:     Optional[int]							      =				None
  
  
  
  
  
  						def __init__( self       :Tuple		,						*lowerCAmelCase__       :str		,						**lowerCAmelCase__       :Union[str, Any]    )     ->List[str]:
  										# Sanitize args and kwargs
  										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:
  																		lowercase						    =			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():
  														lowercase						    =			getattr(self		,						F'''{attribute_name}_class'''    )
  														# Nothing is ever going to be an instance of "AutoXxx", in that case we check the base class.
  														lowercase						    =			AUTO_TO_BASE_CLASS_MAPPING.get(lowerCAmelCase__		,						lowerCAmelCase__    )
  														if isinstance(lowerCAmelCase__		,						lowerCAmelCase__    ):
  																		lowercase						    =			tuple(getattr(lowerCAmelCase__		,						lowerCAmelCase__    ) for n in class_name if n is not None    )
  														else:
  																		lowercase						    =			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       :str    )     ->Optional[int]:
  										lowercase						    =			[F'''- {name}: {repr(getattr(self		,						lowerCAmelCase__    )    )}''' for name in self.attributes]
  										lowercase						    =			"\n".join(lowerCAmelCase__    )
  										return F'''{self.__class__.__name__}:\n{attributes_repr}'''
  
  
  
  
  
  						def 					SCREAMING_SNAKE_CASE( self       :Any		,						lowerCAmelCase__       :List[Any]		,						lowerCAmelCase__       :bool = False		,						**lowerCAmelCase__       :Union[str, Any]    )     ->Optional[Any]:
  										os.makedirs(lowerCAmelCase__		,						exist_ok=lowerCAmelCase__    )
  
  										if push_to_hub:
  														lowercase						    =			kwargs.pop("commit_message"		,						lowerCAmelCase__    )
  														lowercase						    =			kwargs.pop("repo_id"		,						save_directory.split(os.path.sep    )[-1]    )
  														lowercase						    =			self._create_repo(lowerCAmelCase__		,						**lowerCAmelCase__    )
  														lowercase						    =			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:
  														lowercase						    =			[getattr(self		,						lowerCAmelCase__    ) for attribute_name in self.attributes]
  														lowercase						    =			[(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:
  														lowercase						    =			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:
  																		lowercase						    =			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       :int		,						lowerCAmelCase__       :Union[str, os.PathLike]		,						lowerCAmelCase__       :Optional[Union[str, os.PathLike]] = None		,						lowerCAmelCase__       :bool = False		,						lowerCAmelCase__       :bool = False		,						lowerCAmelCase__       :Optional[Union[str, bool]] = None		,						lowerCAmelCase__       :str = "main"		,						**lowerCAmelCase__       :int		,						)     ->Tuple:
  										lowercase						    =			cache_dir
  										lowercase						    =			force_download
  										lowercase						    =			local_files_only
  										lowercase						    =			revision
  
  										lowercase						    =			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`."    )
  														lowercase						    =			use_auth_token
  
  										if token is not None:
  														# change to `token` in a follow-up PR
  														lowercase						    =			token
  
  										lowercase						    =			cls._get_arguments_from_pretrained(lowerCAmelCase__		,						**lowerCAmelCase__    )
  										return cls(*lowerCAmelCase__    )
  
  
  
  
  
  						@classmethod
  						def 					SCREAMING_SNAKE_CASE( cls       :Any		,						lowerCAmelCase__       :int="AutoProcessor"    )     ->Tuple:
  										if not isinstance(lowerCAmelCase__		,						lowerCAmelCase__    ):
  														lowercase						    =			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.'''    )
  
  										lowercase						    =			auto_class
  
  
  
  
  
  						@classmethod
  						def 					SCREAMING_SNAKE_CASE( cls       :Tuple		,						lowerCAmelCase__       :Optional[Any]		,						**lowerCAmelCase__       :List[str]    )     ->List[Any]:
  										lowercase						    =			[]
  										for attribute_name in cls.attributes:
  														lowercase						    =			getattr(cls		,						F'''{attribute_name}_class'''    )
  														if isinstance(lowerCAmelCase__		,						lowerCAmelCase__    ):
  																		lowercase						    =			tuple(getattr(lowerCAmelCase__		,						lowerCAmelCase__    ) if n is not None else None for n in class_name    )
  																		lowercase						    =			kwargs.get("use_fast"		,						lowerCAmelCase__    )
  																		if use_fast and classes[1] is not None:
  																						lowercase						    =			classes[1]
  																		else:
  																						lowercase						    =			classes[0]
  														else:
  																		lowercase						    =			getattr(lowerCAmelCase__		,						lowerCAmelCase__    )
  
  														args.append(attribute_class.from_pretrained(lowerCAmelCase__		,						**lowerCAmelCase__    )    )
  										return args
  
  
  
  
  
  						@property
  						def 					SCREAMING_SNAKE_CASE( self       :Dict    )     ->str:
  										lowercase						    =			getattr(self		,						self.attributes[0]    )
  										return getattr(lowerCAmelCase__		,						"model_input_names"		,						lowerCAmelCase__    )
  
  
  
  
  _snake_case			:       List[Any]      =						copy_func(ProcessorMixin.push_to_hub)
  if ProcessorMixin.push_to_hub.__doc__ is not None:
  						_snake_case			:       str      =						ProcessorMixin.push_to_hub.__doc__.format(
  						    object="processor", object_class="AutoProcessor", object_files="processor files"
  						)
  
style_context: 
  from transformers import PretrainedConfig
  
  
  
  
  
  class      UpperCamelCase_			(			__a		):
  
  
  
  
  
  
  
  						'''simple docstring'''
  
  
  
  						UpperCamelCase			:     List[str]							      =				'''custom'''
  
  
  
  
  
  						def __init__( self       :Tuple		,						lowerCAmelCase__       :int=1		,						**lowerCAmelCase__       :List[Any]    )     ->int:
  										lowercase						    =			attribute
  										super().__init__(**lowerCAmelCase__    )
  
  
  
  
  
  class      UpperCamelCase_			(			__a		):
  
  
  
  
  
  
  
  						'''simple docstring'''
  
  
  
  						UpperCamelCase			:     Union[str, Any]							      =				'''custom'''
  
  
  
  
  
  						def __init__( self       :Union[str, Any]		,						lowerCAmelCase__       :Dict=1		,						**lowerCAmelCase__       :Dict    )     ->List[str]:
  										lowercase						    =			attribute
  