
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  lowerCamelCase__							(				__lowercase):




	'''simple docstring'''




	_A								=     'new-model'


if is_tf_available():




		class  lowerCamelCase__							(				__lowercase):




			'''simple docstring'''




			_A								=     NewModelConfig




@require_tf
class  lowerCamelCase__							(				unittest.TestCase):




	'''simple docstring'''




	@slow
	def    _lowerCamelCase				(					self		:int						)		-> Any:
								__UpperCamelCase	:   List[Any]			   =					"bert-base-cased"
								__UpperCamelCase	:   Any			   =					AutoConfig.from_pretrained(a						)
								self.assertIsNotNone(a						)
								self.assertIsInstance(a     ,   a						)

								__UpperCamelCase	:   Any			   =					TFAutoModel.from_pretrained(a						)
								self.assertIsNotNone(a						)
								self.assertIsInstance(a     ,   a						)







	@slow
	def    _lowerCamelCase				(					self		:str						)		-> int:
								__UpperCamelCase	:   List[Any]			   =					"bert-base-cased"
								__UpperCamelCase	:   List[str]			   =					AutoConfig.from_pretrained(a						)
								self.assertIsNotNone(a						)
								self.assertIsInstance(a     ,   a						)

								__UpperCamelCase	:   Union[str, Any]			   =					TFAutoModelForPreTraining.from_pretrained(a						)
								self.assertIsNotNone(a						)
								self.assertIsInstance(a     ,   a						)







	@slow
	def    _lowerCamelCase				(					self		:int						)		-> Optional[int]:
								for model_name in TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
															__UpperCamelCase	:   Union[str, Any]			   =					AutoConfig.from_pretrained(a						)
															self.assertIsNotNone(a						)
															self.assertIsInstance(a     ,   a						)

															__UpperCamelCase	:   Any			   =					TFAutoModelForCausalLM.from_pretrained(a						)
															__UpperCamelCase   ,						__UpperCamelCase	:   Dict			   =					TFAutoModelForCausalLM.from_pretrained(a     ,   output_loading_info=a						)
															self.assertIsNotNone(a						)
															self.assertIsInstance(a     ,   a						)







	@slow
	def    _lowerCamelCase				(					self		:Any						)		-> Optional[int]:
								for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
															__UpperCamelCase	:   Optional[int]			   =					AutoConfig.from_pretrained(a						)
															self.assertIsNotNone(a						)
															self.assertIsInstance(a     ,   a						)

															__UpperCamelCase	:   List[str]			   =					TFAutoModelWithLMHead.from_pretrained(a						)
															self.assertIsNotNone(a						)
															self.assertIsInstance(a     ,   a						)







	@slow
	def    _lowerCamelCase				(					self		:str						)		-> Union[str, Any]:
								for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
															__UpperCamelCase	:   int			   =					AutoConfig.from_pretrained(a						)
															self.assertIsNotNone(a						)
															self.assertIsInstance(a     ,   a						)

															__UpperCamelCase	:   List[str]			   =					TFAutoModelForMaskedLM.from_pretrained(a						)
															__UpperCamelCase   ,						__UpperCamelCase	:   Dict			   =					TFAutoModelForMaskedLM.from_pretrained(a     ,   output_loading_info=a						)
															self.assertIsNotNone(a						)
															self.assertIsInstance(a     ,   a						)







	@slow
	def    _lowerCamelCase				(					self		:Any						)		-> str:
								for model_name in TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
															__UpperCamelCase	:   Optional[Any]			   =					AutoConfig.from_pretrained(a						)
															self.assertIsNotNone(a						)
															self.assertIsInstance(a     ,   a						)

															__UpperCamelCase	:   Union[str, Any]			   =					TFAutoModelForSeqaSeqLM.from_pretrained(a						)
															__UpperCamelCase   ,						__UpperCamelCase	:   Optional[Any]			   =					TFAutoModelForSeqaSeqLM.from_pretrained(a     ,   output_loading_info=a						)
															self.assertIsNotNone(a						)
															self.assertIsInstance(a     ,   a						)







	@slow
	def    _lowerCamelCase				(					self		:Dict						)		-> List[Any]:
								# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
								for model_name in ["bert-base-uncased"]:
															__UpperCamelCase	:   Optional[Any]			   =					AutoConfig.from_pretrained(a						)
															self.assertIsNotNone(a						)
															self.assertIsInstance(a     ,   a						)

															__UpperCamelCase	:   Union[str, Any]			   =					TFAutoModelForSequenceClassification.from_pretrained(a						)
															self.assertIsNotNone(a						)
															self.assertIsInstance(a     ,   a						)







	@slow
	def    _lowerCamelCase				(					self		:str						)		-> Any:
								# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
								for model_name in ["bert-base-uncased"]:
															__UpperCamelCase	:   Any			   =					AutoConfig.from_pretrained(a						)
															self.assertIsNotNone(a						)
															self.assertIsInstance(a     ,   a						)

															__UpperCamelCase	:   Union[str, Any]			   =					TFAutoModelForQuestionAnswering.from_pretrained(a						)
															self.assertIsNotNone(a						)
															self.assertIsInstance(a     ,   a						)







	@slow
	@require_tensorflow_probability
	def    _lowerCamelCase				(					self		:Optional[Any]						)		-> Optional[Any]:
								for model_name in TF_TAPAS_PRETRAINED_MODEL_ARCHIVE_LIST[5:6]:
															__UpperCamelCase	:   Union[str, Any]			   =					AutoConfig.from_pretrained(a						)
															self.assertIsNotNone(a						)
															self.assertIsInstance(a     ,   a						)

															__UpperCamelCase	:   Optional[int]			   =					TFAutoModelForTableQuestionAnswering.from_pretrained(a						)
															__UpperCamelCase   ,						__UpperCamelCase	:   List[str]			   =					TFAutoModelForTableQuestionAnswering.from_pretrained(
															    a     ,   output_loading_info=a						)
															self.assertIsNotNone(a						)
															self.assertIsInstance(a     ,   a						)







	def    _lowerCamelCase				(					self		:int						)		-> Dict:
								__UpperCamelCase	:   Optional[int]			   =					TFAutoModelWithLMHead.from_pretrained(a						)
								self.assertIsInstance(a     ,   a						)
								self.assertEqual(model.num_parameters()     ,   1_4_4_1_0						)
								self.assertEqual(model.num_parameters(only_trainable=a						)     ,   1_4_4_1_0						)







	def    _lowerCamelCase				(					self		:Optional[int]						)		-> Any:
								__UpperCamelCase	:   Optional[Any]			   =					TFAutoModelWithLMHead.from_pretrained(a						)
								self.assertIsInstance(a     ,   a						)
								self.assertEqual(model.num_parameters()     ,   1_4_4_1_0						)
								self.assertEqual(model.num_parameters(only_trainable=a						)     ,   1_4_4_1_0						)







	def    _lowerCamelCase				(					self		:Dict						)		-> List[str]:
								# For the auto model mapping, FunnelConfig has two models: FunnelModel and FunnelBaseModel
								__UpperCamelCase	:   str			   =					TFAutoModel.from_pretrained("sgugger/funnel-random-tiny"						)
								self.assertIsInstance(a     ,   a						)

								__UpperCamelCase	:   Dict			   =					copy.deepcopy(model.config						)
								__UpperCamelCase	:   Dict			   =					["FunnelBaseModel"]
								__UpperCamelCase	:   Optional[Any]			   =					TFAutoModel.from_config(a						)
								self.assertIsInstance(a     ,   a						)

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







	def    _lowerCamelCase				(					self		:List[str]						)		-> str:
								try:
															AutoConfig.register("new-model"     ,   a						)

															__UpperCamelCase	:   List[str]			   =					[
															    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
																													__UpperCamelCase	:   Union[str, Any]			   =					BertModelTester(self						).get_config()
																													__UpperCamelCase	:   Optional[int]			   =					NewModelConfig(**tiny_config.to_dict()						)
																													__UpperCamelCase	:   Optional[int]			   =					auto_class.from_config(a						)
																													self.assertIsInstance(a     ,   a						)

																													with tempfile.TemporaryDirectory() as tmp_dir:
																																				model.save_pretrained(a						)
																																				__UpperCamelCase	:   Optional[int]			   =					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    _lowerCamelCase				(					self		:Any						)		-> int:
								with self.assertRaisesRegex(
								    a     ,   "bert-base is not a local folder and is not a valid model identifier"						):
															__UpperCamelCase	:   List[str]			   =					TFAutoModel.from_pretrained("bert-base"						)







	def    _lowerCamelCase				(					self		:int						)		-> str:
								with self.assertRaisesRegex(
								    a     ,   r"aaaaaa is not a valid git identifier \(branch name, tag name or commit id\)"						):
															__UpperCamelCase	:   Tuple			   =					TFAutoModel.from_pretrained(a     ,   revision="aaaaaa"						)







	def    _lowerCamelCase				(					self		:Optional[int]						)		-> Dict:
								with self.assertRaisesRegex(
								    a     ,   "hf-internal-testing/config-no-model does not appear to have a file named pytorch_model.bin"     ,   ):
															__UpperCamelCase	:   Optional[Any]			   =					TFAutoModel.from_pretrained("hf-internal-testing/config-no-model"						)







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







	def    _lowerCamelCase				(					self		:int						)		-> Dict:
								# Make sure we have cached the model.
								__UpperCamelCase	:   str			   =					TFAutoModel.from_pretrained("hf-internal-testing/tiny-random-bert"						)
								with RequestCounter() as counter:
															__UpperCamelCase	:   int			   =					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
								__UpperCamelCase	:   Optional[Any]			   =					TFAutoModel.from_pretrained("ArthurZ/tiny-random-bert-sharded"						)
								with RequestCounter() as counter:
															__UpperCamelCase	:   int			   =					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						)

