


import unittest

from transformers import FunnelConfig, FunnelTokenizer, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
	import torch

	from transformers import (
	    MODEL_FOR_PRETRAINING_MAPPING,
	    FunnelBaseModel,
	    FunnelForMaskedLM,
	    FunnelForMultipleChoice,
	    FunnelForPreTraining,
	    FunnelForQuestionAnswering,
	    FunnelForSequenceClassification,
	    FunnelForTokenClassification,
	    FunnelModel,
	)




class 			lowercase_				:





				def __init__(							self					,     lowercase_					,     lowercase_=13					,     lowercase_=7					,     lowercase_=True					,     lowercase_=True					,     lowercase_=True					,     lowercase_=True					,     lowercase_=99					,     lowercase_=[1, 1, 2]					,     lowercase_=1					,     lowercase_=32					,     lowercase_=4					,     lowercase_=8					,     lowercase_=37					,     lowercase_="gelu_new"					,     lowercase_=0.1					,     lowercase_=0.1					,     lowercase_=0.0					,     lowercase_=512					,     lowercase_=3					,     lowercase_=0.02					,     lowercase_=3					,     lowercase_=4					,     lowercase_=None					,     lowercase_=False					,     )     ->   Any:
											a__     						=parent
											a__     						=batch_size
											a__     						=seq_length
											a__     						=is_training
											a__     						=use_input_mask
											a__     						=use_token_type_ids
											a__     						=use_labels
											a__     						=vocab_size
											a__     						=block_sizes
											a__     						=num_decoder_layers
											a__     						=d_model
											a__     						=n_head
											a__     						=d_head
											a__     						=d_inner
											a__     						=hidden_act
											a__     						=hidden_dropout
											a__     						=attention_dropout
											a__     						=activation_dropout
											a__     						=max_position_embeddings
											a__     						=type_vocab_size
											a__     						=2
											a__     						=num_labels
											a__     						=num_choices
											a__     						=scope
											a__     						=initializer_std

											# Used in the tests to check the size of the first attention layer
											a__     						=n_head
											# Used in the tests to check the size of the first hidden state
											a__     						=self.d_model
											# Used in the tests to check the number of output hidden states/attentions
											a__     						=sum(self.block_sizes) + (0 if base else self.num_decoder_layers)
											# FunnelModel adds two hidden layers: input embeddings and the sum of the upsampled encoder hidden state with
											# the last hidden state of the first block (which is the first hidden state of the decoder).
											if not base:
																		a__     						=self.num_hidden_layers + 2





				def 	__UpperCamelCase						(							self)     ->   Tuple:
											a__     						=ids_tensor([self.batch_size, self.seq_length]					,     self.vocab_size)

											a__     						=None
											if self.use_input_mask:
																		a__     						=ids_tensor([self.batch_size, self.seq_length]					,     vocab_size=2)

											a__     						=None
											if self.use_token_type_ids:
																		a__     						=ids_tensor([self.batch_size, self.seq_length]					,     self.type_vocab_size)

											a__     						=None
											a__     						=None
											a__     						=None
											if self.use_labels:
																		a__     						=ids_tensor([self.batch_size]					,     self.type_sequence_label_size)
																		a__     						=ids_tensor([self.batch_size, self.seq_length]					,     self.num_labels)
																		a__     						=ids_tensor([self.batch_size]					,     self.num_choices)
																		a__     						=ids_tensor([self.batch_size, self.seq_length]					,     1)

											a__     						=self.get_config()

											return (
											    config,
											    input_ids,
											    token_type_ids,
											    input_mask,
											    sequence_labels,
											    token_labels,
											    choice_labels,
											    fake_token_labels,
											)





				def 	__UpperCamelCase						(							self)     ->   Any:
											return FunnelConfig(
											    vocab_size=self.vocab_size					,     block_sizes=self.block_sizes					,     num_decoder_layers=self.num_decoder_layers					,     d_model=self.d_model					,     n_head=self.n_head					,     d_head=self.d_head					,     d_inner=self.d_inner					,     hidden_act=self.hidden_act					,     hidden_dropout=self.hidden_dropout					,     attention_dropout=self.attention_dropout					,     activation_dropout=self.activation_dropout					,     max_position_embeddings=self.max_position_embeddings					,     type_vocab_size=self.type_vocab_size					,     initializer_std=self.initializer_std					,     )





				def 	__UpperCamelCase						(							self					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     )     ->   Any:
											a__     						=FunnelModel(config=lowercase_)
											model.to(lowercase_)
											model.eval()
											a__     						=model(lowercase_					,     attention_mask=lowercase_					,     token_type_ids=lowercase_)
											a__     						=model(lowercase_					,     token_type_ids=lowercase_)
											a__     						=model(lowercase_)
											self.parent.assertEqual(result.last_hidden_state.shape					,     (self.batch_size, self.seq_length, self.d_model))

											a__     						=False
											a__     						=model(lowercase_)
											self.parent.assertEqual(result.last_hidden_state.shape					,     (self.batch_size, self.seq_length, self.d_model))

											a__     						=False
											a__     						=model(lowercase_)
											self.parent.assertEqual(result.last_hidden_state.shape					,     (self.batch_size, self.seq_length, self.d_model))





				def 	__UpperCamelCase						(							self					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     )     ->   str:
											a__     						=FunnelBaseModel(config=lowercase_)
											model.to(lowercase_)
											model.eval()
											a__     						=model(lowercase_					,     attention_mask=lowercase_					,     token_type_ids=lowercase_)
											a__     						=model(lowercase_					,     token_type_ids=lowercase_)
											a__     						=model(lowercase_)
											self.parent.assertEqual(result.last_hidden_state.shape					,     (self.batch_size, 2, self.d_model))

											a__     						=False
											a__     						=model(lowercase_)
											self.parent.assertEqual(result.last_hidden_state.shape					,     (self.batch_size, 3, self.d_model))

											a__     						=False
											a__     						=model(lowercase_)
											self.parent.assertEqual(result.last_hidden_state.shape					,     (self.batch_size, 2, self.d_model))





				def 	__UpperCamelCase						(							self					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     )     ->   Optional[Any]:
											a__     						=self.num_labels
											a__     						=FunnelForPreTraining(config=lowercase_)
											model.to(lowercase_)
											model.eval()
											a__     						=model(lowercase_					,     attention_mask=lowercase_					,     token_type_ids=lowercase_					,     labels=lowercase_)
											self.parent.assertEqual(result.logits.shape					,     (self.batch_size, self.seq_length))





				def 	__UpperCamelCase						(							self					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     )     ->   Optional[Any]:
											a__     						=FunnelForMaskedLM(config=lowercase_)
											model.to(lowercase_)
											model.eval()
											a__     						=model(lowercase_					,     attention_mask=lowercase_					,     token_type_ids=lowercase_					,     labels=lowercase_)
											self.parent.assertEqual(result.logits.shape					,     (self.batch_size, self.seq_length, self.vocab_size))





				def 	__UpperCamelCase						(							self					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     )     ->   Any:
											a__     						=self.num_labels
											a__     						=FunnelForSequenceClassification(lowercase_)
											model.to(lowercase_)
											model.eval()
											a__     						=model(lowercase_					,     attention_mask=lowercase_					,     token_type_ids=lowercase_					,     labels=lowercase_)
											self.parent.assertEqual(result.logits.shape					,     (self.batch_size, self.num_labels))





				def 	__UpperCamelCase						(							self					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     )     ->   int:
											a__     						=self.num_choices
											a__     						=FunnelForMultipleChoice(config=lowercase_)
											model.to(lowercase_)
											model.eval()
											a__     						=input_ids.unsqueeze(1).expand(-1					,     self.num_choices					,     -1).contiguous()
											a__     						=token_type_ids.unsqueeze(1).expand(-1					,     self.num_choices					,     -1).contiguous()
											a__     						=input_mask.unsqueeze(1).expand(-1					,     self.num_choices					,     -1).contiguous()
											a__     						=model(
											    lowercase_					,     attention_mask=lowercase_					,     token_type_ids=lowercase_					,     labels=lowercase_					,     )
											self.parent.assertEqual(result.logits.shape					,     (self.batch_size, self.num_choices))





				def 	__UpperCamelCase						(							self					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     )     ->   Optional[Any]:
											a__     						=self.num_labels
											a__     						=FunnelForTokenClassification(config=lowercase_)
											model.to(lowercase_)
											model.eval()
											a__     						=model(lowercase_					,     attention_mask=lowercase_					,     token_type_ids=lowercase_					,     labels=lowercase_)
											self.parent.assertEqual(result.logits.shape					,     (self.batch_size, self.seq_length, self.num_labels))





				def 	__UpperCamelCase						(							self					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     lowercase_					,     )     ->   Any:
											a__     						=FunnelForQuestionAnswering(config=lowercase_)
											model.to(lowercase_)
											model.eval()
											a__     						=model(
											    lowercase_					,     attention_mask=lowercase_					,     token_type_ids=lowercase_					,     start_positions=lowercase_					,     end_positions=lowercase_					,     )
											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)     ->   Any:
											a__     						=self.prepare_config_and_inputs()
											(
											    (
											    a__		
											)						,    (
											    a__		
											)						,    (
											    a__		
											)						,    (
											    a__		
											)						,    (
											    a__		
											)						,    (
											    a__		
											)						,    (
											    a__		
											)						,    (
											    a__		
											)						,    		
											)     						=config_and_inputs
											a__     						={'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
											return config, inputs_dict







@require_torch
class 			lowercase_				(UpperCAmelCase_			,				UpperCAmelCase_			,				unittest.TestCase      ):
				snake_case  						=False
				snake_case  						=False
				snake_case  						=(
				    (
				        FunnelModel,
				        FunnelForMaskedLM,
				        FunnelForPreTraining,
				        FunnelForQuestionAnswering,
				        FunnelForTokenClassification,
				    )
				    if is_torch_available()
				    else ()
				)
				snake_case  						=(
				    {
				        'feature-extraction': (FunnelBaseModel, FunnelModel),
				        'fill-mask': FunnelForMaskedLM,
				        'question-answering': FunnelForQuestionAnswering,
				        'text-classification': FunnelForSequenceClassification,
				        'token-classification': FunnelForTokenClassification,
				        'zero-shot': FunnelForSequenceClassification,
				    }
				    if is_torch_available()
				    else {}
				)





				def 	__UpperCamelCase						(							self					,     lowercase_					,     lowercase_					,     lowercase_=False)     ->   Tuple:
											a__     						=super()._prepare_for_class(lowercase_					,     lowercase_					,     return_labels=lowercase_)

											if return_labels:
																		if model_class in get_values(lowercase_):
																									a__     						=torch.zeros(
																									    (self.model_tester.batch_size, self.model_tester.seq_length)					,     dtype=torch.long					,     device=lowercase_)
											return inputs_dict





				def 	__UpperCamelCase						(							self)     ->   List[str]:
											a__     						=FunnelModelTester(self)
											a__     						=ConfigTester(self					,     config_class=lowercase_)





				def 	__UpperCamelCase						(							self)     ->   Tuple:
											self.config_tester.run_common_tests()





				def 	__UpperCamelCase						(							self)     ->   List[str]:
											a__     						=self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_model(*lowercase_)





				def 	__UpperCamelCase						(							self)     ->   Optional[int]:
											a__     						=self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_pretraining(*lowercase_)





				def 	__UpperCamelCase						(							self)     ->   str:
											a__     						=self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_masked_lm(*lowercase_)





				def 	__UpperCamelCase						(							self)     ->   Dict:
											a__     						=self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_token_classification(*lowercase_)





				def 	__UpperCamelCase						(							self)     ->   Tuple:
											a__     						=self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_question_answering(*lowercase_)





				def 	__UpperCamelCase						(							self					,     lowercase_)     ->   int:
											if hasattr(lowercase_					,     'weight') and module.weight is not None:
																		module.weight.data.fill_(3)
											if hasattr(lowercase_					,     'bias') and module.bias is not None:
																		module.bias.data.fill_(3)

											for param in ["r_w_bias", "r_r_bias", "r_kernel", "r_s_bias", "seg_embed"]:
																		if hasattr(lowercase_					,     lowercase_) and getattr(lowercase_					,     lowercase_) is not None:
																									a__     						=getattr(lowercase_					,     lowercase_)
																									weight.data.fill_(3)







@require_torch
class 			lowercase_				(UpperCAmelCase_			,				unittest.TestCase      ):
				snake_case  						=False
				snake_case  						=False
				snake_case  						=(
				    (FunnelBaseModel, FunnelForMultipleChoice, FunnelForSequenceClassification) if is_torch_available() else ()
				)





				def 	__UpperCamelCase						(							self)     ->   Optional[int]:
											a__     						=FunnelModelTester(self					,     base=lowercase_)
											a__     						=ConfigTester(self					,     config_class=lowercase_)





				def 	__UpperCamelCase						(							self)     ->   Any:
											self.config_tester.run_common_tests()





				def 	__UpperCamelCase						(							self)     ->   str:
											a__     						=self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_base_model(*lowercase_)





				def 	__UpperCamelCase						(							self)     ->   Any:
											a__     						=self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_sequence_classification(*lowercase_)





				def 	__UpperCamelCase						(							self)     ->   Any:
											a__     						=self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_multiple_choice(*lowercase_)





				def 	__UpperCamelCase						(							self)     ->   str:
											a__						,    a__     						=self.model_tester.prepare_config_and_inputs_for_common()
											a__     						=True

											for model_class in self.all_model_classes:
																		if model_class.__name__ == "FunnelBaseModel":
																									continue
																		a__     						=model_class(lowercase_)
																		model.to(lowercase_)
																		model.train()
																		a__     						=self._prepare_for_class(lowercase_					,     lowercase_					,     return_labels=lowercase_)
																		a__     						=model(**lowercase_).loss
																		loss.backward()





				def 	__UpperCamelCase						(							self					,     lowercase_)     ->   List[Any]:
											if hasattr(lowercase_					,     'weight') and module.weight is not None:
																		module.weight.data.fill_(3)
											if hasattr(lowercase_					,     'bias') and module.bias is not None:
																		module.bias.data.fill_(3)

											for param in ["r_w_bias", "r_r_bias", "r_kernel", "r_s_bias", "seg_embed"]:
																		if hasattr(lowercase_					,     lowercase_) and getattr(lowercase_					,     lowercase_) is not None:
																									a__     						=getattr(lowercase_					,     lowercase_)
																									weight.data.fill_(3)







@require_torch
@require_sentencepiece
@require_tokenizers
class 			lowercase_				(unittest.TestCase      ):





				def 	__UpperCamelCase						(							self)     ->   Tuple:
											a__     						=13
											a__     						=7
											a__     						=torch.arange(0					,     batch_size * sequence_length).long().reshape(lowercase_					,     lowercase_)
											a__     						=[0, 1, 2, 3, 4, 5, 6, 4, 1, 3, 5, 0, 1]
											a__     						=torch.tensor([[2] + [0] * a + [1] * (sequence_length - a - 1) for a in lengths])

											a__     						=FunnelModel.from_pretrained('sgugger/funnel-random-tiny')
											a__     						=model(lowercase_					,     token_type_ids=lowercase_)[0].abs()

											a__     						=torch.tensor(2344.8352)
											a__     						=torch.tensor(0.80_52)
											self.assertTrue(torch.allclose(output.sum()					,     lowercase_					,     atol=1e-4))
											self.assertTrue(torch.allclose(output.mean()					,     lowercase_					,     atol=1e-4))

											a__     						=torch.tensor([[1] * 7, [1] * 4 + [0] * 3] * 6 + [[0, 1, 1, 0, 0, 1, 1]])
											a__     						=model(lowercase_					,     attention_mask=lowercase_					,     token_type_ids=lowercase_)[0].abs()

											a__     						=torch.tensor(2343.8425)
											a__     						=torch.tensor(0.80_49)
											self.assertTrue(torch.allclose(output.sum()					,     lowercase_					,     atol=1e-4))
											self.assertTrue(torch.allclose(output.mean()					,     lowercase_					,     atol=1e-4))





				@slow
				def 	__UpperCamelCase						(							self)     ->   Optional[int]:
											a__     						=FunnelTokenizer.from_pretrained('huggingface/funnel-small')
											a__     						=FunnelModel.from_pretrained('huggingface/funnel-small')
											a__     						=tokenizer('Hello! I am the Funnel Transformer model.'					,     return_tensors='pt')
											a__     						=model(**lowercase_)[0]

											a__     						=torch.tensor(2_35.72_46)
											a__     						=torch.tensor(0.02_56)
											self.assertTrue(torch.allclose(output.sum()					,     lowercase_					,     atol=1e-4))
											self.assertTrue(torch.allclose(output.mean()					,     lowercase_					,     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


_lowerCAmelCase:	Any      							=					logging.get_logger(__name__)

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


_lowerCAmelCase:	Optional[Any]      							=					{
    'AutoTokenizer': 'PreTrainedTokenizerBase',
    'AutoFeatureExtractor': 'FeatureExtractionMixin',
    'AutoImageProcessor': 'ImageProcessingMixin',
}




class 			lowercase_				(lowercase__      ):
				snake_case  						=['feature_extractor', 'tokenizer']
				# Names need to be attr_class for attr in attributes
				snake_case  						=None
				snake_case  						=None
				snake_case  						=None





				def __init__(							self					,     *lowercase_					,     **lowercase_)     ->   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(lowercase_					,     self.attributes):
																		if attribute_name in kwargs:
																									raise TypeError(F"""Got multiple values for argument {attribute_name}.""")
																		else:
																									a__     						=arg

											if len(lowercase_) != len(self.attributes):
																		raise ValueError(
																		    F"""This processor requires {len(self.attributes)} arguments: {', '.join(self.attributes)}. Got """
																		    F"""{len(lowercase_)} 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(lowercase_					,     lowercase_)
																		if isinstance(lowercase_					,     lowercase_):
																									a__     						=tuple(getattr(lowercase_					,     lowercase_) for n in class_name if n is not None)
																		else:
																									a__     						=getattr(lowercase_					,     lowercase_)

																		if not isinstance(lowercase_					,     lowercase_):
																									raise ValueError(
																									    F"""Received a {type(lowercase_).__name__} for argument {attribute_name}, but a {class_name} was expected.""")

																		setattr(self					,     lowercase_					,     lowercase_)





				def __repr__(							self)     ->   List[str]:
											a__     						=[F"""- {name}: {repr(getattr(self					,     lowercase_))}""" for name in self.attributes]
											a__     						='\n'.join(lowercase_)
											return F"""{self.__class__.__name__}:\n{attributes_repr}"""





				def 	__UpperCamelCase						(							self					,     lowercase_					,     lowercase_ = False					,     **lowercase_)     ->   Optional[int]:
											os.makedirs(lowercase_					,     exist_ok=lowercase_)

											if push_to_hub:
																		a__     						=kwargs.pop('commit_message'					,     lowercase_)
																		a__     						=kwargs.pop('repo_id'					,     save_directory.split(os.path.sep)[-1])
																		a__     						=self._create_repo(lowercase_					,     **lowercase_)
																		a__     						=self._get_files_timestamps(lowercase_)
											# 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					,     lowercase_) for attribute_name in self.attributes]
																		a__     						=[(a.init_kwargs if isinstance(lowercase_					,     lowercase_) else a) for a in attrs]
																		custom_object_save(self					,     lowercase_					,     config=lowercase_)

											for attribute_name in self.attributes:
																		a__     						=getattr(self					,     lowercase_)
																		# Include the processor class in the attribute config so this processor can then be reloaded with the
																		# `AutoProcessor` API.
																		if hasattr(lowercase_					,     '_set_processor_class'):
																									attribute._set_processor_class(self.__class__.__name__)
																		attribute.save_pretrained(lowercase_)

											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					,     lowercase_)
																									if isinstance(lowercase_					,     lowercase_):
																																del attribute.init_kwargs["auto_map"]

											if push_to_hub:
																		self._upload_modified_files(
																		    lowercase_					,     lowercase_					,     lowercase_					,     commit_message=lowercase_					,     token=kwargs.get('use_auth_token')					,     )





				@classmethod
				def 	__UpperCamelCase						(							cls					,     lowercase_					,     lowercase_ = None					,     lowercase_ = False					,     lowercase_ = False					,     lowercase_ = None					,     lowercase_ = "main"					,     **lowercase_					,     )     ->   str:
											a__     						=cache_dir
											a__     						=force_download
											a__     						=local_files_only
											a__     						=revision

											a__     						=kwargs.pop('use_auth_token'					,     lowercase_)
											if use_auth_token is not None:
																		warnings.warn(
																		    'The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.'					,     lowercase_)
																		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(lowercase_					,     **lowercase_)
											return cls(*lowercase_)





				@classmethod
				def 	__UpperCamelCase						(							cls					,     lowercase_="AutoProcessor")     ->   Any:
											if not isinstance(lowercase_					,     lowercase_):
																		a__     						=auto_class.__name__

											import transformers.models.auto as auto_module

											if not hasattr(lowercase_					,     lowercase_):
																		raise ValueError(F"""{auto_class} is not a valid auto class.""")

											a__     						=auto_class





				@classmethod
				def 	__UpperCamelCase						(							cls					,     lowercase_					,     **lowercase_)     ->   Optional[int]:
											a__     						=[]
											for attribute_name in cls.attributes:
																		a__     						=getattr(cls					,     F"""{attribute_name}_class""")
																		if isinstance(lowercase_					,     lowercase_):
																									a__     						=tuple(getattr(lowercase_					,     lowercase_) if n is not None else None for n in class_name)
																									a__     						=kwargs.get('use_fast'					,     lowercase_)
																									if use_fast and classes[1] is not None:
																																a__     						=classes[1]
																									else:
																																a__     						=classes[0]
																		else:
																									a__     						=getattr(lowercase_					,     lowercase_)

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





				@property
				def 	__UpperCamelCase						(							self)     ->   List[Any]:
											a__     						=getattr(self					,     self.attributes[0])
											return getattr(lowercase_					,     'model_input_names'					,     lowercase_)







_lowerCAmelCase:	Dict      							=					copy_func(ProcessorMixin.push_to_hub)
if ProcessorMixin.push_to_hub.__doc__ is not None:
	_lowerCAmelCase:	Tuple      							=					ProcessorMixin.push_to_hub.__doc__.format(
	    object='processor', object_class='AutoProcessor', object_files='processor files'
	)

