





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



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







      """simple docstring"""
      lowercase     :      Tuple	=							parent
      lowercase     :      int	=							batch_size
      lowercase     :      List[str]	=							seq_length
      lowercase     :      str	=							is_training
      lowercase     :      Union[str, Any]	=							use_input_mask
      lowercase     :      Optional[int]	=							use_token_type_ids
      lowercase     :      str	=							use_labels
      lowercase     :      int	=							vocab_size
      lowercase     :      Any	=							hidden_size
      lowercase     :      List[str]	=							num_hidden_layers
      lowercase     :      Optional[int]	=							num_attention_heads
      lowercase     :      Dict	=							intermediate_size
      lowercase     :      Dict	=							hidden_act
      lowercase     :      Dict	=							hidden_dropout_prob
      lowercase     :      List[Any]	=							attention_probs_dropout_prob
      lowercase     :      List[str]	=							max_position_embeddings
      lowercase     :      Union[str, Any]	=							type_vocab_size
      lowercase     :      Optional[Any]	=							type_sequence_label_size
      lowercase     :      List[Any]	=							initializer_range
      lowercase     :      Optional[Any]	=							num_labels
      lowercase     :      Optional[Any]	=							num_choices
      lowercase     :      Optional[int]	=							relative_attention
      lowercase     :      str	=							position_biased_input
      lowercase     :      Dict	=							pos_att_type
      lowercase     :      List[str]	=							scope



   def  _UpperCAmelCase						(							self						)			->     Any:







      """simple docstring"""
      lowercase     :      List[Any]	=							ids_tensor([self.batch_size, self.seq_length]   , self.vocab_size						)

      lowercase     :      int	=							None
      if self.use_input_mask:
         lowercase     :      Union[str, Any]	=							ids_tensor([self.batch_size, self.seq_length]   , vocab_size=2						)

      lowercase     :      Optional[int]	=							None
      if self.use_token_type_ids:
         lowercase     :      Tuple	=							ids_tensor([self.batch_size, self.seq_length]   , self.type_vocab_size						)

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

      lowercase     :      str	=							self.get_config()

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



   def  _UpperCAmelCase						(							self						)			->     Optional[int]:







      """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  _UpperCAmelCase						(							self   , snake_case						)			->     List[str]:







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



   def  _UpperCAmelCase						(							self   , snake_case   , snake_case   , snake_case   , snake_case   , snake_case   , snake_case   , snake_case						)			->     List[Any]:







      """simple docstring"""
      lowercase     :      Optional[int]	=							DebertaVaModel(config=__lowerCamelCase						)
      model.to(__lowerCamelCase						)
      model.eval()
      lowercase     :      int	=							model(__lowerCamelCase   , attention_mask=__lowerCamelCase   , token_type_ids=__lowerCamelCase						)[0]
      lowercase     :      str	=							model(__lowerCamelCase   , token_type_ids=__lowerCamelCase						)[0]
      lowercase     :      Tuple	=							model(__lowerCamelCase						)[0]

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



   def  _UpperCAmelCase						(							self   , snake_case   , snake_case   , snake_case   , snake_case   , snake_case   , snake_case   , snake_case						)			->     Dict:







      """simple docstring"""
      lowercase     :      str	=							DebertaVaForMaskedLM(config=__lowerCamelCase						)
      model.to(__lowerCamelCase						)
      model.eval()
      lowercase     :      Dict	=							model(__lowerCamelCase   , attention_mask=__lowerCamelCase   , token_type_ids=__lowerCamelCase   , labels=__lowerCamelCase						)

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



   def  _UpperCAmelCase						(							self   , snake_case   , snake_case   , snake_case   , snake_case   , snake_case   , snake_case   , snake_case						)			->     int:







      """simple docstring"""
      lowercase     :      str	=							self.num_labels
      lowercase     :      Union[str, Any]	=							DebertaVaForSequenceClassification(__lowerCamelCase						)
      model.to(__lowerCamelCase						)
      model.eval()
      lowercase     :      Optional[int]	=							model(__lowerCamelCase   , attention_mask=__lowerCamelCase   , token_type_ids=__lowerCamelCase   , labels=__lowerCamelCase						)
      self.parent.assertListEqual(list(result.logits.size()						)   , [self.batch_size, self.num_labels]						)
      self.check_loss_output(__lowerCamelCase						)



   def  _UpperCAmelCase						(							self   , snake_case   , snake_case   , snake_case   , snake_case   , snake_case   , snake_case   , snake_case						)			->     Optional[int]:







      """simple docstring"""
      lowercase     :      List[Any]	=							self.num_labels
      lowercase     :      int	=							DebertaVaForTokenClassification(config=__lowerCamelCase						)
      model.to(__lowerCamelCase						)
      model.eval()
      lowercase     :      str	=							model(__lowerCamelCase   , attention_mask=__lowerCamelCase   , token_type_ids=__lowerCamelCase   , labels=__lowerCamelCase						)
      self.parent.assertEqual(result.logits.shape   , (self.batch_size, self.seq_length, self.num_labels)						)



   def  _UpperCAmelCase						(							self   , snake_case   , snake_case   , snake_case   , snake_case   , snake_case   , snake_case   , snake_case						)			->     List[Any]:







      """simple docstring"""
      lowercase     :      Tuple	=							DebertaVaForQuestionAnswering(config=__lowerCamelCase						)
      model.to(__lowerCamelCase						)
      model.eval()
      lowercase     :      Any	=							model(
          __lowerCamelCase   , attention_mask=__lowerCamelCase   , token_type_ids=__lowerCamelCase   , start_positions=__lowerCamelCase   , end_positions=__lowerCamelCase   , )
      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  _UpperCAmelCase						(							self   , snake_case   , snake_case   , snake_case   , snake_case   , snake_case   , snake_case   , snake_case						)			->     Union[str, Any]:







      """simple docstring"""
      lowercase     :      int	=							DebertaVaForMultipleChoice(config=__lowerCamelCase						)
      model.to(__lowerCamelCase						)
      model.eval()
      lowercase     :      Any	=							input_ids.unsqueeze(1						).expand(-1   , self.num_choices   , -1						).contiguous()
      lowercase     :      Tuple	=							token_type_ids.unsqueeze(1						).expand(-1   , self.num_choices   , -1						).contiguous()
      lowercase     :      int	=							input_mask.unsqueeze(1						).expand(-1   , self.num_choices   , -1						).contiguous()
      lowercase     :      List[str]	=							model(
          __lowerCamelCase   , attention_mask=__lowerCamelCase   , token_type_ids=__lowerCamelCase   , labels=__lowerCamelCase   , )
      self.parent.assertEqual(result.logits.shape   , (self.batch_size, self.num_choices)						)





   def  _UpperCAmelCase						(							self						)			->     Dict:







      """simple docstring"""
      lowercase     :      Any	=							self.prepare_config_and_inputs()
      (
          (
          lowercase	
      )	,       (
          lowercase	
      )	,       (
          lowercase	
      )	,       (
          lowercase	
      )	,       (
          lowercase	
      )	,       (
          lowercase	
      )	,       (
          lowercase	
      )	,       	
      )     :      Optional[int]	=							config_and_inputs
      lowercase     :      Union[str, Any]	=							{"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
      return config, inputs_dict




@require_torch
class lowerCamelCase__	(     __snake_case	,					__snake_case	,					unittest.TestCase					):
   __UpperCAmelCase										=       (
       (
           DebertaVaModel,
           DebertaVaForMaskedLM,
           DebertaVaForSequenceClassification,
           DebertaVaForTokenClassification,
           DebertaVaForQuestionAnswering,
           DebertaVaForMultipleChoice,
       )
       if is_torch_available()
       else ()
   )
   __UpperCAmelCase										=       (
       {
           """feature-extraction""": DebertaVaModel,
           """fill-mask""": DebertaVaForMaskedLM,
           """question-answering""": DebertaVaForQuestionAnswering,
           """text-classification""": DebertaVaForSequenceClassification,
           """token-classification""": DebertaVaForTokenClassification,
           """zero-shot""": DebertaVaForSequenceClassification,
       }
       if is_torch_available()
       else {}
   )

   __UpperCAmelCase										=       True
   __UpperCAmelCase										=       False
   __UpperCAmelCase										=       False
   __UpperCAmelCase										=       False
   __UpperCAmelCase										=       False



   def  _UpperCAmelCase						(							self						)			->     Dict:







      """simple docstring"""
      lowercase     :      Dict	=							DebertaVaModelTester(self						)
      lowercase     :      str	=							ConfigTester(self   , config_class=__lowerCamelCase   , hidden_size=3_7						)



   def  _UpperCAmelCase						(							self						)			->     Any:







      """simple docstring"""
      self.config_tester.run_common_tests()



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







      """simple docstring"""
      lowercase     :      int	=							self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_deberta_model(*__lowerCamelCase						)



   def  _UpperCAmelCase						(							self						)			->     Any:







      """simple docstring"""
      lowercase     :      str	=							self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_deberta_for_sequence_classification(*__lowerCamelCase						)



   def  _UpperCAmelCase						(							self						)			->     Any:







      """simple docstring"""
      lowercase     :      Optional[Any]	=							self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_deberta_for_masked_lm(*__lowerCamelCase						)



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







      """simple docstring"""
      lowercase     :      Dict	=							self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_deberta_for_question_answering(*__lowerCamelCase						)



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







      """simple docstring"""
      lowercase     :      List[str]	=							self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_deberta_for_token_classification(*__lowerCamelCase						)



   def  _UpperCAmelCase						(							self						)			->     str:







      """simple docstring"""
      lowercase     :      Dict	=							self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_deberta_for_multiple_choice(*__lowerCamelCase						)





   @slow
   def  _UpperCAmelCase						(							self						)			->     Optional[Any]:







      """simple docstring"""
      for model_name in DEBERTA_V2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
         lowercase     :      Optional[int]	=							DebertaVaModel.from_pretrained(__lowerCamelCase						)
         self.assertIsNotNone(__lowerCamelCase						)




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



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







      """simple docstring"""
      pass





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







      """simple docstring"""
      lowercase     :      Optional[Any]	=							DebertaVaModel.from_pretrained("""microsoft/deberta-v2-xlarge"""						)

      lowercase     :      Optional[int]	=							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]]						)
      lowercase     :      Union[str, Any]	=							torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]						)
      with torch.no_grad():
         lowercase     :      Optional[Any]	=							model(__lowerCamelCase   , attention_mask=__lowerCamelCase						)[0]
      # compare the actual values for a slice.
      lowercase     :      int	=							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]   , __lowerCamelCase   , atol=1E-4						)   , f'''{output[:, 1:4, 1:4]}'''						)





import os





def 	__a     (      ):
    SCREAMING_SNAKE_CASE										=   os.path.join(os.path.dirname(A__       )			,  "num.txt"       )
    with open(A__       ) as file_hand:
        return str(sum(int(A__       ) for line in file_hand       )       )[:10]


if __name__ == "__main__":
    print(solution())