import argparse
import datetime




def 	_SCREAMING_SNAKE_CASE					(		_lowerCamelCase :			str)					->    str:






							'''simple docstring'''





							__UpperCamelCase	:   str			   =					{
							    "0": "Sunday",
							    "1": "Monday",
							    "2": "Tuesday",
							    "3": "Wednesday",
							    "4": "Thursday",
							    "5": "Friday",
							    "6": "Saturday",
							}

							__UpperCamelCase	:   List[str]			   =					{0: 1, 1: 2, 2: 3, 3: 4, 4: 5, 5: 6, 6: 0}

							# Validate
							if not 0 < len(_lowerCamelCase) < 11:
														raise ValueError("Must be 10 characters long")

							# Get month
							__UpperCamelCase	:   int			   =					int(date_input[0] + date_input[1])
							# Validate
							if not 0 < m < 13:
														raise ValueError("Month must be between 1 - 12")

							__UpperCamelCase	:   str			   =					date_input[2]
							# Validate
							if sep_a not in ["-", "/"]:
														raise ValueError("Date separator must be '-' or '/'")

							# Get day
							__UpperCamelCase	:   int			   =					int(date_input[3] + date_input[4])
							# Validate
							if not 0 < d < 32:
														raise ValueError("Date must be between 1 - 31")

							# Get second separator
							__UpperCamelCase	:   str			   =					date_input[5]
							# Validate
							if sep_a not in ["-", "/"]:
														raise ValueError("Date separator must be '-' or '/'")

							# Get year
							__UpperCamelCase	:   int			   =					int(date_input[6] + date_input[7] + date_input[8] + date_input[9])
							# Arbitrary year range
							if not 45 < y < 8_500:
														raise ValueError(
														    "Year out of range. There has to be some sort of limit...right?")

							# Get datetime obj for validation
							__UpperCamelCase	:   Union[str, Any]			   =					datetime.date(int(_lowerCamelCase)						,  int(_lowerCamelCase)						,  int(_lowerCamelCase))

							# Start math
							if m <= 2:
														__UpperCamelCase	:   Any			   =					y - 1
														__UpperCamelCase	:   Optional[Any]			   =					m + 12
							# maths var
							__UpperCamelCase	:   int			   =					int(str(_lowerCamelCase)[:2])
							__UpperCamelCase	:   int			   =					int(str(_lowerCamelCase)[2:])
							__UpperCamelCase	:   int			   =					int(2.6 * m - 5.3_9)
							__UpperCamelCase	:   int			   =					int(c / 4)
							__UpperCamelCase	:   int			   =					int(k / 4)
							__UpperCamelCase	:   int			   =					int(d + k)
							__UpperCamelCase	:   int			   =					int(t + u + v + x)
							__UpperCamelCase	:   int			   =					int(z - (2 * c))
							__UpperCamelCase	:   int			   =					round(w % 7)
							# End math

							# Validate math
							if f != convert_datetime_days[dt_ck.weekday()]:
														raise AssertionError("The date was evaluated incorrectly. Contact developer.")

							# Response
							__UpperCamelCase	:   str			   =					F'Your date {date_input}, is a {days[str(_lowerCamelCase)]}!'
							return response


if __name__ == "__main__":
		import doctest

		doctest.testmod()
		lowercase  :					Optional[int]													=       argparse.ArgumentParser(
		    description=(
		        'Find out what day of the week nearly any date is or was. Enter '
		        'date as a string in the mm-dd-yyyy or mm/dd/yyyy format'
		    )
		)
		parser.add_argument(
		    'date_input', type=str, help='Date as a string (mm-dd-yyyy or mm/dd/yyyy)'
		)
		lowercase  :					Tuple													=       parser.parse_args()
		zeller(args.date_input)