



'''simple docstring'''


import gc
import math
import unittest

import torch

from diffusers import UNetaDModel
from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device
from diffusers.utils.testing_utils import enable_full_determinism

from .test_modeling_common import ModelTesterMixin, UNetTesterMixin


lowerCAmelCase :					str 							=logging.get_logger(__name__)

enable_full_determinism()
class 				a_       (    UpperCamelCase__     ,						UpperCamelCase__     ,						unittest.TestCase							):
     __A								=      UNetaDModel
     __A								=      "sample"





     @property
     def 							lowercase__				(			self		: List[Any]						):





        """simple docstring"""




        lowercase_      :Optional[Any]         =			4
        lowercase_      :Optional[Any]         =			3
        lowercase_      :str         =			(32, 32)

        lowercase_      :Optional[Any]         =			floats_tensor((batch_size, num_channels) + sizes						).to(__lowerCamelCase						)
        lowercase_      :str         =			torch.tensor([10]						).to(__lowerCamelCase						)

        return {"sample": noise, "timestep": time_step}





     @property
     def 							lowercase__				(			self		: Tuple						):





        """simple docstring"""




        return (3, 32, 32)





     @property
     def 							lowercase__				(			self		: Union[str, Any]						):





        """simple docstring"""




        return (3, 32, 32)







     def 							lowercase__				(			self		: Tuple						):





        """simple docstring"""




        lowercase_      :Tuple         =			{
            "block_out_channels": (32, 64),
            "down_block_types": ("DownBlock2D", "AttnDownBlock2D"),
            "up_block_types": ("AttnUpBlock2D", "UpBlock2D"),
            "attention_head_dim": 3,
            "out_channels": 3,
            "in_channels": 3,
            "layers_per_block": 2,
            "sample_size": 32,
        }
        lowercase_      :List[str]         =			self.dummy_input
        return init_dict, inputs_dict







