"""simple docstring"""







from __future__ import annotations

import unittest

from transformers import DistilBertConfig, is_tf_available
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.models.distilbert.modeling_tf_distilbert import (
	    TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
	    TFDistilBertForMaskedLM,
	    TFDistilBertForMultipleChoice,
	    TFDistilBertForQuestionAnswering,
	    TFDistilBertForSequenceClassification,
	    TFDistilBertForTokenClassification,
	    TFDistilBertModel,
	)

class 		UpperCamelCase      :



				def __init__(self    :				List[str]     ,  _A    :				Any     ,  )   ->     Optional[Any]:
					__snake_case      :							Any						=			parent
					__snake_case      :							Union[str, Any]						=			13
					__snake_case      :							Union[str, Any]						=			7
					__snake_case      :							List[str]						=			True
					__snake_case      :							str						=			True
					__snake_case      :							str						=			False
					__snake_case      :							Union[str, Any]						=			True
					__snake_case      :							Any						=			99
					__snake_case      :							Any						=			32
					__snake_case      :							int						=			2
					__snake_case      :							Tuple						=			4
					__snake_case      :							Tuple						=			37
					__snake_case      :							Optional[Any]						=			'gelu'
					__snake_case      :							Optional[int]						=			0.1
					__snake_case      :							Optional[int]						=			0.1
					__snake_case      :							Optional[Any]						=			5_12
					__snake_case      :							str						=			16
					__snake_case      :							Optional[Any]						=			2
					__snake_case      :							Any						=			0.02
					__snake_case      :							int						=			3
					__snake_case      :							Dict						=			4
					__snake_case      :							List[Any]						=			None



				def  _lowercase					(self    :				int)   ->     List[str]:
					__snake_case      :							Any						=			ids_tensor([self.batch_size, self.seq_length]     ,  self.vocab_size)

					__snake_case      :							List[str]						=			None
					if self.use_input_mask:
						__snake_case      :							int						=			random_attention_mask([self.batch_size, self.seq_length])

					__snake_case      :							List[str]						=			None
					__snake_case      :							Dict						=			None
					__snake_case      :							Dict						=			None
					if self.use_labels:
						__snake_case      :							List[Any]						=			ids_tensor([self.batch_size]     ,  self.type_sequence_label_size)
						__snake_case      :							int						=			ids_tensor([self.batch_size, self.seq_length]     ,  self.num_labels)
						__snake_case      :							List[str]						=			ids_tensor([self.batch_size]     ,  self.num_choices)

					__snake_case      :							Dict						=			DistilBertConfig(
					    vocab_size=self.vocab_size     ,  dim=self.hidden_size     ,  n_layers=self.num_hidden_layers     ,  n_heads=self.num_attention_heads     ,  hidden_dim=self.intermediate_size     ,  hidden_act=self.hidden_act     ,  dropout=self.hidden_dropout_prob     ,  attention_dropout=self.attention_probs_dropout_prob     ,  max_position_embeddings=self.max_position_embeddings     ,  initializer_range=self.initializer_range     ,  )

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



				def  _lowercase					(self    :				List[Any]     ,  _A    :				Tuple     ,  _A    :				int     ,  _A    :				Any     ,  _A    :				int     ,  _A    :				List[str]     ,  _A    :				str)   ->     int:
					__snake_case      :							Tuple						=			TFDistilBertModel(config=_A)
					__snake_case      :							Union[str, Any]						=			{'input_ids': input_ids, 'attention_mask': input_mask}

					__snake_case      :							Optional[int]						=			model(_A)

					__snake_case      :							Union[str, Any]						=			[input_ids, input_mask]

					__snake_case      :							Any						=			model(_A)

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



				def  _lowercase					(self    :				List[str]     ,  _A    :				List[Any]     ,  _A    :				Dict     ,  _A    :				str     ,  _A    :				List[Any]     ,  _A    :				List[str]     ,  _A    :				Optional[int])   ->     int:
					__snake_case      :							Optional[Any]						=			TFDistilBertForMaskedLM(config=_A)
					__snake_case      :							Union[str, Any]						=			{'input_ids': input_ids, 'attention_mask': input_mask}
					__snake_case      :							Dict						=			model(_A)
					self.parent.assertEqual(result.logits.shape     ,  (self.batch_size, self.seq_length, self.vocab_size))



				def  _lowercase					(self    :				str     ,  _A    :				int     ,  _A    :				int     ,  _A    :				Dict     ,  _A    :				Union[str, Any]     ,  _A    :				Optional[int]     ,  _A    :				List[Any])   ->     Optional[Any]:
					__snake_case      :							int						=			TFDistilBertForQuestionAnswering(config=_A)
					__snake_case      :							str						=			{
					    'input_ids': input_ids,
					    'attention_mask': input_mask,
					}
					__snake_case      :							Dict						=			model(_A)
					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  _lowercase					(self    :				List[Any]     ,  _A    :				Any     ,  _A    :				Tuple     ,  _A    :				Dict     ,  _A    :				Union[str, Any]     ,  _A    :				Any     ,  _A    :				List[str])   ->     int:
					__snake_case      :							int						=			self.num_labels
					__snake_case      :							str						=			TFDistilBertForSequenceClassification(_A)
					__snake_case      :							Any						=			{'input_ids': input_ids, 'attention_mask': input_mask}
					__snake_case      :							Optional[int]						=			model(_A)
					self.parent.assertEqual(result.logits.shape     ,  (self.batch_size, self.num_labels))



				def  _lowercase					(self    :				Optional[int]     ,  _A    :				List[Any]     ,  _A    :				List[str]     ,  _A    :				int     ,  _A    :				Optional[Any]     ,  _A    :				Optional[Any]     ,  _A    :				int)   ->     Tuple:
					__snake_case      :							str						=			self.num_choices
					__snake_case      :							List[Any]						=			TFDistilBertForMultipleChoice(_A)
					__snake_case      :							int						=			tf.tile(tf.expand_dims(_A     ,  1)     ,  (1, self.num_choices, 1))
					__snake_case      :							Union[str, Any]						=			tf.tile(tf.expand_dims(_A     ,  1)     ,  (1, self.num_choices, 1))
					__snake_case      :							int						=			{
					    'input_ids': multiple_choice_inputs_ids,
					    'attention_mask': multiple_choice_input_mask,
					}
					__snake_case      :							str						=			model(_A)
					self.parent.assertEqual(result.logits.shape     ,  (self.batch_size, self.num_choices))



				def  _lowercase					(self    :				List[Any]     ,  _A    :				str     ,  _A    :				Any     ,  _A    :				Optional[int]     ,  _A    :				Tuple     ,  _A    :				Dict     ,  _A    :				Union[str, Any])   ->     Optional[Any]:
					__snake_case      :							Any						=			self.num_labels
					__snake_case      :							Optional[int]						=			TFDistilBertForTokenClassification(_A)
					__snake_case      :							int						=			{'input_ids': input_ids, 'attention_mask': input_mask}
					__snake_case      :							Optional[Any]						=			model(_A)
					self.parent.assertEqual(result.logits.shape     ,  (self.batch_size, self.seq_length, self.num_labels))






				def  _lowercase					(self    :				Tuple)   ->     Any:
					__snake_case      :							Union[str, Any]						=			self.prepare_config_and_inputs()
					(__snake_case)      :							Optional[Any]						=			config_and_inputs
					__snake_case      :							Tuple						=			{'input_ids': input_ids, 'attention_mask': input_mask}
					return config, inputs_dict







