



"""simple docstring"""
import json
import os
import re
import unittest

from transformers import CodeGenTokenizer, CodeGenTokenizerFast
from transformers.models.codegen.tokenization_codegen import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin


@require_tokenizers
class    SCREAMING_SNAKE_CASE__ (							__a      ,  unittest.TestCase   ):
    lowercase__      =   CodeGenTokenizer
    lowercase__      =   CodeGenTokenizerFast
    lowercase__      =   True
    lowercase__      =   {"add_prefix_space": True}
    lowercase__      =   False

    def 					_UpperCAmelCase	(				self			:				Dict):







      """simple docstring"""







      super().setUp()

      # Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
      lowercase_								= [
          """l""",
          """o""",
          """w""",
          """e""",
          """r""",
          """s""",
          """t""",
          """i""",
          """d""",
          """n""",
          """\u0120""",
          """\u0120l""",
          """\u0120n""",
          """\u0120lo""",
          """\u0120low""",
          """er""",
          """\u0120lowest""",
          """\u0120newer""",
          """\u0120wider""",
          """<unk>""",
          """<|endoftext|>""",
      ]
      lowercase_								= dict(zip(A__ ,  range(len(A__))))
      lowercase_								= ["""#version: 0.2""", """\u0120 l""", """\u0120l o""", """\u0120lo w""", """e r""", """"""]
      lowercase_								= {"""unk_token""": """<unk>"""}

      lowercase_								= os.path.join(self.tmpdirname ,  VOCAB_FILES_NAMES["""vocab_file"""])
      lowercase_								= os.path.join(self.tmpdirname ,  VOCAB_FILES_NAMES["""merges_file"""])
      with open(self.vocab_file ,  """w""" ,  encoding="""utf-8""") as fp:
        fp.write(json.dumps(A__) + """\n""")
      with open(self.merges_file ,  """w""" ,  encoding="""utf-8""") as fp:
        fp.write("""\n""".join(A__))

    def 					_UpperCAmelCase	(				self			:				Optional[Any] ,  **lowerCAmelCase_			:				Optional[int]):







      """simple docstring"""







      kwargs.update(self.special_tokens_map)
      return CodeGenTokenizer.from_pretrained(self.tmpdirname ,  **A__)

    def 					_UpperCAmelCase	(				self			:				List[Any] ,  **lowerCAmelCase_			:				Tuple):







      """simple docstring"""







      kwargs.update(self.special_tokens_map)
      return CodeGenTokenizerFast.from_pretrained(self.tmpdirname ,  **A__)

    def 					_UpperCAmelCase	(				self			:				List[Any] ,  lowerCAmelCase_			:				Any):







      """simple docstring"""







      lowercase_								= """lower newer"""
      lowercase_								= """lower newer"""
      return input_text, output_text

    def 					_UpperCAmelCase	(				self			:				Dict):







      """simple docstring"""







      lowercase_								= CodeGenTokenizer(self.vocab_file ,  self.merges_file ,  **self.special_tokens_map)
      lowercase_								= """lower newer"""
      lowercase_								= ["""\u0120low""", """er""", """\u0120""", """n""", """e""", """w""", """er"""]
      lowercase_								= tokenizer.tokenize(A__ ,  add_prefix_space=A__)
      self.assertListEqual(A__ ,  A__)

      lowercase_								= tokens + [tokenizer.unk_token]
      lowercase_								= [1_4, 1_5, 1_0, 9, 3, 2, 1_5, 1_9]
      self.assertListEqual(tokenizer.convert_tokens_to_ids(A__) ,  A__)

    def 					_UpperCAmelCase	(				self			:				int):







      """simple docstring"""







      if not self.test_rust_tokenizer:
        return

      lowercase_								= self.get_tokenizer()
      lowercase_								= self.get_rust_tokenizer(add_prefix_space=A__)

      lowercase_								= """lower newer"""

      # Testing tokenization
      lowercase_								= tokenizer.tokenize(A__ ,  add_prefix_space=A__)
      lowercase_								= rust_tokenizer.tokenize(A__)
      self.assertListEqual(A__ ,  A__)

      # Testing conversion to ids without special tokens
      lowercase_								= tokenizer.encode(A__ ,  add_special_tokens=A__ ,  add_prefix_space=A__)
      lowercase_								= rust_tokenizer.encode(A__ ,  add_special_tokens=A__)
      self.assertListEqual(A__ ,  A__)

      # Testing conversion to ids with special tokens
      lowercase_								= self.get_rust_tokenizer(add_prefix_space=A__)
      lowercase_								= tokenizer.encode(A__ ,  add_prefix_space=A__)
      lowercase_								= rust_tokenizer.encode(A__)
      self.assertListEqual(A__ ,  A__)

      # Testing the unknown token
      lowercase_								= tokens + [rust_tokenizer.unk_token]
      lowercase_								= [1_4, 1_5, 1_0, 9, 3, 2, 1_5, 1_9]
      self.assertListEqual(rust_tokenizer.convert_tokens_to_ids(A__) ,  A__)

    def 					_UpperCAmelCase	(				self			:				Dict ,  *lowerCAmelCase_			:				Union[str, Any] ,  **lowerCAmelCase_			:				Dict):







      """simple docstring"""







      pass

    def 					_UpperCAmelCase	(				self			:				Union[str, Any] ,  lowerCAmelCase_			:				Union[str, Any]=1_5):







      """simple docstring"""







      for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
        with self.subTest(F'''{tokenizer.__class__.__name__} ({pretrained_name})'''):
          lowercase_								= self.rust_tokenizer_class.from_pretrained(A__ ,  **A__)

          # Simple input
          lowercase_								= """This is a simple input"""
          lowercase_								= ["""This is a simple input 1""", """This is a simple input 2"""]
          lowercase_								= ("""This is a simple input""", """This is a pair""")
          lowercase_								= [
              ("""This is a simple input 1""", """This is a simple input 2"""),
              ("""This is a simple pair 1""", """This is a simple pair 2"""),
          ]

          # Simple input tests
          self.assertRaises(A__ ,  tokenizer_r.encode ,  A__ ,  max_length=A__ ,  padding="""max_length""")

          # Simple input
          self.assertRaises(A__ ,  tokenizer_r.encode_plus ,  A__ ,  max_length=A__ ,  padding="""max_length""")

          # Simple input
          self.assertRaises(
              A__ ,  tokenizer_r.batch_encode_plus ,  A__ ,  max_length=A__ ,  padding="""max_length""" ,  )

          # Pair input
          self.assertRaises(A__ ,  tokenizer_r.encode ,  A__ ,  max_length=A__ ,  padding="""max_length""")

          # Pair input
          self.assertRaises(A__ ,  tokenizer_r.encode_plus ,  A__ ,  max_length=A__ ,  padding="""max_length""")

          # Pair input
          self.assertRaises(
              A__ ,  tokenizer_r.batch_encode_plus ,  A__ ,  max_length=A__ ,  padding="""max_length""" ,  )

    def 					_UpperCAmelCase	(				self			:				Tuple):







      """simple docstring"""







      lowercase_								= CodeGenTokenizer.from_pretrained(self.tmpdirname ,  pad_token="""<pad>""")

      # Simple input
      lowercase_								= """This is a simple input"""
      lowercase_								= ["""This is a simple input looooooooong""", """This is a simple input"""]
      lowercase_								= ("""This is a simple input""", """This is a pair""")
      lowercase_								= [
          ("""This is a simple input loooooong""", """This is a simple input"""),
          ("""This is a simple pair loooooong""", """This is a simple pair"""),
      ]

      lowercase_								= tokenizer.pad_token_id

      lowercase_								= tokenizer(A__ ,  padding="""max_length""" ,  max_length=3_0 ,  return_tensors="""np""")
      lowercase_								= tokenizer(A__ ,  padding=A__ ,  truncate=A__ ,  return_tensors="""np""")
      lowercase_								= tokenizer(*A__ ,  padding="""max_length""" ,  max_length=6_0 ,  return_tensors="""np""")
      lowercase_								= tokenizer(A__ ,  padding=A__ ,  truncate=A__ ,  return_tensors="""np""")

      # s
      # test single string max_length padding
      self.assertEqual(out_s["""input_ids"""].shape[-1] ,  3_0)
      self.assertTrue(pad_token_id in out_s["""input_ids"""])
      self.assertTrue(0 in out_s["""attention_mask"""])

      # s2
      # test automatic padding
      self.assertEqual(out_sa["""input_ids"""].shape[-1] ,  3_3)
      # long slice doesn't have padding
      self.assertFalse(pad_token_id in out_sa["""input_ids"""][0])
      self.assertFalse(0 in out_sa["""attention_mask"""][0])
      # short slice does have padding
      self.assertTrue(pad_token_id in out_sa["""input_ids"""][1])
      self.assertTrue(0 in out_sa["""attention_mask"""][1])

      # p
      # test single pair max_length padding
      self.assertEqual(out_p["""input_ids"""].shape[-1] ,  6_0)
      self.assertTrue(pad_token_id in out_p["""input_ids"""])
      self.assertTrue(0 in out_p["""attention_mask"""])

      # p2
      # test automatic padding pair
      self.assertEqual(out_pa["""input_ids"""].shape[-1] ,  5_2)
      # long slice pair doesn't have padding
      self.assertFalse(pad_token_id in out_pa["""input_ids"""][0])
      self.assertFalse(0 in out_pa["""attention_mask"""][0])
      # short slice pair does have padding
      self.assertTrue(pad_token_id in out_pa["""input_ids"""][1])
      self.assertTrue(0 in out_pa["""attention_mask"""][1])

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







      """simple docstring"""







      lowercase_								= """$$$"""
      lowercase_								= CodeGenTokenizer.from_pretrained(self.tmpdirname ,  bos_token=A__ ,  add_bos_token=A__)

      lowercase_								= """This is a simple input"""
      lowercase_								= ["""This is a simple input 1""", """This is a simple input 2"""]

      lowercase_								= tokenizer.bos_token_id

      lowercase_								= tokenizer(A__)
      lowercase_								= tokenizer(A__)

      self.assertEqual(out_s.input_ids[0] ,  A__)
      self.assertTrue(all(o[0] == bos_token_id for o in out_sa.input_ids))

      lowercase_								= tokenizer.decode(out_s.input_ids)
      lowercase_								= tokenizer.batch_decode(out_sa.input_ids)

      self.assertEqual(decode_s.split()[0] ,  A__)
      self.assertTrue(all(d.split()[0] == bos_token for d in decode_sa))

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







      """simple docstring"""







      lowercase_								= CodeGenTokenizer.from_pretrained("""Salesforce/codegen-350M-mono""")

      lowercase_								= """\nif len_a > len_b:\n    result = a\nelse:\n    result = b\n\n\n\n#"""
      lowercase_								= """\nif len_a > len_b:      result = a\nelse:      result = b"""

      lowercase_								= tokenizer.encode(A__)
      lowercase_								= ["""^#""", re.escape("""<|endoftext|>"""), """^\'\'\'""", """^\"\"\"""", """\n\n\n"""]
      lowercase_								= tokenizer.decode(A__ ,  truncate_before_pattern=A__)
      self.assertEqual(A__ ,  A__)




    def 					_UpperCAmelCase	(				self			:				List[Any]):







      """simple docstring"""







      pass