class 				a_       (    UpperCamelCase__     ,						UpperCamelCase__     ,						unittest.TestCase							):
     __A								=      UNetaDModel
     __A								=      "sample"





     @property
     def 							lowercase__				(			self		: List[Any]						):





        """simple docstring"""




        lowercase_      :Optional[int]         =			4
        lowercase_      :Optional[int]         =			4
        lowercase_      :int         =			(32, 32)

        lowercase_      :Dict         =			floats_tensor((batch_size, num_channels) + sizes						).to(__lowerCamelCase						)
        lowercase_      :Any         =			torch.tensor([10]						).to(__lowerCamelCase						)

        return {"sample": noise, "timestep": time_step}





     @property
     def 							lowercase__				(			self		: List[Any]						):





        """simple docstring"""




        return (4, 32, 32)





     @property
     def 							lowercase__				(			self		: Optional[Any]						):





        """simple docstring"""




        return (4, 32, 32)





     def 							lowercase__				(			self		: str						):





        """simple docstring"""




        lowercase_      :Dict         =			{
            "sample_size": 32,
            "in_channels": 4,
            "out_channels": 4,
            "layers_per_block": 2,
            "block_out_channels": (32, 64),
            "attention_head_dim": 32,
            "down_block_types": ("DownBlock2D", "DownBlock2D"),
            "up_block_types": ("UpBlock2D", "UpBlock2D"),
        }
        lowercase_      :List[Any]         =			self.dummy_input
        return init_dict, inputs_dict





     def 							lowercase__				(			self		: int						):





        """simple docstring"""




        lowercase_      ,							lowercase_      :Any         =			UNetaDModel.from_pretrained("fusing/unet-ldm-dummy-update"     ,				output_loading_info=__lowerCamelCase						)

        self.assertIsNotNone(__lowerCamelCase						)
        self.assertEqual(len(loading_info["missing_keys"]						)     ,				0						)

        model.to(__lowerCamelCase						)
        lowercase_      :Optional[Any]         =			model(**self.dummy_input						).sample

        assert image is not None, "Make sure output is not None"





     @unittest.skipIf(torch_device != "cuda"     ,				"This test is supposed to run on GPU"						)
     def 							lowercase__				(			self		: List[str]						):





        """simple docstring"""




        lowercase_      ,							lowercase_      :Union[str, Any]         =			UNetaDModel.from_pretrained("fusing/unet-ldm-dummy-update"     ,				output_loading_info=__lowerCamelCase						)
        model.to(__lowerCamelCase						)
        lowercase_      :List[str]         =			model(**self.dummy_input						).sample

        assert image is not None, "Make sure output is not None"





     @unittest.skipIf(torch_device != "cuda"     ,				"This test is supposed to run on GPU"						)
     def 							lowercase__				(			self		: Tuple						):





        """simple docstring"""




        lowercase_      ,							lowercase_      :Optional[Any]         =			UNetaDModel.from_pretrained("fusing/unet-ldm-dummy-update"     ,				output_loading_info=__lowerCamelCase						)
        model_accelerate.to(__lowerCamelCase						)
        model_accelerate.eval()

        lowercase_      :List[str]         =			torch.randn(
            1     ,				model_accelerate.config.in_channels     ,				model_accelerate.config.sample_size     ,				model_accelerate.config.sample_size     ,				generator=torch.manual_seed(0						)     ,				)
        lowercase_      :Any         =			noise.to(__lowerCamelCase						)
        lowercase_      :Any         =			torch.tensor([10] * noise.shape[0]						).to(__lowerCamelCase						)

        lowercase_      :Optional[Any]         =			model_accelerate(__lowerCamelCase     ,				__lowerCamelCase						)["sample"]

        # two models don't need to stay in the device at the same time
        del model_accelerate
        torch.cuda.empty_cache()
        gc.collect()

        lowercase_      ,							lowercase_      :int         =			UNetaDModel.from_pretrained(
            "fusing/unet-ldm-dummy-update"     ,				output_loading_info=__lowerCamelCase     ,				low_cpu_mem_usage=__lowerCamelCase						)
        model_normal_load.to(__lowerCamelCase						)
        model_normal_load.eval()
        lowercase_      :Any         =			model_normal_load(__lowerCamelCase     ,				__lowerCamelCase						)["sample"]

        assert torch_all_close(__lowerCamelCase     ,				__lowerCamelCase     ,				rtol=1e-3						)







     def 							lowercase__				(			self		: Optional[Any]						):





        """simple docstring"""




        lowercase_      :str         =			UNetaDModel.from_pretrained("fusing/unet-ldm-dummy-update"						)
        model.eval()
        model.to(__lowerCamelCase						)

        lowercase_      :List[str]         =			torch.randn(
            1     ,				model.config.in_channels     ,				model.config.sample_size     ,				model.config.sample_size     ,				generator=torch.manual_seed(0						)     ,				)
        lowercase_      :int         =			noise.to(__lowerCamelCase						)
        lowercase_      :Dict         =			torch.tensor([10] * noise.shape[0]						).to(__lowerCamelCase						)

        with torch.no_grad():
           lowercase_      :Union[str, Any]         =			model(__lowerCamelCase     ,				__lowerCamelCase						).sample

        lowercase_      :int         =			output[0, -1, -3:, -3:].flatten().cpu()
        # fmt: off
        lowercase_      :Optional[int]         =			torch.tensor([-13.32_58, -20.11_00, -15.98_73, -17.66_17, -23.05_96, -17.94_19, -13.36_75, -16.18_89, -12.38_00]						)
        # fmt: on

        self.assertTrue(torch_all_close(__lowerCamelCase     ,				__lowerCamelCase     ,				rtol=1e-3						)						)







