


'''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   UpperCAmelCase_    (_UpperCAmelCase    ):





    """simple docstring"""






    def __init__(				self     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_=13     ,	SCREAMING_SNAKE_CASE_=7     ,	SCREAMING_SNAKE_CASE_=True     ,	SCREAMING_SNAKE_CASE_=True     ,	SCREAMING_SNAKE_CASE_=True     ,	SCREAMING_SNAKE_CASE_=True     ,	SCREAMING_SNAKE_CASE_=99     ,	SCREAMING_SNAKE_CASE_=32     ,	SCREAMING_SNAKE_CASE_=5     ,	SCREAMING_SNAKE_CASE_=4     ,	SCREAMING_SNAKE_CASE_=37     ,	SCREAMING_SNAKE_CASE_="gelu"     ,	SCREAMING_SNAKE_CASE_=0.1     ,	SCREAMING_SNAKE_CASE_=0.1     ,	SCREAMING_SNAKE_CASE_=5_12     ,	SCREAMING_SNAKE_CASE_=16     ,	SCREAMING_SNAKE_CASE_=2     ,	SCREAMING_SNAKE_CASE_=0.0_2     ,	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[int]:
         __lowerCamelCase  :      List[str]														=						parent
         __lowerCamelCase  :      List[Any]														=						batch_size
         __lowerCamelCase  :      Dict														=						seq_length
         __lowerCamelCase  :      int														=						is_training
         __lowerCamelCase  :      Any														=						use_input_mask
         __lowerCamelCase  :      int														=						use_token_type_ids
         __lowerCamelCase  :      Optional[int]														=						use_labels
         __lowerCamelCase  :      str														=						vocab_size
         __lowerCamelCase  :      List[str]														=						hidden_size
         __lowerCamelCase  :      Any														=						num_hidden_layers
         __lowerCamelCase  :      Dict														=						num_attention_heads
         __lowerCamelCase  :      int														=						intermediate_size
         __lowerCamelCase  :      int														=						hidden_act
         __lowerCamelCase  :      List[Any]														=						hidden_dropout_prob
         __lowerCamelCase  :      Optional[Any]														=						attention_probs_dropout_prob
         __lowerCamelCase  :      int														=						max_position_embeddings
         __lowerCamelCase  :      Dict														=						type_vocab_size
         __lowerCamelCase  :      str														=						type_sequence_label_size
         __lowerCamelCase  :      Any														=						initializer_range
         __lowerCamelCase  :      List[Any]														=						num_labels
         __lowerCamelCase  :      int														=						num_choices
         __lowerCamelCase  :      Union[str, Any]														=						relative_attention
         __lowerCamelCase  :      Optional[int]														=						position_biased_input
         __lowerCamelCase  :      Union[str, Any]														=						pos_att_type
         __lowerCamelCase  :      Optional[int]														=						scope







    def  lowercase_							(				self      )							->	Union[str, Any]:
         __lowerCamelCase  :      List[Any]														=						ids_tensor([self.batch_size, self.seq_length]     ,	self.vocab_size      )

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

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

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

         __lowerCamelCase  :      List[str]														=						self.get_config()

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







    def  lowercase_							(				self      )							->	Optional[int]:
         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_      )							->	Any:
         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:
         __lowerCamelCase  :      Union[str, Any]														=						DebertaVaModel(config=SCREAMING_SNAKE_CASE_      )
         model.to(SCREAMING_SNAKE_CASE_      )
         model.eval()
         __lowerCamelCase  :      List[Any]														=						model(SCREAMING_SNAKE_CASE_     ,	attention_mask=SCREAMING_SNAKE_CASE_     ,	token_type_ids=SCREAMING_SNAKE_CASE_      )[0]
         __lowerCamelCase  :      Any														=						model(SCREAMING_SNAKE_CASE_     ,	token_type_ids=SCREAMING_SNAKE_CASE_      )[0]
         __lowerCamelCase  :      str														=						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_      )							->	Tuple:
         __lowerCamelCase  :      Tuple														=						DebertaVaForMaskedLM(config=SCREAMING_SNAKE_CASE_      )
         model.to(SCREAMING_SNAKE_CASE_      )
         model.eval()
         __lowerCamelCase  :      List[str]														=						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_      )							->	Tuple:
         __lowerCamelCase  :      Union[str, Any]														=						self.num_labels
         __lowerCamelCase  :      Dict														=						DebertaVaForSequenceClassification(SCREAMING_SNAKE_CASE_      )
         model.to(SCREAMING_SNAKE_CASE_      )
         model.eval()
         __lowerCamelCase  :      int														=						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_      )							->	int:
         __lowerCamelCase  :      Dict														=						self.num_labels
         __lowerCamelCase  :      int														=						DebertaVaForTokenClassification(config=SCREAMING_SNAKE_CASE_      )
         model.to(SCREAMING_SNAKE_CASE_      )
         model.eval()
         __lowerCamelCase  :      Dict														=						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_      )							->	Dict:
         __lowerCamelCase  :      Tuple														=						DebertaVaForQuestionAnswering(config=SCREAMING_SNAKE_CASE_      )
         model.to(SCREAMING_SNAKE_CASE_      )
         model.eval()
         __lowerCamelCase  :      List[str]														=						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_      )							->	str:
         __lowerCamelCase  :      List[str]														=						DebertaVaForMultipleChoice(config=SCREAMING_SNAKE_CASE_      )
         model.to(SCREAMING_SNAKE_CASE_      )
         model.eval()
         __lowerCamelCase  :      Dict														=						input_ids.unsqueeze(1      ).expand(-1     ,	self.num_choices     ,	-1      ).contiguous()
         __lowerCamelCase  :      Any														=						token_type_ids.unsqueeze(1      ).expand(-1     ,	self.num_choices     ,	-1      ).contiguous()
         __lowerCamelCase  :      List[Any]														=						input_mask.unsqueeze(1      ).expand(-1     ,	self.num_choices     ,	-1      ).contiguous()
         __lowerCamelCase  :      Optional[Any]														=						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      )							->	Tuple:
         __lowerCamelCase  :      Tuple														=						self.prepare_config_and_inputs()
         (
             (
             __lowerCamelCase
         )							,			(
             __lowerCamelCase
         )							,			(
             __lowerCamelCase
         )							,			(
             __lowerCamelCase
         )							,			(
             __lowerCamelCase
         )							,			(
             __lowerCamelCase
         )							,			(
             __lowerCamelCase
         )							,			
         )  :      Optional[Any]														=						config_and_inputs
         __lowerCamelCase  :      List[str]														=						{'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
         return config, inputs_dict







@require_torch
class   UpperCAmelCase_    (_UpperCAmelCase   ,						_UpperCAmelCase   ,						unittest.TestCase    ):





    """simple docstring"""






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

    lowerCamelCase    :   Any					=     True
    lowerCamelCase    :   List[Any]					=     False
    lowerCamelCase    :   Union[str, Any]					=     False
    lowerCamelCase    :   Optional[int]					=     False
    lowerCamelCase    :   Dict					=     False







    def  lowercase_							(				self      )							->	str:
         __lowerCamelCase  :      Optional[int]														=						DebertaVaModelTester(self      )
         __lowerCamelCase  :      Union[str, Any]														=						ConfigTester(self     ,	config_class=SCREAMING_SNAKE_CASE_     ,	hidden_size=37      )







    def  lowercase_							(				self      )							->	Optional[Any]:
         self.config_tester.run_common_tests()







    def  lowercase_							(				self      )							->	Any:
         __lowerCamelCase  :      Tuple														=						self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_deberta_model(*SCREAMING_SNAKE_CASE_      )







    def  lowercase_							(				self      )							->	str:
         __lowerCamelCase  :      Tuple														=						self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_deberta_for_sequence_classification(*SCREAMING_SNAKE_CASE_      )







    def  lowercase_							(				self      )							->	Any:
         __lowerCamelCase  :      int														=						self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_deberta_for_masked_lm(*SCREAMING_SNAKE_CASE_      )







    def  lowercase_							(				self      )							->	Any:
         __lowerCamelCase  :      Optional[Any]														=						self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_deberta_for_question_answering(*SCREAMING_SNAKE_CASE_      )







    def  lowercase_							(				self      )							->	int:
         __lowerCamelCase  :      Tuple														=						self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_deberta_for_token_classification(*SCREAMING_SNAKE_CASE_      )







    def  lowercase_							(				self      )							->	Any:
         __lowerCamelCase  :      Optional[Any]														=						self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_deberta_for_multiple_choice(*SCREAMING_SNAKE_CASE_      )







    @slow
    def  lowercase_							(				self      )							->	Dict:
         for model_name in DEBERTA_V2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
              __lowerCamelCase  :      str														=						DebertaVaModel.from_pretrained(SCREAMING_SNAKE_CASE_      )
              self.assertIsNotNone(SCREAMING_SNAKE_CASE_      )







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





    """simple docstring"""






    @unittest.skip(reason='Model not available yet'      )
    def  lowercase_							(				self      )							->	int:
         pass







    @slow
    def  lowercase_							(				self      )							->	Union[str, Any]:
         __lowerCamelCase  :      Dict														=						DebertaVaModel.from_pretrained('microsoft/deberta-v2-xlarge'      )

         __lowerCamelCase  :      Optional[Any]														=						torch.tensor([[0, 3_14_14, 2_32, 3_28, 7_40, 11_40, 1_26_95, 69, 4_60_78, 15_88, 2]]      )
         __lowerCamelCase  :      Tuple														=						torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]      )
         with torch.no_grad():
              __lowerCamelCase  :      Tuple														=						model(SCREAMING_SNAKE_CASE_     ,	attention_mask=SCREAMING_SNAKE_CASE_      )[0]
         # compare the actual values for a slice.
         __lowerCamelCase  :      Any														=						torch.tensor(
             [[[0.2_3_5_6, 0.1_9_4_8, 0.0_3_6_9], [-0.1_0_6_3, 0.3_5_8_6, -0.5_1_5_2], [-0.6_3_9_9, -0.0_2_5_9, -0.2_5_2_5]]]      )
         self.assertTrue(torch.allclose(output[:, 1:4, 1:4]     ,	SCREAMING_SNAKE_CASE_     ,	atol=1E-4      )     ,	f'{output[:, 1:4, 1:4]}'      )










'''simple docstring'''



def      UpperCAmelCase__   (      UpperCAmelCase_       :							int = 10_00				)	->						int:
     __lowerCamelCase  :      Union[str, Any]														=						3
     __lowerCamelCase  :      Dict														=						0
     while a < n:
          if a % 3 == 0 or a % 5 == 0:
               result += a
          elif a % 15 == 0:
               result -= a
          a += 1
     return result


if __name__ == "__main__":
      print(f'''{solution() = }''')