"""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    SCREAMING_SNAKE_CASE__ (							__UpperCAmelCase   ):

    def __init__(				self			:				Union[str, Any] ,  lowerCAmelCase_			:				int ,  lowerCAmelCase_			:				Optional[int]=1_3 ,  lowerCAmelCase_			:				Union[str, Any]=7 ,  lowerCAmelCase_			:				int=True ,  lowerCAmelCase_			:				Optional[int]=True ,  lowerCAmelCase_			:				List[Any]=True ,  lowerCAmelCase_			:				Tuple=True ,  lowerCAmelCase_			:				Dict=9_9 ,  lowerCAmelCase_			:				List[str]=3_2 ,  lowerCAmelCase_			:				Tuple=5 ,  lowerCAmelCase_			:				str=4 ,  lowerCAmelCase_			:				List[str]=3_7 ,  lowerCAmelCase_			:				List[str]="gelu" ,  lowerCAmelCase_			:				Optional[Any]=0.1 ,  lowerCAmelCase_			:				Union[str, Any]=0.1 ,  lowerCAmelCase_			:				List[str]=5_1_2 ,  lowerCAmelCase_			:				Union[str, Any]=1_6 ,  lowerCAmelCase_			:				List[Any]=2 ,  lowerCAmelCase_			:				Dict=0.02 ,  lowerCAmelCase_			:				int=False ,  lowerCAmelCase_			:				Any=True ,  lowerCAmelCase_			:				Tuple="None" ,  lowerCAmelCase_			:				int=3 ,  lowerCAmelCase_			:				Union[str, Any]=4 ,  lowerCAmelCase_			:				Dict=None ,  ):







      """simple docstring"""







      lowercase_								= parent
      lowercase_								= batch_size
      lowercase_								= seq_length
      lowercase_								= is_training
      lowercase_								= use_input_mask
      lowercase_								= use_token_type_ids
      lowercase_								= use_labels
      lowercase_								= vocab_size
      lowercase_								= hidden_size
      lowercase_								= num_hidden_layers
      lowercase_								= num_attention_heads
      lowercase_								= intermediate_size
      lowercase_								= hidden_act
      lowercase_								= hidden_dropout_prob
      lowercase_								= attention_probs_dropout_prob
      lowercase_								= max_position_embeddings
      lowercase_								= type_vocab_size
      lowercase_								= type_sequence_label_size
      lowercase_								= initializer_range
      lowercase_								= num_labels
      lowercase_								= num_choices
      lowercase_								= relative_attention
      lowercase_								= position_biased_input
      lowercase_								= pos_att_type
      lowercase_								= scope

    def 					_UpperCAmelCase	(				self			:				Any):







      """simple docstring"""







      lowercase_								= ids_tensor([self.batch_size, self.seq_length] ,  self.vocab_size)

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

      lowercase_								= None
      if self.use_token_type_ids:
        lowercase_								= ids_tensor([self.batch_size, self.seq_length] ,  self.type_vocab_size)

      lowercase_								= None
      lowercase_								= None
      lowercase_								= None
      if self.use_labels:
        lowercase_								= ids_tensor([self.batch_size] ,  self.type_sequence_label_size)
        lowercase_								= ids_tensor([self.batch_size, self.seq_length] ,  self.num_labels)
        lowercase_								= ids_tensor([self.batch_size] ,  self.num_choices)

      lowercase_								= self.get_config()

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

    def 					_UpperCAmelCase	(				self			:				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			:				Tuple ,  lowerCAmelCase_			:				Dict):







      """simple docstring"""







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

    def 					_UpperCAmelCase	(				self			:				Any ,  lowerCAmelCase_			:				int ,  lowerCAmelCase_			:				Optional[Any] ,  lowerCAmelCase_			:				List[Any] ,  lowerCAmelCase_			:				Dict ,  lowerCAmelCase_			:				Tuple ,  lowerCAmelCase_			:				Union[str, Any] ,  lowerCAmelCase_			:				List[str]):







      """simple docstring"""







      lowercase_								= DebertaVaModel(config=lowerCAmelCase_)
      model.to(lowerCAmelCase_)
      model.eval()
      lowercase_								= model(lowerCAmelCase_ ,  attention_mask=lowerCAmelCase_ ,  token_type_ids=lowerCAmelCase_)[0]
      lowercase_								= model(lowerCAmelCase_ ,  token_type_ids=lowerCAmelCase_)[0]
      lowercase_								= model(lowerCAmelCase_)[0]

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

    def 					_UpperCAmelCase	(				self			:				Optional[Any] ,  lowerCAmelCase_			:				str ,  lowerCAmelCase_			:				str ,  lowerCAmelCase_			:				int ,  lowerCAmelCase_			:				Tuple ,  lowerCAmelCase_			:				Dict ,  lowerCAmelCase_			:				List[str] ,  lowerCAmelCase_			:				Union[str, Any]):







      """simple docstring"""







      lowercase_								= DebertaVaForMaskedLM(config=lowerCAmelCase_)
      model.to(lowerCAmelCase_)
      model.eval()
      lowercase_								= 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			:				Any ,  lowerCAmelCase_			:				List[str] ,  lowerCAmelCase_			:				List[str] ,  lowerCAmelCase_			:				List[Any] ,  lowerCAmelCase_			:				Optional[Any] ,  lowerCAmelCase_			:				str ,  lowerCAmelCase_			:				Tuple ,  lowerCAmelCase_			:				Tuple):







      """simple docstring"""







      lowercase_								= self.num_labels
      lowercase_								= DebertaVaForSequenceClassification(lowerCAmelCase_)
      model.to(lowerCAmelCase_)
      model.eval()
      lowercase_								= 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			:				List[str] ,  lowerCAmelCase_			:				Any ,  lowerCAmelCase_			:				List[str] ,  lowerCAmelCase_			:				Union[str, Any] ,  lowerCAmelCase_			:				Tuple ,  lowerCAmelCase_			:				Optional[int] ,  lowerCAmelCase_			:				Union[str, Any] ,  lowerCAmelCase_			:				Any):







      """simple docstring"""







      lowercase_								= self.num_labels
      lowercase_								= DebertaVaForTokenClassification(config=lowerCAmelCase_)
      model.to(lowerCAmelCase_)
      model.eval()
      lowercase_								= 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			:				str ,  lowerCAmelCase_			:				Tuple ,  lowerCAmelCase_			:				Union[str, Any] ,  lowerCAmelCase_			:				Dict ,  lowerCAmelCase_			:				List[str] ,  lowerCAmelCase_			:				str ,  lowerCAmelCase_			:				Tuple ,  lowerCAmelCase_			:				Dict):







      """simple docstring"""







      lowercase_								= DebertaVaForQuestionAnswering(config=lowerCAmelCase_)
      model.to(lowerCAmelCase_)
      model.eval()
      lowercase_								= 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			:				Tuple ,  lowerCAmelCase_			:				Union[str, Any] ,  lowerCAmelCase_			:				Dict ,  lowerCAmelCase_			:				str ,  lowerCAmelCase_			:				str ,  lowerCAmelCase_			:				Optional[int] ,  lowerCAmelCase_			:				List[str] ,  lowerCAmelCase_			:				Optional[Any]):







      """simple docstring"""







      lowercase_								= DebertaVaForMultipleChoice(config=lowerCAmelCase_)
      model.to(lowerCAmelCase_)
      model.eval()
      lowercase_								= input_ids.unsqueeze(1).expand(-1 ,  self.num_choices ,  -1).contiguous()
      lowercase_								= token_type_ids.unsqueeze(1).expand(-1 ,  self.num_choices ,  -1).contiguous()
      lowercase_								= input_mask.unsqueeze(1).expand(-1 ,  self.num_choices ,  -1).contiguous()
      lowercase_								= 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			:				int):







      """simple docstring"""







      lowercase_								= self.prepare_config_and_inputs()
      (
          (
          lowercase_
      )					,    (
          lowercase_
      )					,    (
          lowercase_
      )					,    (
          lowercase_
      )					,    (
          lowercase_
      )					,    (
          lowercase_
      )					,    (
          lowercase_
      )					,    
      )								= config_and_inputs
      lowercase_								= {"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
      return config, inputs_dict







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

    lowercase__      =   True
    lowercase__      =   False
    lowercase__      =   False
    lowercase__      =   False
    lowercase__      =   False

    def 					_UpperCAmelCase	(				self			:				Optional[Any]):







      """simple docstring"""







      lowercase_								= DebertaVaModelTester(self)
      lowercase_								= ConfigTester(self ,  config_class=lowerCAmelCase_ ,  hidden_size=3_7)

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







      """simple docstring"""







      self.config_tester.run_common_tests()

    def 					_UpperCAmelCase	(				self			:				int):







      """simple docstring"""







      lowercase_								= self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_deberta_model(*lowerCAmelCase_)

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







      """simple docstring"""







      lowercase_								= self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_deberta_for_sequence_classification(*lowerCAmelCase_)

    def 					_UpperCAmelCase	(				self			:				Dict):







      """simple docstring"""







      lowercase_								= self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_deberta_for_masked_lm(*lowerCAmelCase_)

    def 					_UpperCAmelCase	(				self			:				List[Any]):







      """simple docstring"""







      lowercase_								= self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_deberta_for_question_answering(*lowerCAmelCase_)

    def 					_UpperCAmelCase	(				self			:				str):







      """simple docstring"""







      lowercase_								= self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_deberta_for_token_classification(*lowerCAmelCase_)

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







      """simple docstring"""







      lowercase_								= self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_deberta_for_multiple_choice(*lowerCAmelCase_)




    @slow
    def 					_UpperCAmelCase	(				self			:				Tuple):







      """simple docstring"""







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







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

    @unittest.skip(reason="""Model not available yet""")
    def 					_UpperCAmelCase	(				self			:				Optional[int]):







      """simple docstring"""







      pass




    @slow
    def 					_UpperCAmelCase	(				self			:				int):







      """simple docstring"""







      lowercase_								= DebertaVaModel.from_pretrained("""microsoft/deberta-v2-xlarge""")

      lowercase_								= 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_								= torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]])
      with torch.no_grad():
        lowercase_								= model(lowerCAmelCase_ ,  attention_mask=lowerCAmelCase_)[0]
      # compare the actual values for a slice.
      lowercase_								= torch.tensor(
          [[[0.2_356, 0.1_948, 0.0_369], [-0.1_063, 0.3_586, -0.5_152], [-0.6_399, -0.0_259, -0.2_525]]])
      self.assertTrue(torch.allclose(output[:, 1:4, 1:4] ,  lowerCAmelCase_ ,  atol=1E-4) ,  F'''{output[:, 1:4, 1:4]}''')