@require_tf
class 		UpperCamelCase      (   lowercase				,     lowercase				,     unittest.TestCase						):
				UpperCAmelCase    :				Optional[Any]   =		(
				    (
				        TFDistilBertModel,
				        TFDistilBertForMaskedLM,
				        TFDistilBertForQuestionAnswering,
				        TFDistilBertForSequenceClassification,
				        TFDistilBertForTokenClassification,
				        TFDistilBertForMultipleChoice,
				    )
				    if is_tf_available()
				    else None
				)
				UpperCAmelCase    :				str   =		(
				    {
				        """feature-extraction""": TFDistilBertModel,
				        """fill-mask""": TFDistilBertForMaskedLM,
				        """question-answering""": TFDistilBertForQuestionAnswering,
				        """text-classification""": TFDistilBertForSequenceClassification,
				        """token-classification""": TFDistilBertForTokenClassification,
				        """zero-shot""": TFDistilBertForSequenceClassification,
				    }
				    if is_tf_available()
				    else {}
				)
				UpperCAmelCase    :				Tuple   =		False
				UpperCAmelCase    :				List[str]   =		False



				def  _lowercase					(self    :				Optional[int])   ->     Optional[int]:
					__snake_case      :							Dict						=			TFDistilBertModelTester(self)
					__snake_case      :							List[Any]						=			ConfigTester(self     ,  config_class=_A     ,  dim=37)



				def  _lowercase					(self    :				Tuple)   ->     Union[str, Any]:
					self.config_tester.run_common_tests()



				def  _lowercase					(self    :				Optional[int])   ->     List[str]:
					__snake_case      :							List[str]						=			self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_distilbert_model(*_A)



				def  _lowercase					(self    :				List[str])   ->     Optional[Any]:
					__snake_case      :							Optional[int]						=			self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_distilbert_for_masked_lm(*_A)



				def  _lowercase					(self    :				Union[str, Any])   ->     Dict:
					__snake_case      :							Dict						=			self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_distilbert_for_question_answering(*_A)



				def  _lowercase					(self    :				List[str])   ->     str:
					__snake_case      :							Optional[Any]						=			self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_distilbert_for_sequence_classification(*_A)



				def  _lowercase					(self    :				Dict)   ->     Dict:
					__snake_case      :							Union[str, Any]						=			self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_distilbert_for_multiple_choice(*_A)



				def  _lowercase					(self    :				Dict)   ->     Dict:
					__snake_case      :							Union[str, Any]						=			self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_distilbert_for_token_classification(*_A)






				@slow
				def  _lowercase					(self    :				Optional[int])   ->     List[str]:
					for model_name in list(TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]):
						__snake_case      :							int						=			TFDistilBertModel.from_pretrained(_A)
						self.assertIsNotNone(_A)