class 				a_       (    UpperCamelCase__     ,						UpperCamelCase__     ,						unittest.TestCase							):
     __A								=      UNetaDModel
     __A								=      "sample"





     @property
     def 							lowercase__				(			self		: Optional[Any]     ,				lowercase		: Tuple=(32, 32)						):





        """simple docstring"""




        lowercase_      :Any         =			4
        lowercase_      :Optional[Any]         =			3

        lowercase_      :Tuple         =			floats_tensor((batch_size, num_channels) + sizes						).to(__lowerCamelCase						)
        lowercase_      :int         =			torch.tensor(batch_size * [10]						).to(dtype=torch.intaa     ,				device=__lowerCamelCase						)

        return {"sample": noise, "timestep": time_step}





     @property
     def 							lowercase__				(			self		: Union[str, Any]						):





        """simple docstring"""




        return (3, 32, 32)





     @property
     def 							lowercase__				(			self		: Optional[Any]						):





        """simple docstring"""




        return (3, 32, 32)





     def 							lowercase__				(			self		: List[str]						):





        """simple docstring"""




        lowercase_      :Dict         =			{
            "block_out_channels": [32, 64, 64, 64],
            "in_channels": 3,
            "layers_per_block": 1,
            "out_channels": 3,
            "time_embedding_type": "fourier",
            "norm_eps": 1e-6,
            "mid_block_scale_factor": math.sqrt(2.0						),
            "norm_num_groups": None,
            "down_block_types": [
                "SkipDownBlock2D",
                "AttnSkipDownBlock2D",
                "SkipDownBlock2D",
                "SkipDownBlock2D",
            ],
            "up_block_types": [
                "SkipUpBlock2D",
                "SkipUpBlock2D",
                "AttnSkipUpBlock2D",
                "SkipUpBlock2D",
            ],
        }
        lowercase_      :Optional[int]         =			self.dummy_input
        return init_dict, inputs_dict





     @slow
     def 							lowercase__				(			self		: Optional[int]						):





        """simple docstring"""




        lowercase_      ,							lowercase_      :int         =			UNetaDModel.from_pretrained("google/ncsnpp-celebahq-256"     ,				output_loading_info=__lowerCamelCase						)
        self.assertIsNotNone(__lowerCamelCase						)
        self.assertEqual(len(loading_info["missing_keys"]						)     ,				0						)

        model.to(__lowerCamelCase						)
        lowercase_      :Optional[int]         =			self.dummy_input
        lowercase_      :Dict         =			floats_tensor((4, 3) + (256, 256)						).to(__lowerCamelCase						)
        lowercase_      :Any         =			noise
        lowercase_      :List[Any]         =			model(**__lowerCamelCase						)

        assert image is not None, "Make sure output is not None"





     @slow
     def 							lowercase__				(			self		: Optional[int]						):





        """simple docstring"""




        lowercase_      :Dict         =			UNetaDModel.from_pretrained("google/ncsnpp-celebahq-256"						)
        model.to(__lowerCamelCase						)

        lowercase_      :List[str]         =			4
        lowercase_      :Dict         =			3
        lowercase_      :int         =			(256, 256)

        lowercase_      :int         =			torch.ones((batch_size, num_channels) + sizes						).to(__lowerCamelCase						)
        lowercase_      :str         =			torch.tensor(batch_size * [1e-4]						).to(__lowerCamelCase						)

        with torch.no_grad():
           lowercase_      :int         =			model(__lowerCamelCase     ,				__lowerCamelCase						).sample

        lowercase_      :Optional[Any]         =			output[0, -3:, -3:, -1].flatten().cpu()
        # fmt: off
        lowercase_      :List[str]         =			torch.tensor([-48_42.86_91, -64_99.66_31, -38_00.19_53, -79_78.26_86, -1_09_80.71_29, -2_00_28.85_35, 81_48.28_22, 23_42.29_05, 5_67.76_08]						)
        # fmt: on

        self.assertTrue(torch_all_close(__lowerCamelCase     ,				__lowerCamelCase     ,				rtol=1e-2						)						)





     def 							lowercase__				(			self		: Any						):





        """simple docstring"""




        lowercase_      :Dict         =			UNetaDModel.from_pretrained("fusing/ncsnpp-ffhq-ve-dummy-update"						)
        model.to(__lowerCamelCase						)

        lowercase_      :Any         =			4
        lowercase_      :Union[str, Any]         =			3
        lowercase_      :Optional[Any]         =			(32, 32)

        lowercase_      :Optional[Any]         =			torch.ones((batch_size, num_channels) + sizes						).to(__lowerCamelCase						)
        lowercase_      :Any         =			torch.tensor(batch_size * [1e-4]						).to(__lowerCamelCase						)

        with torch.no_grad():
           lowercase_      :Optional[int]         =			model(__lowerCamelCase     ,				__lowerCamelCase						).sample

        lowercase_      :Dict         =			output[0, -3:, -3:, -1].flatten().cpu()
        # fmt: off
        lowercase_      :List[str]         =			torch.tensor([-0.03_25, -0.09_00, -0.08_69, -0.03_32, -0.07_25, -0.02_70, -0.01_01, 0.02_27, 0.02_56]						)
        # fmt: on

        self.assertTrue(torch_all_close(__lowerCamelCase     ,				__lowerCamelCase     ,				rtol=1e-2						)						)







     def 							lowercase__				(			self		: Any						):





        """simple docstring"""




        pass









'''simple docstring'''


import unittest

from transformers import DebertaConfig, 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 (
     DebertaForMaskedLM,
     DebertaForQuestionAnswering,
     DebertaForSequenceClassification,
     DebertaForTokenClassification,
     DebertaModel,
 )
 from transformers.models.deberta.modeling_deberta import DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST
class 				a_       (    _lowerCAmelCase							):





     def __init__(			self		: Any     ,				lowercase		: int     ,				lowercase		: Union[str, Any]=13     ,				lowercase		: List[str]=7     ,				lowercase		: List[str]=True     ,				lowercase		: int=True     ,				lowercase		: Tuple=True     ,				lowercase		: int=True     ,				lowercase		: List[Any]=99     ,				lowercase		: Optional[int]=32     ,				lowercase		: Dict=5     ,				lowercase		: Optional[int]=4     ,				lowercase		: List[str]=37     ,				lowercase		: Tuple="gelu"     ,				lowercase		: List[Any]=0.1     ,				lowercase		: Tuple=0.1     ,				lowercase		: List[str]=512     ,				lowercase		: str=16     ,				lowercase		: Tuple=2     ,				lowercase		: List[Any]=0.02     ,				lowercase		: Dict=False     ,				lowercase		: Dict=True     ,				lowercase		: int="None"     ,				lowercase		: Optional[Any]=3     ,				lowercase		: Dict=4     ,				lowercase		: List[Any]=None     ,				):





        """simple docstring"""




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





     def 							lowercase__				(			self		: Dict						):





        """simple docstring"""




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

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

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

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

        lowercase_      :Optional[Any]         =			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 DebertaConfig(
            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		: Optional[int]						):





        """simple docstring"""




        lowercase_      :Dict         =			self.get_config()
        lowercase_      :Optional[Any]         =			300
        return config





     def 							lowercase__				(			self		: Optional[Any]     ,				lowercase		: Dict						):





        """simple docstring"""




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





     def 							lowercase__				(			self		: Optional[Any]     ,				lowercase		: Union[str, Any]     ,				lowercase		: List[Any]     ,				lowercase		: List[Any]     ,				lowercase		: Tuple     ,				lowercase		: str     ,				lowercase		: Optional[Any]     ,				lowercase		: Optional[int]						):





        """simple docstring"""




        lowercase_      :str         =			DebertaModel(config=lowercase						)
        model.to(lowercase						)
        model.eval()
        lowercase_      :Optional[int]         =			model(lowercase     ,				attention_mask=lowercase     ,				token_type_ids=lowercase						)[0]
        lowercase_      :Union[str, Any]         =			model(lowercase     ,				token_type_ids=lowercase						)[0]
        lowercase_      :Dict         =			model(lowercase						)[0]

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





     def 							lowercase__				(			self		: Dict     ,				lowercase		: Union[str, Any]     ,				lowercase		: Optional[int]     ,				lowercase		: Tuple     ,				lowercase		: Dict     ,				lowercase		: Dict     ,				lowercase		: str     ,				lowercase		: Tuple						):





        """simple docstring"""




        lowercase_      :Dict         =			DebertaForMaskedLM(config=lowercase						)
        model.to(lowercase						)
        model.eval()
        lowercase_      :Optional[Any]         =			model(lowercase     ,				attention_mask=lowercase     ,				token_type_ids=lowercase     ,				labels=lowercase						)

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





     def 							lowercase__				(			self		: Optional[int]     ,				lowercase		: Union[str, Any]     ,				lowercase		: Union[str, Any]     ,				lowercase		: Union[str, Any]     ,				lowercase		: Dict     ,				lowercase		: List[Any]     ,				lowercase		: int     ,				lowercase		: Dict						):





        """simple docstring"""




        lowercase_      :Dict         =			self.num_labels
        lowercase_      :int         =			DebertaForSequenceClassification(lowercase						)
        model.to(lowercase						)
        model.eval()
        lowercase_      :Union[str, Any]         =			model(lowercase     ,				attention_mask=lowercase     ,				token_type_ids=lowercase     ,				labels=lowercase						)
        self.parent.assertListEqual(list(result.logits.size()						)     ,				[self.batch_size, self.num_labels]						)
        self.check_loss_output(lowercase						)





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





        """simple docstring"""




        lowercase_      :List[str]         =			self.num_labels
        lowercase_      :Optional[int]         =			DebertaForTokenClassification(config=lowercase						)
        model.to(lowercase						)
        model.eval()
        lowercase_      :Dict         =			model(lowercase     ,				attention_mask=lowercase     ,				token_type_ids=lowercase     ,				labels=lowercase						)
        self.parent.assertEqual(result.logits.shape     ,				(self.batch_size, self.seq_length, self.num_labels)						)





     def 							lowercase__				(			self		: Union[str, Any]     ,				lowercase		: Tuple     ,				lowercase		: Any     ,				lowercase		: List[Any]     ,				lowercase		: List[Any]     ,				lowercase		: Union[str, Any]     ,				lowercase		: Optional[int]     ,				lowercase		: List[Any]						):





        """simple docstring"""




        lowercase_      :Any         =			DebertaForQuestionAnswering(config=lowercase						)
        model.to(lowercase						)
        model.eval()
        lowercase_      :List[Any]         =			model(
            lowercase     ,				attention_mask=lowercase     ,				token_type_ids=lowercase     ,				start_positions=lowercase     ,				end_positions=lowercase     ,				)
        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		: Any						):





        """simple docstring"""




        lowercase_      :Optional[int]         =			self.prepare_config_and_inputs()
        (
            (
            lowercase_
        )      ,							(
            lowercase_
        )      ,							(
            lowercase_
        )      ,							(
            lowercase_
        )      ,							(
            lowercase_
        )      ,							(
            lowercase_
        )      ,							(
            lowercase_
        )      ,							
        )      :List[str]         =			config_and_inputs
        lowercase_      :Tuple         =			{"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
        return config, inputs_dict







@require_torch
class 				a_       (    _lowerCAmelCase     ,						_lowerCAmelCase     ,						unittest.TestCase							):
     __A								=      (
         (
             DebertaModel,
             DebertaForMaskedLM,
             DebertaForSequenceClassification,
             DebertaForTokenClassification,
             DebertaForQuestionAnswering,
         )
         if is_torch_available()
         else ()
     )
     __A								=      (
         {
             "feature-extraction": DebertaModel,
             "fill-mask": DebertaForMaskedLM,
             "question-answering": DebertaForQuestionAnswering,
             "text-classification": DebertaForSequenceClassification,
             "token-classification": DebertaForTokenClassification,
             "zero-shot": DebertaForSequenceClassification,
         }
         if is_torch_available()
         else {}
     )

     __A								=      True
     __A								=      False
     __A								=      False
     __A								=      False
     __A								=      False





     def 							lowercase__				(			self		: Optional[int]						):





        """simple docstring"""




        lowercase_      :List[Any]         =			DebertaModelTester(self						)
        lowercase_      :str         =			ConfigTester(self     ,				config_class=lowercase     ,				hidden_size=37						)





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





        """simple docstring"""




        self.config_tester.run_common_tests()





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





        """simple docstring"""




        lowercase_      :str         =			self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_deberta_model(*lowercase						)





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





        """simple docstring"""




        lowercase_      :Optional[Any]         =			self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_deberta_for_sequence_classification(*lowercase						)





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





        """simple docstring"""




        lowercase_      :Optional[int]         =			self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_deberta_for_masked_lm(*lowercase						)





     def 							lowercase__				(			self		: int						):





        """simple docstring"""




        lowercase_      :Union[str, Any]         =			self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_deberta_for_question_answering(*lowercase						)





     def 							lowercase__				(			self		: Tuple						):





        """simple docstring"""




        lowercase_      :Union[str, Any]         =			self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_deberta_for_token_classification(*lowercase						)







     @slow
     def 							lowercase__				(			self		: Optional[int]						):





        """simple docstring"""




        for model_name in DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
           lowercase_      :Tuple         =			DebertaModel.from_pretrained(lowercase						)
           self.assertIsNotNone(lowercase						)







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





     @unittest.skip(reason="Model not available yet"						)
     def 							lowercase__				(			self		: Dict						):





        """simple docstring"""




        pass







     @slow
     def 							lowercase__				(			self		: List[Any]						):





        """simple docstring"""




        lowercase_      :Optional[Any]         =			DebertaModel.from_pretrained("microsoft/deberta-base"						)

        lowercase_      :Dict         =			torch.tensor([[0, 31_414, 232, 328, 740, 1_140, 12_695, 69, 46_078, 1_588, 2]]						)
        lowercase_      :Optional[Any]         =			torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]						)
        with torch.no_grad():
           lowercase_      :Optional[int]         =			model(lowercase     ,				attention_mask=lowercase						)[0]
        # compare the actual values for a slice.
        lowercase_      :List[Any]         =			torch.tensor(
            [[[-0.59_86, -0.80_55, -0.84_62], [1.44_84, -0.93_48, -0.80_59], [0.31_23, 0.00_32, -1.41_31]]]						)
        self.assertTrue(torch.allclose(output[:, 1:4, 1:4]     ,				lowercase     ,				atol=1e-4						)     ,				F'{output[:, 1:4, 1:4]}'						)


