
import unittest

from transformers import DebertaVaConfig, is_torch_available
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 (
		    DebertaVaForMaskedLM,
		    DebertaVaForMultipleChoice,
		    DebertaVaForQuestionAnswering,
		    DebertaVaForSequenceClassification,
		    DebertaVaForTokenClassification,
		    DebertaVaModel,
		)
		from transformers.models.deberta_va.modeling_deberta_va import DEBERTA_V2_PRETRAINED_MODEL_ARCHIVE_LIST




class  lowerCamelCase__							(				__lowercase):




	'''simple docstring'''




	def __init__(					self		:Optional[int]     ,   a		:int     ,   a		:Tuple=1_3     ,   a		:Tuple=7     ,   a		:Tuple=True     ,   a		:Union[str, Any]=True     ,   a		:Any=True     ,   a		:Union[str, Any]=True     ,   a		:Union[str, Any]=9_9     ,   a		:str=3_2     ,   a		:int=5     ,   a		:str=4     ,   a		:str=3_7     ,   a		:str="gelu"     ,   a		:Optional[Any]=0.1     ,   a		:int=0.1     ,   a		:Dict=5_1_2     ,   a		:Optional[Any]=1_6     ,   a		:Tuple=2     ,   a		:Tuple=0.02     ,   a		:Any=False     ,   a		:Optional[Any]=True     ,   a		:Dict="None"     ,   a		:Dict=3     ,   a		:Union[str, Any]=4     ,   a		:Optional[int]=None     ,   )		-> List[Any]:
								__UpperCamelCase	:   str			   =					parent
								__UpperCamelCase	:   Optional[Any]			   =					batch_size
								__UpperCamelCase	:   Tuple			   =					seq_length
								__UpperCamelCase	:   Optional[Any]			   =					is_training
								__UpperCamelCase	:   List[str]			   =					use_input_mask
								__UpperCamelCase	:   Union[str, Any]			   =					use_token_type_ids
								__UpperCamelCase	:   Any			   =					use_labels
								__UpperCamelCase	:   List[Any]			   =					vocab_size
								__UpperCamelCase	:   Any			   =					hidden_size
								__UpperCamelCase	:   Union[str, Any]			   =					num_hidden_layers
								__UpperCamelCase	:   Optional[int]			   =					num_attention_heads
								__UpperCamelCase	:   List[Any]			   =					intermediate_size
								__UpperCamelCase	:   Optional[int]			   =					hidden_act
								__UpperCamelCase	:   Optional[int]			   =					hidden_dropout_prob
								__UpperCamelCase	:   Any			   =					attention_probs_dropout_prob
								__UpperCamelCase	:   Optional[int]			   =					max_position_embeddings
								__UpperCamelCase	:   int			   =					type_vocab_size
								__UpperCamelCase	:   Optional[Any]			   =					type_sequence_label_size
								__UpperCamelCase	:   Any			   =					initializer_range
								__UpperCamelCase	:   Tuple			   =					num_labels
								__UpperCamelCase	:   Union[str, Any]			   =					num_choices
								__UpperCamelCase	:   Tuple			   =					relative_attention
								__UpperCamelCase	:   Any			   =					position_biased_input
								__UpperCamelCase	:   Any			   =					pos_att_type
								__UpperCamelCase	:   List[str]			   =					scope







	def    _lowerCamelCase				(					self		:Union[str, Any]						)		-> Dict:
								__UpperCamelCase	:   Union[str, Any]			   =					ids_tensor([self.batch_size, self.seq_length]     ,   self.vocab_size						)

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

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

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

								__UpperCamelCase	:   str			   =					self.get_config()

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







	def    _lowerCamelCase				(					self		:str						)		-> str:
								return DebertaVaConfig(
								    vocab_size=self.vocab_size     ,   hidden_size=self.hidden_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     ,   relative_attention=self.relative_attention     ,   position_biased_input=self.position_biased_input     ,   pos_att_type=self.pos_att_type     ,   )







	def    _lowerCamelCase				(					self		:str     ,   a		:Any						)		-> Optional[Any]:
								self.parent.assertListEqual(list(result.loss.size()						)     ,   []						)







	def    _lowerCamelCase				(					self		:str     ,   a		:List[Any]     ,   a		:str     ,   a		:Any     ,   a		:str     ,   a		:List[Any]     ,   a		:List[Any]     ,   a		:Dict						)		-> Optional[int]:
								__UpperCamelCase	:   Optional[Any]			   =					DebertaVaModel(config=a						)
								model.to(a						)
								model.eval()
								__UpperCamelCase	:   int			   =					model(a     ,   attention_mask=a     ,   token_type_ids=a						)[0]
								__UpperCamelCase	:   Tuple			   =					model(a     ,   token_type_ids=a						)[0]
								__UpperCamelCase	:   Any			   =					model(a						)[0]

								self.parent.assertListEqual(list(sequence_output.size()						)     ,   [self.batch_size, self.seq_length, self.hidden_size]						)







	def    _lowerCamelCase				(					self		:Optional[Any]     ,   a		:int     ,   a		:List[Any]     ,   a		:Optional[int]     ,   a		:Dict     ,   a		:Dict     ,   a		:Dict     ,   a		:str						)		-> Optional[int]:
								__UpperCamelCase	:   str			   =					DebertaVaForMaskedLM(config=a						)
								model.to(a						)
								model.eval()
								__UpperCamelCase	:   List[Any]			   =					model(a     ,   attention_mask=a     ,   token_type_ids=a     ,   labels=a						)

								self.parent.assertEqual(result.logits.shape     ,   (self.batch_size, self.seq_length, self.vocab_size)						)







	def    _lowerCamelCase				(					self		:Optional[Any]     ,   a		:str     ,   a		:Optional[int]     ,   a		:Dict     ,   a		:Tuple     ,   a		:Union[str, Any]     ,   a		:Any     ,   a		:Any						)		-> Union[str, Any]:
								__UpperCamelCase	:   Optional[int]			   =					self.num_labels
								__UpperCamelCase	:   Optional[int]			   =					DebertaVaForSequenceClassification(a						)
								model.to(a						)
								model.eval()
								__UpperCamelCase	:   Union[str, Any]			   =					model(a     ,   attention_mask=a     ,   token_type_ids=a     ,   labels=a						)
								self.parent.assertListEqual(list(result.logits.size()						)     ,   [self.batch_size, self.num_labels]						)
								self.check_loss_output(a						)







	def    _lowerCamelCase				(					self		:Optional[Any]     ,   a		:Union[str, Any]     ,   a		:List[str]     ,   a		:int     ,   a		:Dict     ,   a		:List[str]     ,   a		:Tuple     ,   a		:Optional[Any]						)		-> str:
								__UpperCamelCase	:   Tuple			   =					self.num_labels
								__UpperCamelCase	:   Any			   =					DebertaVaForTokenClassification(config=a						)
								model.to(a						)
								model.eval()
								__UpperCamelCase	:   Union[str, Any]			   =					model(a     ,   attention_mask=a     ,   token_type_ids=a     ,   labels=a						)
								self.parent.assertEqual(result.logits.shape     ,   (self.batch_size, self.seq_length, self.num_labels)						)







	def    _lowerCamelCase				(					self		:str     ,   a		:Dict     ,   a		:Union[str, Any]     ,   a		:str     ,   a		:int     ,   a		:Optional[Any]     ,   a		:Optional[Any]     ,   a		:List[Any]						)		-> List[str]:
								__UpperCamelCase	:   Union[str, Any]			   =					DebertaVaForQuestionAnswering(config=a						)
								model.to(a						)
								model.eval()
								__UpperCamelCase	:   Tuple			   =					model(
								    a     ,   attention_mask=a     ,   token_type_ids=a     ,   start_positions=a     ,   end_positions=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    _lowerCamelCase				(					self		:Optional[Any]     ,   a		:str     ,   a		:Tuple     ,   a		:Optional[Any]     ,   a		:Optional[Any]     ,   a		:Optional[int]     ,   a		:List[Any]     ,   a		:int						)		-> Dict:
								__UpperCamelCase	:   Tuple			   =					DebertaVaForMultipleChoice(config=a						)
								model.to(a						)
								model.eval()
								__UpperCamelCase	:   int			   =					input_ids.unsqueeze(1						).expand(-1     ,   self.num_choices     ,   -1						).contiguous()
								__UpperCamelCase	:   Tuple			   =					token_type_ids.unsqueeze(1						).expand(-1     ,   self.num_choices     ,   -1						).contiguous()
								__UpperCamelCase	:   Tuple			   =					input_mask.unsqueeze(1						).expand(-1     ,   self.num_choices     ,   -1						).contiguous()
								__UpperCamelCase	:   str			   =					model(
								    a     ,   attention_mask=a     ,   token_type_ids=a     ,   labels=a     ,   )
								self.parent.assertEqual(result.logits.shape     ,   (self.batch_size, self.num_choices)						)







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




@require_torch
class  lowerCamelCase__							(				__lowercase     ,						__lowercase     ,						unittest.TestCase):




	'''simple docstring'''




	_A								=     (
	    (
	        DebertaVaModel,
	        DebertaVaForMaskedLM,
	        DebertaVaForSequenceClassification,
	        DebertaVaForTokenClassification,
	        DebertaVaForQuestionAnswering,
	        DebertaVaForMultipleChoice,
	    )
	    if is_torch_available()
	    else ()
	)
	_A								=     (
	    {
	        'feature-extraction': DebertaVaModel,
	        'fill-mask': DebertaVaForMaskedLM,
	        'question-answering': DebertaVaForQuestionAnswering,
	        'text-classification': DebertaVaForSequenceClassification,
	        'token-classification': DebertaVaForTokenClassification,
	        'zero-shot': DebertaVaForSequenceClassification,
	    }
	    if is_torch_available()
	    else {}
	)

	_A								=     True
	_A								=     False
	_A								=     False
	_A								=     False
	_A								=     False







	def    _lowerCamelCase				(					self		:int						)		-> str:
								__UpperCamelCase	:   Dict			   =					DebertaVaModelTester(self						)
								__UpperCamelCase	:   Tuple			   =					ConfigTester(self     ,   config_class=a     ,   hidden_size=3_7						)







	def    _lowerCamelCase				(					self		:Tuple						)		-> List[str]:
								self.config_tester.run_common_tests()







	def    _lowerCamelCase				(					self		:Any						)		-> List[str]:
								__UpperCamelCase	:   List[Any]			   =					self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_deberta_model(*a						)







	def    _lowerCamelCase				(					self		:Any						)		-> Optional[int]:
								__UpperCamelCase	:   Optional[Any]			   =					self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_deberta_for_sequence_classification(*a						)







	def    _lowerCamelCase				(					self		:List[str]						)		-> str:
								__UpperCamelCase	:   Optional[Any]			   =					self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_deberta_for_masked_lm(*a						)







	def    _lowerCamelCase				(					self		:List[str]						)		-> int:
								__UpperCamelCase	:   List[Any]			   =					self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_deberta_for_question_answering(*a						)







	def    _lowerCamelCase				(					self		:List[str]						)		-> List[str]:
								__UpperCamelCase	:   Tuple			   =					self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_deberta_for_token_classification(*a						)







	def    _lowerCamelCase				(					self		:int						)		-> Optional[int]:
								__UpperCamelCase	:   str			   =					self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_deberta_for_multiple_choice(*a						)







	@slow
	def    _lowerCamelCase				(					self		:Optional[Any]						)		-> List[Any]:
								for model_name in DEBERTA_V2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
															__UpperCamelCase	:   Union[str, Any]			   =					DebertaVaModel.from_pretrained(a						)
															self.assertIsNotNone(a						)




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




	'''simple docstring'''




	@unittest.skip(reason="Model not available yet"						)
	def    _lowerCamelCase				(					self		:List[Any]						)		-> List[Any]:
								pass







	@slow
	def    _lowerCamelCase				(					self		:Optional[int]						)		-> List[str]:
								__UpperCamelCase	:   Union[str, Any]			   =					DebertaVaModel.from_pretrained("microsoft/deberta-v2-xlarge"						)

								__UpperCamelCase	:   Union[str, Any]			   =					torch.tensor([[0, 3_1_4_1_4, 2_3_2, 3_2_8, 7_4_0, 1_1_4_0, 1_2_6_9_5, 6_9, 4_6_0_7_8, 1_5_8_8, 2]]						)
								__UpperCamelCase	:   List[Any]			   =					torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]						)
								with torch.no_grad():
															__UpperCamelCase	:   Optional[Any]			   =					model(a     ,   attention_mask=a						)[0]
								# compare the actual values for a slice.
								__UpperCamelCase	:   List[Any]			   =					torch.tensor(
								    [[[0.2356, 0.1948, 0.0369], [-0.1063, 0.3586, -0.5152], [-0.6399, -0.0259, -0.2525]]]						)
								self.assertTrue(torch.allclose(output[:, 1:4, 1:4]     ,   a     ,   atol=1E-4						)     ,   f'{output[:, 1:4, 1:4]}'						)

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)