@require_tf
class 		UpperCamelCase      (   unittest.TestCase						):



				@slow
				def  _lowercase					(self    :				Optional[Any])   ->     List[str]:
					__snake_case      :							Dict						=			TFDistilBertModel.from_pretrained('distilbert-base-uncased')
					__snake_case      :							List[Any]						=			tf.constant([[0, 1, 2, 3, 4, 5]])
					__snake_case      :							Dict						=			model(_A)[0]

					__snake_case      :							Optional[Any]						=			[1, 6, 7_68]
					self.assertEqual(output.shape     ,  _A)

					__snake_case      :							str						=			tf.constant(
					    [
					        [
					            [0.19_261_885, -0.13_732_955, 0.4_119_799],
					            [0.22_150_156, -0.07_422_661, 0.39_037_204],
					            [0.22_756_018, -0.0_896_414, 0.3_701_467],
					        ]
					    ])
					tf.debugging.assert_near(output[:, :3, :3]     ,  _A     ,  atol=1E-4)






"""simple docstring"""







from __future__ import annotations

import copy
import tempfile
import unittest

from transformers import CONFIG_MAPPING, AutoConfig, BertConfig, GPTaConfig, TaConfig, TapasConfig, is_tf_available
from transformers.testing_utils import (
    DUMMY_UNKNOWN_IDENTIFIER,
    SMALL_MODEL_IDENTIFIER,
    RequestCounter,
    require_tensorflow_probability,
    require_tf,
    slow,
)

from ..bert.test_modeling_bert import BertModelTester


