
"""simple docstring"""




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     lowercase(_lowercase       ):



     def __init__(							self     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE=1_3     ,				__SCREAMING_SNAKE_CASE=7     ,				__SCREAMING_SNAKE_CASE=True     ,				__SCREAMING_SNAKE_CASE=True     ,				__SCREAMING_SNAKE_CASE=True     ,				__SCREAMING_SNAKE_CASE=True     ,				__SCREAMING_SNAKE_CASE=9_9     ,				__SCREAMING_SNAKE_CASE=3_2     ,				__SCREAMING_SNAKE_CASE=5     ,				__SCREAMING_SNAKE_CASE=4     ,				__SCREAMING_SNAKE_CASE=3_7     ,				__SCREAMING_SNAKE_CASE="gelu"     ,				__SCREAMING_SNAKE_CASE=0.1     ,				__SCREAMING_SNAKE_CASE=0.1     ,				__SCREAMING_SNAKE_CASE=5_1_2     ,				__SCREAMING_SNAKE_CASE=1_6     ,				__SCREAMING_SNAKE_CASE=2     ,				__SCREAMING_SNAKE_CASE=0.02     ,				__SCREAMING_SNAKE_CASE=False     ,				__SCREAMING_SNAKE_CASE=True     ,				__SCREAMING_SNAKE_CASE="None"     ,				__SCREAMING_SNAKE_CASE=3     ,				__SCREAMING_SNAKE_CASE=4     ,				__SCREAMING_SNAKE_CASE=None     ,				)		->     Optional[Any]:







         """simple docstring"""



         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__		=			hidden_size
         a__		=			num_hidden_layers
         a__		=			num_attention_heads
         a__		=			intermediate_size
         a__		=			hidden_act
         a__		=			hidden_dropout_prob
         a__		=			attention_probs_dropout_prob
         a__		=			max_position_embeddings
         a__		=			type_vocab_size
         a__		=			type_sequence_label_size
         a__		=			initializer_range
         a__		=			num_labels
         a__		=			num_choices
         a__		=			relative_attention
         a__		=			position_biased_input
         a__		=			pos_att_type
         a__		=			scope



     def 			lowercase__  (							self   )		->     str:







         """simple docstring"""



         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__		=			self.get_config()

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



     def 			lowercase__  (							self   )		->     Optional[Any]:







         """simple docstring"""



         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 			lowercase__  (							self     ,				__SCREAMING_SNAKE_CASE   )		->     Tuple:







         """simple docstring"""



         self.parent.assertListEqual(list(result.loss.size()   )     ,				[]   )



     def 			lowercase__  (							self     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE   )		->     Any:







         """simple docstring"""



         a__		=			DebertaVaModel(config=__SCREAMING_SNAKE_CASE   )
         model.to(__SCREAMING_SNAKE_CASE   )
         model.eval()
         a__		=			model(__SCREAMING_SNAKE_CASE     ,				attention_mask=__SCREAMING_SNAKE_CASE     ,				token_type_ids=__SCREAMING_SNAKE_CASE   )[0]
         a__		=			model(__SCREAMING_SNAKE_CASE     ,				token_type_ids=__SCREAMING_SNAKE_CASE   )[0]
         a__		=			model(__SCREAMING_SNAKE_CASE   )[0]

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



     def 			lowercase__  (							self     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE   )		->     List[str]:







         """simple docstring"""



         a__		=			DebertaVaForMaskedLM(config=__SCREAMING_SNAKE_CASE   )
         model.to(__SCREAMING_SNAKE_CASE   )
         model.eval()
         a__		=			model(__SCREAMING_SNAKE_CASE     ,				attention_mask=__SCREAMING_SNAKE_CASE     ,				token_type_ids=__SCREAMING_SNAKE_CASE     ,				labels=__SCREAMING_SNAKE_CASE   )

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



     def 			lowercase__  (							self     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE   )		->     List[Any]:







         """simple docstring"""



         a__		=			self.num_labels
         a__		=			DebertaVaForSequenceClassification(__SCREAMING_SNAKE_CASE   )
         model.to(__SCREAMING_SNAKE_CASE   )
         model.eval()
         a__		=			model(__SCREAMING_SNAKE_CASE     ,				attention_mask=__SCREAMING_SNAKE_CASE     ,				token_type_ids=__SCREAMING_SNAKE_CASE     ,				labels=__SCREAMING_SNAKE_CASE   )
         self.parent.assertListEqual(list(result.logits.size()   )     ,				[self.batch_size, self.num_labels]   )
         self.check_loss_output(__SCREAMING_SNAKE_CASE   )



     def 			lowercase__  (							self     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE   )		->     str:







         """simple docstring"""



         a__		=			self.num_labels
         a__		=			DebertaVaForTokenClassification(config=__SCREAMING_SNAKE_CASE   )
         model.to(__SCREAMING_SNAKE_CASE   )
         model.eval()
         a__		=			model(__SCREAMING_SNAKE_CASE     ,				attention_mask=__SCREAMING_SNAKE_CASE     ,				token_type_ids=__SCREAMING_SNAKE_CASE     ,				labels=__SCREAMING_SNAKE_CASE   )
         self.parent.assertEqual(result.logits.shape     ,				(self.batch_size, self.seq_length, self.num_labels)   )



     def 			lowercase__  (							self     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE   )		->     Optional[Any]:







         """simple docstring"""



         a__		=			DebertaVaForQuestionAnswering(config=__SCREAMING_SNAKE_CASE   )
         model.to(__SCREAMING_SNAKE_CASE   )
         model.eval()
         a__		=			model(
             __SCREAMING_SNAKE_CASE     ,				attention_mask=__SCREAMING_SNAKE_CASE     ,				token_type_ids=__SCREAMING_SNAKE_CASE     ,				start_positions=__SCREAMING_SNAKE_CASE     ,				end_positions=__SCREAMING_SNAKE_CASE     ,				)
         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     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE   )		->     int:







         """simple docstring"""



         a__		=			DebertaVaForMultipleChoice(config=__SCREAMING_SNAKE_CASE   )
         model.to(__SCREAMING_SNAKE_CASE   )
         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(
             __SCREAMING_SNAKE_CASE     ,				attention_mask=__SCREAMING_SNAKE_CASE     ,				token_type_ids=__SCREAMING_SNAKE_CASE     ,				labels=__SCREAMING_SNAKE_CASE     ,				)
         self.parent.assertEqual(result.logits.shape     ,				(self.batch_size, self.num_choices)   )




     def 			lowercase__  (							self   )		->     List[str]:







         """simple docstring"""



         a__		=			self.prepare_config_and_inputs()
         (
             (
             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(_lowercase    ,						_lowercase    ,						unittest.TestCase       ):
     __snake_case:	Optional[Any]						=     (
         (
             DebertaVaModel,
             DebertaVaForMaskedLM,
             DebertaVaForSequenceClassification,
             DebertaVaForTokenClassification,
             DebertaVaForQuestionAnswering,
             DebertaVaForMultipleChoice,
         )
         if is_torch_available()
         else ()
     )
     __snake_case:	Tuple						=     (
         {
             'feature-extraction': DebertaVaModel,
             'fill-mask': DebertaVaForMaskedLM,
             'question-answering': DebertaVaForQuestionAnswering,
             'text-classification': DebertaVaForSequenceClassification,
             'token-classification': DebertaVaForTokenClassification,
             'zero-shot': DebertaVaForSequenceClassification,
         }
         if is_torch_available()
         else {}
     )

     __snake_case:	str						=     True
     __snake_case:	Union[str, Any]						=     False
     __snake_case:	Optional[Any]						=     False
     __snake_case:	List[str]						=     False
     __snake_case:	List[Any]						=     False



     def 			lowercase__  (							self   )		->     str:







         """simple docstring"""



         a__		=			DebertaVaModelTester(self   )
         a__		=			ConfigTester(self     ,				config_class=__SCREAMING_SNAKE_CASE     ,				hidden_size=3_7   )



     def 			lowercase__  (							self   )		->     Dict:







         """simple docstring"""



         self.config_tester.run_common_tests()



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







         """simple docstring"""



         a__		=			self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_deberta_model(*__SCREAMING_SNAKE_CASE   )



     def 			lowercase__  (							self   )		->     Dict:







         """simple docstring"""



         a__		=			self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_deberta_for_sequence_classification(*__SCREAMING_SNAKE_CASE   )



     def 			lowercase__  (							self   )		->     List[str]:







         """simple docstring"""



         a__		=			self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_deberta_for_masked_lm(*__SCREAMING_SNAKE_CASE   )



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







         """simple docstring"""



         a__		=			self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_deberta_for_question_answering(*__SCREAMING_SNAKE_CASE   )



     def 			lowercase__  (							self   )		->     Optional[Any]:







         """simple docstring"""



         a__		=			self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_deberta_for_token_classification(*__SCREAMING_SNAKE_CASE   )



     def 			lowercase__  (							self   )		->     str:







         """simple docstring"""



         a__		=			self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_deberta_for_multiple_choice(*__SCREAMING_SNAKE_CASE   )




     @slow
     def 			lowercase__  (							self   )		->     List[str]:







         """simple docstring"""



         for model_name in DEBERTA_V2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
             a__		=			DebertaVaModel.from_pretrained(__SCREAMING_SNAKE_CASE   )
             self.assertIsNotNone(__SCREAMING_SNAKE_CASE   )







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



     @unittest.skip(reason='Model not available yet'   )
     def 			lowercase__  (							self   )		->     Tuple:







         """simple docstring"""



         pass




     @slow
     def 			lowercase__  (							self   )		->     Dict:







         """simple docstring"""



         a__		=			DebertaVaModel.from_pretrained('microsoft/deberta-v2-xlarge'   )

         a__		=			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]]   )
         a__		=			torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]   )
         with torch.no_grad():
             a__		=			model(__SCREAMING_SNAKE_CASE     ,				attention_mask=__SCREAMING_SNAKE_CASE   )[0]
         # compare the actual values for a slice.
         a__		=			torch.tensor(
             [[[0.23_56, 0.19_48, 0.03_69], [-0.10_63, 0.35_86, -0.51_52], [-0.63_99, -0.02_59, -0.25_25]]]   )
         self.assertTrue(torch.allclose(output[:, 1:4, 1:4]     ,				__SCREAMING_SNAKE_CASE     ,				atol=1e-4   )     ,				f'{output[:, 1:4, 1:4]}'   )




"""simple docstring"""




from math import ceil



def     __magic_name__		(					UpperCamelCase     :		int = 1001     )     ->						int:
    a__		=			1

    for i in range(1							,		int(ceil(n / 2.0     )     )     ):
        a__		=			2 * i + 1
        a__		=			2 * i
        a__		=			total + 4 * odd**2 - 6 * even

    return total


if __name__ == "__main__":
    import sys

    if len(sys.argv) == 1:
        print(solution())
    else:
        try:
            a		:       Any     						=       int(sys.argv[1])
            print(solution(n))
        except ValueError:
            print('Invalid entry - please enter a number')


