




from __future__ import annotations

import unittest

from transformers import AlbertConfig, is_tf_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
  import tensorflow as tf

  from transformers import TF_MODEL_FOR_PRETRAINING_MAPPING
  from transformers.models.albert.modeling_tf_albert import (
      TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
      TFAlbertForMaskedLM,
      TFAlbertForMultipleChoice,
      TFAlbertForPreTraining,
      TFAlbertForQuestionAnswering,
      TFAlbertForSequenceClassification,
      TFAlbertForTokenClassification,
      TFAlbertModel,
  )







class 						snake_case  :



   '''simple docstring'''






   def __init__(   self							:     List[str]			,						lowerCAmelCase							:     List[str]			,						lowerCAmelCase							:     Union[str, Any]=13			,						lowerCAmelCase							:     Tuple=7			,						lowerCAmelCase							:     List[Any]=True			,						lowerCAmelCase							:     str=True			,						lowerCAmelCase							:     str=True			,						lowerCAmelCase							:     Union[str, Any]=True			,						lowerCAmelCase							:     Union[str, Any]=99			,						lowerCAmelCase							:     Dict=16			,						lowerCAmelCase							:     List[Any]=32			,						lowerCAmelCase							:     Union[str, Any]=2			,						lowerCAmelCase							:     Any=4			,						lowerCAmelCase							:     str=37			,						lowerCAmelCase							:     Optional[int]="gelu"			,						lowerCAmelCase							:     List[str]=0.1			,						lowerCAmelCase							:     Union[str, Any]=0.1			,						lowerCAmelCase							:     int=512			,						lowerCAmelCase							:     str=16			,						lowerCAmelCase							:     Dict=2			,						lowerCAmelCase							:     Union[str, Any]=0.02			,						lowerCAmelCase							:     Dict=3			,						lowerCAmelCase							:     Any=4			,						lowerCAmelCase							:     Union[str, Any]=None			,						)			->			Optional[Any]:

    """simple docstring"""







    _snake_case      :					int					=   parent
    _snake_case      :					Optional[int]					=   13
    _snake_case      :					Any					=   7
    _snake_case      :					int					=   True
    _snake_case      :					Dict					=   True
    _snake_case      :					Any					=   True
    _snake_case      :					Dict					=   True
    _snake_case      :					Union[str, Any]					=   99
    _snake_case      :					List[Any]					=   16
    _snake_case      :					Union[str, Any]					=   32
    _snake_case      :					int					=   2
    _snake_case      :					str					=   4
    _snake_case      :					Tuple					=   37
    _snake_case      :					Dict					=   """gelu"""
    _snake_case      :					Optional[int]					=   0.1
    _snake_case      :					Optional[Any]					=   0.1
    _snake_case      :					Tuple					=   512
    _snake_case      :					int					=   16
    _snake_case      :					Any					=   2
    _snake_case      :					List[Any]					=   0.02
    _snake_case      :					Dict					=   3
    _snake_case      :					Tuple					=   4
    _snake_case      :					int					=   None

   def        UpperCamelCase_					(   self							:     Tuple)			->			Tuple:

    """simple docstring"""







    _snake_case      :					str					=   ids_tensor([self.batch_size, self.seq_length]			,						self.vocab_size)

    _snake_case      :					Dict					=   None
    if self.use_input_mask:
     _snake_case      :					List[Any]					=   random_attention_mask([self.batch_size, self.seq_length])

    _snake_case      :					str					=   None
    if self.use_token_type_ids:
     _snake_case      :					Optional[Any]					=   ids_tensor([self.batch_size, self.seq_length]			,						self.type_vocab_size)

    _snake_case      :					Union[str, Any]					=   None
    _snake_case      :					Any					=   None
    _snake_case      :					str					=   None
    if self.use_labels:
     _snake_case      :					int					=   ids_tensor([self.batch_size]			,						self.type_sequence_label_size)
     _snake_case      :					Tuple					=   ids_tensor([self.batch_size, self.seq_length]			,						self.num_labels)
     _snake_case      :					Any					=   ids_tensor([self.batch_size]			,						self.num_choices)

    _snake_case      :					int					=   AlbertConfig(
        vocab_size=self.vocab_size			,						hidden_size=self.hidden_size			,						embedding_size=self.embedding_size			,						num_hidden_layers=self.num_hidden_layers			,						num_attention_heads=self.num_attention_heads			,						intermediate_size=self.intermediate_size			,						hidden_act=self.hidden_act			,						hidden_dropout_prob=self.hidden_dropout_prob			,						attention_probs_dropout_prob=self.attention_probs_dropout_prob			,						max_position_embeddings=self.max_position_embeddings			,						type_vocab_size=self.type_vocab_size			,						initializer_range=self.initializer_range			,						)

    return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels

   def        UpperCamelCase_					(   self							:     Any			,						lowerCAmelCase							:     int			,						lowerCAmelCase							:     Optional[Any]			,						lowerCAmelCase							:     int			,						lowerCAmelCase							:     List[str]			,						lowerCAmelCase							:     int			,						lowerCAmelCase							:     str			,						lowerCAmelCase							:     Tuple)			->			Dict:

    """simple docstring"""







    _snake_case      :					Optional[int]					=   TFAlbertModel(config=lowerCAmelCase)
    # inputs = {'input_ids': input_ids,
    #           'attention_mask': input_mask,
    #           'token_type_ids': token_type_ids}
    # sequence_output, pooled_output = model(**inputs)
    _snake_case      :					Optional[Any]					=   {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
    _snake_case      :					List[str]					=   model(lowerCAmelCase)

    _snake_case      :					Tuple					=   [input_ids, input_mask]
    _snake_case      :					Optional[int]					=   model(lowerCAmelCase)

    _snake_case      :					List[Any]					=   model(lowerCAmelCase)

    self.parent.assertEqual(result.last_hidden_state.shape			,						(self.batch_size, self.seq_length, self.hidden_size))
    self.parent.assertEqual(result.pooler_output.shape			,						(self.batch_size, self.hidden_size))

   def        UpperCamelCase_					(   self							:     Optional[Any]			,						lowerCAmelCase							:     str			,						lowerCAmelCase							:     List[str]			,						lowerCAmelCase							:     Union[str, Any]			,						lowerCAmelCase							:     Tuple			,						lowerCAmelCase							:     Optional[Any]			,						lowerCAmelCase							:     int			,						lowerCAmelCase							:     List[str])			->			List[Any]:

    """simple docstring"""







    _snake_case      :					str					=   self.num_labels
    _snake_case      :					Dict					=   TFAlbertForPreTraining(config=lowerCAmelCase)
    _snake_case      :					str					=   {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
    _snake_case      :					int					=   model(lowerCAmelCase)
    self.parent.assertEqual(result.prediction_logits.shape			,						(self.batch_size, self.seq_length, self.vocab_size))
    self.parent.assertEqual(result.sop_logits.shape			,						(self.batch_size, self.num_labels))

   def        UpperCamelCase_					(   self							:     Union[str, Any]			,						lowerCAmelCase							:     Optional[int]			,						lowerCAmelCase							:     List[Any]			,						lowerCAmelCase							:     List[str]			,						lowerCAmelCase							:     str			,						lowerCAmelCase							:     List[Any]			,						lowerCAmelCase							:     str			,						lowerCAmelCase							:     List[str])			->			List[Any]:

    """simple docstring"""







    _snake_case      :					Optional[int]					=   TFAlbertForMaskedLM(config=lowerCAmelCase)
    _snake_case      :					Dict					=   {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
    _snake_case      :					List[Any]					=   model(lowerCAmelCase)
    self.parent.assertEqual(result.logits.shape			,						(self.batch_size, self.seq_length, self.vocab_size))

   def        UpperCamelCase_					(   self							:     Optional[Any]			,						lowerCAmelCase							:     str			,						lowerCAmelCase							:     Optional[int]			,						lowerCAmelCase							:     List[str]			,						lowerCAmelCase							:     Tuple			,						lowerCAmelCase							:     str			,						lowerCAmelCase							:     List[str]			,						lowerCAmelCase							:     Optional[int])			->			Union[str, Any]:

    """simple docstring"""







    _snake_case      :					int					=   self.num_labels
    _snake_case      :					Optional[int]					=   TFAlbertForSequenceClassification(config=lowerCAmelCase)
    _snake_case      :					Union[str, Any]					=   {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
    _snake_case      :					Optional[Any]					=   model(lowerCAmelCase)
    self.parent.assertEqual(result.logits.shape			,						(self.batch_size, self.num_labels))

   def        UpperCamelCase_					(   self							:     Union[str, Any]			,						lowerCAmelCase							:     List[Any]			,						lowerCAmelCase							:     Any			,						lowerCAmelCase							:     Optional[int]			,						lowerCAmelCase							:     Union[str, Any]			,						lowerCAmelCase							:     Dict			,						lowerCAmelCase							:     Any			,						lowerCAmelCase							:     Dict)			->			Optional[Any]:

    """simple docstring"""







    _snake_case      :					Union[str, Any]					=   TFAlbertForQuestionAnswering(config=lowerCAmelCase)
    _snake_case      :					Union[str, Any]					=   {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
    _snake_case      :					str					=   model(lowerCAmelCase)
    self.parent.assertEqual(result.start_logits.shape			,						(self.batch_size, self.seq_length))
    self.parent.assertEqual(result.end_logits.shape			,						(self.batch_size, self.seq_length))

   def        UpperCamelCase_					(   self							:     str			,						lowerCAmelCase							:     Any			,						lowerCAmelCase							:     Optional[int]			,						lowerCAmelCase							:     str			,						lowerCAmelCase							:     Dict			,						lowerCAmelCase							:     str			,						lowerCAmelCase							:     List[str]			,						lowerCAmelCase							:     Tuple)			->			Union[str, Any]:

    """simple docstring"""







    _snake_case      :					str					=   self.num_choices
    _snake_case      :					List[str]					=   TFAlbertForMultipleChoice(config=lowerCAmelCase)
    _snake_case      :					Any					=   tf.tile(tf.expand_dims(lowerCAmelCase			,						1)			,						(1, self.num_choices, 1))
    _snake_case      :					Tuple					=   tf.tile(tf.expand_dims(lowerCAmelCase			,						1)			,						(1, self.num_choices, 1))
    _snake_case      :					str					=   tf.tile(tf.expand_dims(lowerCAmelCase			,						1)			,						(1, self.num_choices, 1))
    _snake_case      :					Any					=   {
        """input_ids""": multiple_choice_inputs_ids,
        """attention_mask""": multiple_choice_input_mask,
        """token_type_ids""": multiple_choice_token_type_ids,
    }
    _snake_case      :					List[str]					=   model(lowerCAmelCase)
    self.parent.assertListEqual(list(result["""logits"""].shape)			,						[self.batch_size, self.num_choices])

   def        UpperCamelCase_					(   self							:     int			,						lowerCAmelCase							:     Any			,						lowerCAmelCase							:     Union[str, Any]			,						lowerCAmelCase							:     Union[str, Any]			,						lowerCAmelCase							:     Optional[Any]			,						lowerCAmelCase							:     str			,						lowerCAmelCase							:     Any			,						lowerCAmelCase							:     Any)			->			int:

    """simple docstring"""







    _snake_case      :					Tuple					=   self.num_labels
    _snake_case      :					Union[str, Any]					=   TFAlbertForTokenClassification(config=lowerCAmelCase)
    _snake_case      :					str					=   {
        """input_ids""": input_ids,
        """attention_mask""": input_mask,
        """token_type_ids""": token_type_ids,
    }
    _snake_case      :					Dict					=   model(lowerCAmelCase)
    self.parent.assertListEqual(list(result["""logits"""].shape)			,						[self.batch_size, self.seq_length, self.num_labels])


   def        UpperCamelCase_					(   self							:     Optional[int])			->			List[str]:

    """simple docstring"""







    _snake_case      :					Optional[Any]					=   self.prepare_config_and_inputs()
    (
        _snake_case      
    )      :					Tuple					=   config_and_inputs
    _snake_case      :					List[str]					=   {"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
    return config, inputs_dict







@require_tf
class 						snake_case  (		SCREAMING_SNAKE_CASE_   ,SCREAMING_SNAKE_CASE_   ,unittest.TestCase					):



   '''simple docstring'''






   snake_case_   :	List[Any]       =						(
       (
           TFAlbertModel,
           TFAlbertForPreTraining,
           TFAlbertForMaskedLM,
           TFAlbertForSequenceClassification,
           TFAlbertForQuestionAnswering,
           TFAlbertForTokenClassification,
           TFAlbertForMultipleChoice,
       )
       if is_tf_available()
       else ()
   )
   snake_case_   :	str       =						(
       {
           """feature-extraction""": TFAlbertModel,
           """fill-mask""": TFAlbertForMaskedLM,
           """question-answering""": TFAlbertForQuestionAnswering,
           """text-classification""": TFAlbertForSequenceClassification,
           """token-classification""": TFAlbertForTokenClassification,
           """zero-shot""": TFAlbertForSequenceClassification,
       }
       if is_tf_available()
       else {}
   )
   snake_case_   :	Dict       =						False
   snake_case_   :	Tuple       =						False

   def        UpperCamelCase_					(   self							:     List[str]			,						lowerCAmelCase							:     Optional[Any]			,						lowerCAmelCase							:     Union[str, Any]			,						lowerCAmelCase							:     int=False)			->			Optional[int]:

    """simple docstring"""







    _snake_case      :					Dict					=   super()._prepare_for_class(lowerCAmelCase			,						lowerCAmelCase			,						return_labels=lowerCAmelCase)

    if return_labels:
     if model_class in get_values(lowerCAmelCase):
      _snake_case      :					Any					=   tf.zeros(self.model_tester.batch_size			,						dtype=tf.intaa)

    return inputs_dict

   def        UpperCamelCase_					(   self							:     Any)			->			Optional[int]:

    """simple docstring"""







    _snake_case      :					Dict					=   TFAlbertModelTester(self)
    _snake_case      :					Optional[int]					=   ConfigTester(self			,						config_class=lowerCAmelCase			,						hidden_size=37)

   def        UpperCamelCase_					(   self							:     Any)			->			str:

    """simple docstring"""







    self.config_tester.run_common_tests()

   def        UpperCamelCase_					(   self							:     int)			->			int:

    """simple docstring"""







    _snake_case      :					List[Any]					=   self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_albert_model(*lowerCAmelCase)

   def        UpperCamelCase_					(   self							:     Any)			->			List[Any]:

    """simple docstring"""







    _snake_case      :					List[Any]					=   self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_albert_for_pretraining(*lowerCAmelCase)

   def        UpperCamelCase_					(   self							:     List[str])			->			Union[str, Any]:

    """simple docstring"""







    _snake_case      :					Union[str, Any]					=   self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_albert_for_masked_lm(*lowerCAmelCase)

   def        UpperCamelCase_					(   self							:     int)			->			Dict:

    """simple docstring"""







    _snake_case      :					Tuple					=   self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_albert_for_multiple_choice(*lowerCAmelCase)

   def        UpperCamelCase_					(   self							:     int)			->			List[Any]:

    """simple docstring"""







    _snake_case      :					List[str]					=   self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_albert_for_sequence_classification(*lowerCAmelCase)

   def        UpperCamelCase_					(   self							:     List[Any])			->			Optional[int]:

    """simple docstring"""







    _snake_case      :					List[Any]					=   self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_albert_for_question_answering(*lowerCAmelCase)


   @slow
   def        UpperCamelCase_					(   self							:     List[str])			->			Optional[Any]:

    """simple docstring"""







    for model_name in TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
     _snake_case      :					Optional[int]					=   TFAlbertModel.from_pretrained(lowerCAmelCase)
     self.assertIsNotNone(lowerCAmelCase)







@require_tf
class 						snake_case  (		unittest.TestCase					):



   '''simple docstring'''






   @slow
   def        UpperCamelCase_					(   self							:     Tuple)			->			Optional[Any]:

    """simple docstring"""







    _snake_case      :					Optional[Any]					=   TFAlbertForPreTraining.from_pretrained("""albert-base-v2""")
    _snake_case      :					Union[str, Any]					=   tf.constant([[0, 1, 2, 3, 4, 5]])
    _snake_case      :					List[str]					=   model(lowerCAmelCase)[0]

    _snake_case      :					Optional[int]					=   [1, 6, 3_0000]
    self.assertEqual(output.shape			,						lowerCAmelCase)

    _snake_case      :					List[Any]					=   tf.constant(
        [
            [
                [4.595_668, 0.74_462_754, -1.818_147],
                [4.5_954_347, 0.7_454_184, -1.8_188_258],
                [4.5_954_905, 0.7_448_235, -1.8_182_316],
            ]
        ])
    tf.debugging.assert_near(output[:, :3, :3]			,						lowerCAmelCase			,						atol=1E-4)





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


a__      =		logging.get_logger(__name__)

# Dynamically import the Transformers module to grab the attribute classes of the processor form their names.
a__      =		direct_transformers_import(Path(__file__).parent)


a__      =		{
    """AutoTokenizer""": """PreTrainedTokenizerBase""",
    """AutoFeatureExtractor""": """FeatureExtractionMixin""",
    """AutoImageProcessor""": """ImageProcessingMixin""",
}







class 						snake_case  (		SCREAMING_SNAKE_CASE_					):



   '''simple docstring'''






   snake_case_   :	List[str]       =						["""feature_extractor""", """tokenizer"""]
   # Names need to be attr_class for attr in attributes
   snake_case_   :	Optional[Any]       =						None
   snake_case_   :	List[str]       =						None
   snake_case_   :	List[str]       =						None

   def __init__(   self							:     int			,						*lowerCAmelCase							:     Any			,						**lowerCAmelCase							:     int)			->			Optional[Any]:

    """simple docstring"""







    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:
      _snake_case      :					List[str]					=   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():
     _snake_case      :					Optional[Any]					=   getattr(self			,						F'''{attribute_name}_class''')
     # Nothing is ever going to be an instance of "AutoXxx", in that case we check the base class.
     _snake_case      :					List[str]					=   AUTO_TO_BASE_CLASS_MAPPING.get(lowerCAmelCase			,						lowerCAmelCase)
     if isinstance(lowerCAmelCase			,						lowerCAmelCase):
      _snake_case      :					Optional[Any]					=   tuple(getattr(lowerCAmelCase			,						lowerCAmelCase) for n in class_name if n is not None)
     else:
      _snake_case      :					List[Any]					=   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							:     int)			->			Dict:

    """simple docstring"""







    _snake_case      :					Union[str, Any]					=   [F'''- {name}: {repr(getattr(self			,						lowerCAmelCase))}''' for name in self.attributes]
    _snake_case      :					str					=   """\n""".join(lowerCAmelCase)
    return F'''{self.__class__.__name__}:\n{attributes_repr}'''

   def        UpperCamelCase_					(   self							:     Optional[int]			,						lowerCAmelCase							:     Optional[int]			,						lowerCAmelCase							:     bool = False			,						**lowerCAmelCase							:     Union[str, Any])			->			Dict:

    """simple docstring"""







    os.makedirs(lowerCAmelCase			,						exist_ok=lowerCAmelCase)

    if push_to_hub:
     _snake_case      :					str					=   kwargs.pop("""commit_message"""			,						lowerCAmelCase)
     _snake_case      :					Union[str, Any]					=   kwargs.pop("""repo_id"""			,						save_directory.split(os.path.sep)[-1])
     _snake_case      :					Tuple					=   self._create_repo(lowerCAmelCase			,						**lowerCAmelCase)
     _snake_case      :					Any					=   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:
     _snake_case      :					Any					=   [getattr(self			,						lowerCAmelCase) for attribute_name in self.attributes]
     _snake_case      :					Any					=   [(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:
     _snake_case      :					Optional[int]					=   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:
      _snake_case      :					List[str]					=   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        UpperCamelCase_					(   cls							:     List[Any]			,						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							:     Dict			,						)			->			Tuple:

    """simple docstring"""







    _snake_case      :					Dict					=   cache_dir
    _snake_case      :					Optional[Any]					=   force_download
    _snake_case      :					Dict					=   local_files_only
    _snake_case      :					Any					=   revision

    _snake_case      :					Dict					=   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`.""")
     _snake_case      :					str					=   use_auth_token

    if token is not None:
     # change to `token` in a follow-up PR
     _snake_case      :					Tuple					=   token

    _snake_case      :					Tuple					=   cls._get_arguments_from_pretrained(lowerCAmelCase			,						**lowerCAmelCase)
    return cls(*lowerCAmelCase)

   @classmethod
   def        UpperCamelCase_					(   cls							:     Optional[Any]			,						lowerCAmelCase							:     str="AutoProcessor")			->			int:

    """simple docstring"""







    if not isinstance(lowerCAmelCase			,						lowerCAmelCase):
     _snake_case      :					List[Any]					=   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.''')

    _snake_case      :					List[str]					=   auto_class

   @classmethod
   def        UpperCamelCase_					(   cls							:     List[Any]			,						lowerCAmelCase							:     Any			,						**lowerCAmelCase							:     Union[str, Any])			->			Optional[Any]:

    """simple docstring"""







    _snake_case      :					Optional[Any]					=   []
    for attribute_name in cls.attributes:
     _snake_case      :					Optional[Any]					=   getattr(cls			,						F'''{attribute_name}_class''')
     if isinstance(lowerCAmelCase			,						lowerCAmelCase):
      _snake_case      :					Tuple					=   tuple(getattr(lowerCAmelCase			,						lowerCAmelCase) if n is not None else None for n in class_name)
      _snake_case      :					str					=   kwargs.get("""use_fast"""			,						lowerCAmelCase)
      if use_fast and classes[1] is not None:
       _snake_case      :					Any					=   classes[1]
      else:
       _snake_case      :					Union[str, Any]					=   classes[0]
     else:
      _snake_case      :					Optional[Any]					=   getattr(lowerCAmelCase			,						lowerCAmelCase)

     args.append(attribute_class.from_pretrained(lowerCAmelCase			,						**lowerCAmelCase))
    return args


   @property
   def        UpperCamelCase_					(   self							:     Optional[int])			->			str:

    """simple docstring"""







    _snake_case      :					Tuple					=   getattr(self			,						self.attributes[0])
    return getattr(lowerCAmelCase			,						"""model_input_names"""			,						lowerCAmelCase)
a__      =		copy_func(ProcessorMixin.push_to_hub)
if ProcessorMixin.push_to_hub.__doc__ is not None:
  a__      =		ProcessorMixin.push_to_hub.__doc__.format(
      object="""processor""", object_class="""AutoProcessor""", object_files="""processor files"""
  )