if is_tf_available():
	from transformers import (
	    TFAutoModel,
	    TFAutoModelForCausalLM,
	    TFAutoModelForMaskedLM,
	    TFAutoModelForPreTraining,
	    TFAutoModelForQuestionAnswering,
	    TFAutoModelForSeqaSeqLM,
	    TFAutoModelForSequenceClassification,
	    TFAutoModelForTableQuestionAnswering,
	    TFAutoModelForTokenClassification,
	    TFAutoModelWithLMHead,
	    TFBertForMaskedLM,
	    TFBertForPreTraining,
	    TFBertForQuestionAnswering,
	    TFBertForSequenceClassification,
	    TFBertModel,
	    TFFunnelBaseModel,
	    TFFunnelModel,
	    TFGPTaLMHeadModel,
	    TFRobertaForMaskedLM,
	    TFTaForConditionalGeneration,
	    TFTapasForQuestionAnswering,
	)
	from transformers.models.auto.modeling_tf_auto import (
	    TF_MODEL_FOR_CAUSAL_LM_MAPPING,
	    TF_MODEL_FOR_MASKED_LM_MAPPING,
	    TF_MODEL_FOR_PRETRAINING_MAPPING,
	    TF_MODEL_FOR_QUESTION_ANSWERING_MAPPING,
	    TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
	    TF_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING,
	    TF_MODEL_MAPPING,
	)
	from transformers.models.bert.modeling_tf_bert import TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST
	from transformers.models.gpta.modeling_tf_gpta import TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST
	from transformers.models.ta.modeling_tf_ta import TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST
	from transformers.models.tapas.modeling_tf_tapas import TF_TAPAS_PRETRAINED_MODEL_ARCHIVE_LIST

class 		UpperCamelCase      (   lowercase						):
				UpperCAmelCase    :				Optional[int]   =		"""new-model"""


if is_tf_available():

	class 		UpperCamelCase      (   lowercase						):
					UpperCAmelCase    :				List[str]   =		NewModelConfig

@require_tf
class 		UpperCamelCase      (   unittest.TestCase						):



				@slow
				def  _lowercase					(self    :				List[str])   ->     Dict:
					__snake_case      :							Any						=			'bert-base-cased'
					__snake_case      :							Optional[Any]						=			AutoConfig.from_pretrained(_A)
					self.assertIsNotNone(_A)
					self.assertIsInstance(_A     ,  _A)

					__snake_case      :							Union[str, Any]						=			TFAutoModel.from_pretrained(_A)
					self.assertIsNotNone(_A)
					self.assertIsInstance(_A     ,  _A)



				@slow
				def  _lowercase					(self    :				List[Any])   ->     str:
					__snake_case      :							Optional[int]						=			'bert-base-cased'
					__snake_case      :							List[Any]						=			AutoConfig.from_pretrained(_A)
					self.assertIsNotNone(_A)
					self.assertIsInstance(_A     ,  _A)

					__snake_case      :							Dict						=			TFAutoModelForPreTraining.from_pretrained(_A)
					self.assertIsNotNone(_A)
					self.assertIsInstance(_A     ,  _A)



				@slow
				def  _lowercase					(self    :				Any)   ->     List[str]:
					for model_name in TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
						__snake_case      :							str						=			AutoConfig.from_pretrained(_A)
						self.assertIsNotNone(_A)
						self.assertIsInstance(_A     ,  _A)

						__snake_case      :							List[str]						=			TFAutoModelForCausalLM.from_pretrained(_A)
						__snake_case		,    __snake_case      :							List[str]						=			TFAutoModelForCausalLM.from_pretrained(_A     ,  output_loading_info=_A)
						self.assertIsNotNone(_A)
						self.assertIsInstance(_A     ,  _A)



				@slow
				def  _lowercase					(self    :				Tuple)   ->     Dict:
					for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
						__snake_case      :							Union[str, Any]						=			AutoConfig.from_pretrained(_A)
						self.assertIsNotNone(_A)
						self.assertIsInstance(_A     ,  _A)

						__snake_case      :							Union[str, Any]						=			TFAutoModelWithLMHead.from_pretrained(_A)
						self.assertIsNotNone(_A)
						self.assertIsInstance(_A     ,  _A)



				@slow
				def  _lowercase					(self    :				Union[str, Any])   ->     Optional[int]:
					for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
						__snake_case      :							Union[str, Any]						=			AutoConfig.from_pretrained(_A)
						self.assertIsNotNone(_A)
						self.assertIsInstance(_A     ,  _A)

						__snake_case      :							Optional[Any]						=			TFAutoModelForMaskedLM.from_pretrained(_A)
						__snake_case		,    __snake_case      :							Optional[int]						=			TFAutoModelForMaskedLM.from_pretrained(_A     ,  output_loading_info=_A)
						self.assertIsNotNone(_A)
						self.assertIsInstance(_A     ,  _A)



				@slow
				def  _lowercase					(self    :				str)   ->     Union[str, Any]:
					for model_name in TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
						__snake_case      :							Dict						=			AutoConfig.from_pretrained(_A)
						self.assertIsNotNone(_A)
						self.assertIsInstance(_A     ,  _A)

						__snake_case      :							str						=			TFAutoModelForSeqaSeqLM.from_pretrained(_A)
						__snake_case		,    __snake_case      :							Union[str, Any]						=			TFAutoModelForSeqaSeqLM.from_pretrained(_A     ,  output_loading_info=_A)
						self.assertIsNotNone(_A)
						self.assertIsInstance(_A     ,  _A)



				@slow
				def  _lowercase					(self    :				str)   ->     str:
					# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
					for model_name in ["bert-base-uncased"]:
						__snake_case      :							Tuple						=			AutoConfig.from_pretrained(_A)
						self.assertIsNotNone(_A)
						self.assertIsInstance(_A     ,  _A)

						__snake_case      :							Tuple						=			TFAutoModelForSequenceClassification.from_pretrained(_A)
						self.assertIsNotNone(_A)
						self.assertIsInstance(_A     ,  _A)



				@slow
				def  _lowercase					(self    :				Optional[Any])   ->     Optional[int]:
					# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
					for model_name in ["bert-base-uncased"]:
						__snake_case      :							List[str]						=			AutoConfig.from_pretrained(_A)
						self.assertIsNotNone(_A)
						self.assertIsInstance(_A     ,  _A)

						__snake_case      :							Any						=			TFAutoModelForQuestionAnswering.from_pretrained(_A)
						self.assertIsNotNone(_A)
						self.assertIsInstance(_A     ,  _A)



				@slow
				@require_tensorflow_probability
				def  _lowercase					(self    :				List[Any])   ->     List[str]:
					for model_name in TF_TAPAS_PRETRAINED_MODEL_ARCHIVE_LIST[5:6]:
						__snake_case      :							Optional[Any]						=			AutoConfig.from_pretrained(_A)
						self.assertIsNotNone(_A)
						self.assertIsInstance(_A     ,  _A)

						__snake_case      :							int						=			TFAutoModelForTableQuestionAnswering.from_pretrained(_A)
						__snake_case		,    __snake_case      :							Dict						=			TFAutoModelForTableQuestionAnswering.from_pretrained(
						    _A     ,  output_loading_info=_A)
						self.assertIsNotNone(_A)
						self.assertIsInstance(_A     ,  _A)



				def  _lowercase					(self    :				Optional[Any])   ->     Optional[Any]:
					__snake_case      :							Optional[int]						=			TFAutoModelWithLMHead.from_pretrained(_A)
					self.assertIsInstance(_A     ,  _A)
					self.assertEqual(model.num_parameters()     ,  1_44_10)
					self.assertEqual(model.num_parameters(only_trainable=_A)     ,  1_44_10)



				def  _lowercase					(self    :				Any)   ->     List[str]:
					__snake_case      :							List[Any]						=			TFAutoModelWithLMHead.from_pretrained(_A)
					self.assertIsInstance(_A     ,  _A)
					self.assertEqual(model.num_parameters()     ,  1_44_10)
					self.assertEqual(model.num_parameters(only_trainable=_A)     ,  1_44_10)



				def  _lowercase					(self    :				Optional[Any])   ->     str:
					# For the auto model mapping, FunnelConfig has two models: FunnelModel and FunnelBaseModel
					__snake_case      :							Optional[Any]						=			TFAutoModel.from_pretrained('sgugger/funnel-random-tiny')
					self.assertIsInstance(_A     ,  _A)

					__snake_case      :							int						=			copy.deepcopy(model.config)
					__snake_case      :							int						=			['FunnelBaseModel']
					__snake_case      :							int						=			TFAutoModel.from_config(_A)
					self.assertIsInstance(_A     ,  _A)

					with tempfile.TemporaryDirectory() as tmp_dir:
						model.save_pretrained(_A)
						__snake_case      :							List[Any]						=			TFAutoModel.from_pretrained(_A)
						self.assertIsInstance(_A     ,  _A)



				def  _lowercase					(self    :				List[Any])   ->     int:
					try:
						AutoConfig.register('new-model'     ,  _A)

						__snake_case      :							int						=			[
						    TFAutoModel,
						    TFAutoModelForCausalLM,
						    TFAutoModelForMaskedLM,
						    TFAutoModelForPreTraining,
						    TFAutoModelForQuestionAnswering,
						    TFAutoModelForSequenceClassification,
						    TFAutoModelForTokenClassification,
						]

						for auto_class in auto_classes:
							with self.subTest(auto_class.__name__):
								# Wrong config class will raise an error
								with self.assertRaises(_A):
									auto_class.register(_A     ,  _A)
								auto_class.register(_A     ,  _A)
								# Trying to register something existing in the Transformers library will raise an error
								with self.assertRaises(_A):
									auto_class.register(_A     ,  _A)

								# Now that the config is registered, it can be used as any other config with the auto-API
								__snake_case      :							Union[str, Any]						=			BertModelTester(self).get_config()
								__snake_case      :							Optional[int]						=			NewModelConfig(**tiny_config.to_dict())
								__snake_case      :							List[str]						=			auto_class.from_config(_A)
								self.assertIsInstance(_A     ,  _A)

								with tempfile.TemporaryDirectory() as tmp_dir:
									model.save_pretrained(_A)
									__snake_case      :							Tuple						=			auto_class.from_pretrained(_A)
									self.assertIsInstance(_A     ,  _A)

					finally:
						if "new-model" in CONFIG_MAPPING._extra_content:
							del CONFIG_MAPPING._extra_content["new-model"]
						for mapping in (
						    TF_MODEL_MAPPING,
						    TF_MODEL_FOR_PRETRAINING_MAPPING,
						    TF_MODEL_FOR_QUESTION_ANSWERING_MAPPING,
						    TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
						    TF_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING,
						    TF_MODEL_FOR_CAUSAL_LM_MAPPING,
						    TF_MODEL_FOR_MASKED_LM_MAPPING,
						):
							if NewModelConfig in mapping._extra_content:
								del mapping._extra_content[NewModelConfig]



				def  _lowercase					(self    :				Optional[int])   ->     Union[str, Any]:
					with self.assertRaisesRegex(
					    _A     ,  'bert-base is not a local folder and is not a valid model identifier'):
						__snake_case      :							Any						=			TFAutoModel.from_pretrained('bert-base')



				def  _lowercase					(self    :				str)   ->     str:
					with self.assertRaisesRegex(
					    _A     ,  r'aaaaaa is not a valid git identifier \(branch name, tag name or commit id\)'):
						__snake_case      :							Optional[Any]						=			TFAutoModel.from_pretrained(_A     ,  revision='aaaaaa')



				def  _lowercase					(self    :				int)   ->     Any:
					with self.assertRaisesRegex(
					    _A     ,  'hf-internal-testing/config-no-model does not appear to have a file named pytorch_model.bin'     ,  ):
						__snake_case      :							List[str]						=			TFAutoModel.from_pretrained('hf-internal-testing/config-no-model')



				def  _lowercase					(self    :				Optional[Any])   ->     Any:
					with self.assertRaisesRegex(_A     ,  'Use `from_pt=True` to load this model'):
						__snake_case      :							List[str]						=			TFAutoModel.from_pretrained('hf-internal-testing/tiny-bert-pt-only')






				def  _lowercase					(self    :				str)   ->     Any:
					# Make sure we have cached the model.
					__snake_case      :							str						=			TFAutoModel.from_pretrained('hf-internal-testing/tiny-random-bert')
					with RequestCounter() as counter:
						__snake_case      :							List[str]						=			TFAutoModel.from_pretrained('hf-internal-testing/tiny-random-bert')
						self.assertEqual(counter.get_request_count     ,  0)
						self.assertEqual(counter.head_request_count     ,  1)
						self.assertEqual(counter.other_request_count     ,  0)

					# With a sharded checkpoint
					__snake_case      :							Optional[int]						=			TFAutoModel.from_pretrained('ArthurZ/tiny-random-bert-sharded')
					with RequestCounter() as counter:
						__snake_case      :							Any						=			TFAutoModel.from_pretrained('ArthurZ/tiny-random-bert-sharded')
						self.assertEqual(counter.get_request_count     ,  0)
						self.assertEqual(counter.head_request_count     ,  1)
						self.assertEqual(counter.other_request_count     ,  0)





