




import json
import pathlib
import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision, slow
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
					import torch

if is_vision_available():
					from PIL import Image

					from transformers import ConditionalDetrImageProcessor
class     a__					(      unittest.TestCase   ):






						def __init__(     self	,    _A	,    _A=7	,    _A=3	,    _A=3_0	,    _A=4_0_0	,    _A=True	,    _A=None	,    _A=True	,    _A=[0.5, 0.5, 0.5]	,    _A=[0.5, 0.5, 0.5]	,    _A=True	,    _A=1 / 2_5_5	,    _A=True	,    ):




											"""simple docstring"""



											__lowerCAmelCase            = size if size is not None else {"shortest_edge": 1_8, "longest_edge": 1_3_3_3}
											__lowerCAmelCase            = parent
											__lowerCAmelCase            = batch_size
											__lowerCAmelCase            = num_channels
											__lowerCAmelCase            = min_resolution
											__lowerCAmelCase            = max_resolution
											__lowerCAmelCase            = do_resize
											__lowerCAmelCase            = size
											__lowerCAmelCase            = do_normalize
											__lowerCAmelCase            = image_mean
											__lowerCAmelCase            = image_std
											__lowerCAmelCase            = do_rescale
											__lowerCAmelCase            = rescale_factor
											__lowerCAmelCase            = do_pad






						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											return {
											    "do_resize": self.do_resize,
											    "size": self.size,
											    "do_normalize": self.do_normalize,
											    "image_mean": self.image_mean,
											    "image_std": self.image_std,
											    "do_rescale": self.do_rescale,
											    "rescale_factor": self.rescale_factor,
											    "do_pad": self.do_pad,
											}






						def        __SCREAMING_SNAKE_CASE(     self	,    _A	,    _A=False    ):




											"""simple docstring"""



											if not batched:
																__lowerCAmelCase            = image_inputs[0]
																if isinstance(UpperCAmelCase_	,    Image.Image    ):
																					__lowerCAmelCase     ,							__lowerCAmelCase            = image.size
																else:
																					__lowerCAmelCase     ,							__lowerCAmelCase            = image.shape[1], image.shape[2]
																if w < h:
																					__lowerCAmelCase            = int(self.size["shortest_edge"] * h / w    )
																					__lowerCAmelCase            = self.size["shortest_edge"]
																elif w > h:
																					__lowerCAmelCase            = self.size["shortest_edge"]
																					__lowerCAmelCase            = int(self.size["shortest_edge"] * w / h    )
																else:
																					__lowerCAmelCase            = self.size["shortest_edge"]
																					__lowerCAmelCase            = self.size["shortest_edge"]

											else:
																__lowerCAmelCase            = []
																for image in image_inputs:
																					__lowerCAmelCase     ,							__lowerCAmelCase            = self.get_expected_values([image]    )
																					expected_values.append((expected_height, expected_width)    )
																__lowerCAmelCase            = max(UpperCAmelCase_	,    key=lambda _A    : item[0]    )[0]
																__lowerCAmelCase            = max(UpperCAmelCase_	,    key=lambda _A    : item[1]    )[1]

											return expected_height, expected_width






@require_torch
@require_vision
class     a__					(      __UpperCAmelCase				,       unittest.TestCase   ):
						_a							:					Union[str, Any]      =					ConditionalDetrImageProcessor if is_vision_available() else None






						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											__lowerCAmelCase            = ConditionalDetrImageProcessingTester(self    )






						@property
						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											return self.image_processor_tester.prepare_image_processor_dict()






						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											__lowerCAmelCase            = self.image_processing_class(**self.image_processor_dict    )
											self.assertTrue(hasattr(UpperCAmelCase_	,    "image_mean"    )    )
											self.assertTrue(hasattr(UpperCAmelCase_	,    "image_std"    )    )
											self.assertTrue(hasattr(UpperCAmelCase_	,    "do_normalize"    )    )
											self.assertTrue(hasattr(UpperCAmelCase_	,    "do_resize"    )    )
											self.assertTrue(hasattr(UpperCAmelCase_	,    "size"    )    )






						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											__lowerCAmelCase            = self.image_processing_class.from_dict(self.image_processor_dict    )
											self.assertEqual(image_processor.size	,    {"shortest_edge": 1_8, "longest_edge": 1_3_3_3}    )
											self.assertEqual(image_processor.do_pad	,    UpperCAmelCase_    )

											__lowerCAmelCase            = self.image_processing_class.from_dict(
											    self.image_processor_dict	,    size=4_2	,    max_size=8_4	,    pad_and_return_pixel_mask=UpperCAmelCase_    )
											self.assertEqual(image_processor.size	,    {"shortest_edge": 4_2, "longest_edge": 8_4}    )
											self.assertEqual(image_processor.do_pad	,    UpperCAmelCase_    )






						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											pass






						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											__lowerCAmelCase            = self.image_processing_class(**self.image_processor_dict    )
											# create random PIL images
											__lowerCAmelCase            = prepare_image_inputs(self.image_processor_tester	,    equal_resolution=UpperCAmelCase_    )
											for image in image_inputs:
																self.assertIsInstance(UpperCAmelCase_	,    Image.Image    )

											# Test not batched input
											__lowerCAmelCase            = image_processing(image_inputs[0]	,    return_tensors="pt"    ).pixel_values

											__lowerCAmelCase     ,							__lowerCAmelCase            = self.image_processor_tester.get_expected_values(UpperCAmelCase_    )

											self.assertEqual(
											    encoded_images.shape	,    (1, self.image_processor_tester.num_channels, expected_height, expected_width)	,    )

											# Test batched
											__lowerCAmelCase     ,							__lowerCAmelCase            = self.image_processor_tester.get_expected_values(UpperCAmelCase_	,    batched=UpperCAmelCase_    )

											__lowerCAmelCase            = image_processing(UpperCAmelCase_	,    return_tensors="pt"    ).pixel_values
											self.assertEqual(
											    encoded_images.shape	,    (
											        self.image_processor_tester.batch_size,
											        self.image_processor_tester.num_channels,
											        expected_height,
											        expected_width,
											    )	,    )






						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											__lowerCAmelCase            = self.image_processing_class(**self.image_processor_dict    )
											# create random numpy tensors
											__lowerCAmelCase            = prepare_image_inputs(self.image_processor_tester	,    equal_resolution=UpperCAmelCase_	,    numpify=UpperCAmelCase_    )
											for image in image_inputs:
																self.assertIsInstance(UpperCAmelCase_	,    np.ndarray    )

											# Test not batched input
											__lowerCAmelCase            = image_processing(image_inputs[0]	,    return_tensors="pt"    ).pixel_values

											__lowerCAmelCase     ,							__lowerCAmelCase            = self.image_processor_tester.get_expected_values(UpperCAmelCase_    )

											self.assertEqual(
											    encoded_images.shape	,    (1, self.image_processor_tester.num_channels, expected_height, expected_width)	,    )

											# Test batched
											__lowerCAmelCase            = image_processing(UpperCAmelCase_	,    return_tensors="pt"    ).pixel_values

											__lowerCAmelCase     ,							__lowerCAmelCase            = self.image_processor_tester.get_expected_values(UpperCAmelCase_	,    batched=UpperCAmelCase_    )

											self.assertEqual(
											    encoded_images.shape	,    (
											        self.image_processor_tester.batch_size,
											        self.image_processor_tester.num_channels,
											        expected_height,
											        expected_width,
											    )	,    )






						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											__lowerCAmelCase            = self.image_processing_class(**self.image_processor_dict    )
											# create random PyTorch tensors
											__lowerCAmelCase            = prepare_image_inputs(self.image_processor_tester	,    equal_resolution=UpperCAmelCase_	,    torchify=UpperCAmelCase_    )
											for image in image_inputs:
																self.assertIsInstance(UpperCAmelCase_	,    torch.Tensor    )

											# Test not batched input
											__lowerCAmelCase            = image_processing(image_inputs[0]	,    return_tensors="pt"    ).pixel_values

											__lowerCAmelCase     ,							__lowerCAmelCase            = self.image_processor_tester.get_expected_values(UpperCAmelCase_    )

											self.assertEqual(
											    encoded_images.shape	,    (1, self.image_processor_tester.num_channels, expected_height, expected_width)	,    )

											# Test batched
											__lowerCAmelCase            = image_processing(UpperCAmelCase_	,    return_tensors="pt"    ).pixel_values

											__lowerCAmelCase     ,							__lowerCAmelCase            = self.image_processor_tester.get_expected_values(UpperCAmelCase_	,    batched=UpperCAmelCase_    )

											self.assertEqual(
											    encoded_images.shape	,    (
											        self.image_processor_tester.batch_size,
											        self.image_processor_tester.num_channels,
											        expected_height,
											        expected_width,
											    )	,    )






						@slow
						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											__lowerCAmelCase            = Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"    )
											with open("./tests/fixtures/tests_samples/COCO/coco_annotations.txt"	,    "r"    ) as f:
																__lowerCAmelCase            = json.loads(f.read()    )

											__lowerCAmelCase            = {"image_id": 3_9_7_6_9, "annotations": target}

											# encode them
											__lowerCAmelCase            = ConditionalDetrImageProcessor.from_pretrained("microsoft/conditional-detr-resnet-50"    )
											__lowerCAmelCase            = image_processing(images=UpperCAmelCase_	,    annotations=UpperCAmelCase_	,    return_tensors="pt"    )

											# verify pixel values
											__lowerCAmelCase            = torch.Size([1, 3, 8_0_0, 1_0_6_6]    )
											self.assertEqual(encoding["pixel_values"].shape	,    UpperCAmelCase_    )

											__lowerCAmelCase            = torch.tensor([0.27_96, 0.31_38, 0.34_81]    )
											self.assertTrue(torch.allclose(encoding["pixel_values"][0, 0, 0, :3]	,    UpperCAmelCase_	,    atol=1E-4    )    )

											# verify area
											__lowerCAmelCase            = torch.tensor([58_87.96_00, 1_12_50.20_61, 48_93_53.84_38, 83_71_22.75_00, 14_79_67.51_56, 16_57_32.34_38]    )
											self.assertTrue(torch.allclose(encoding["labels"][0]["area"]	,    UpperCAmelCase_    )    )
											# verify boxes
											__lowerCAmelCase            = torch.Size([6, 4]    )
											self.assertEqual(encoding["labels"][0]["boxes"].shape	,    UpperCAmelCase_    )
											__lowerCAmelCase            = torch.tensor([0.55_03, 0.27_65, 0.06_04, 0.22_15]    )
											self.assertTrue(torch.allclose(encoding["labels"][0]["boxes"][0]	,    UpperCAmelCase_	,    atol=1E-3    )    )
											# verify image_id
											__lowerCAmelCase            = torch.tensor([3_9_7_6_9]    )
											self.assertTrue(torch.allclose(encoding["labels"][0]["image_id"]	,    UpperCAmelCase_    )    )
											# verify is_crowd
											__lowerCAmelCase            = torch.tensor([0, 0, 0, 0, 0, 0]    )
											self.assertTrue(torch.allclose(encoding["labels"][0]["iscrowd"]	,    UpperCAmelCase_    )    )
											# verify class_labels
											__lowerCAmelCase            = torch.tensor([7_5, 7_5, 6_3, 6_5, 1_7, 1_7]    )
											self.assertTrue(torch.allclose(encoding["labels"][0]["class_labels"]	,    UpperCAmelCase_    )    )
											# verify orig_size
											__lowerCAmelCase            = torch.tensor([4_8_0, 6_4_0]    )
											self.assertTrue(torch.allclose(encoding["labels"][0]["orig_size"]	,    UpperCAmelCase_    )    )
											# verify size
											__lowerCAmelCase            = torch.tensor([8_0_0, 1_0_6_6]    )
											self.assertTrue(torch.allclose(encoding["labels"][0]["size"]	,    UpperCAmelCase_    )    )






						@slow
						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											__lowerCAmelCase            = Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"    )
											with open("./tests/fixtures/tests_samples/COCO/coco_panoptic_annotations.txt"	,    "r"    ) as f:
																__lowerCAmelCase            = json.loads(f.read()    )

											__lowerCAmelCase            = {"file_name": "000000039769.png", "image_id": 3_9_7_6_9, "segments_info": target}

											__lowerCAmelCase            = pathlib.Path("./tests/fixtures/tests_samples/COCO/coco_panoptic"    )

											# encode them
											__lowerCAmelCase            = ConditionalDetrImageProcessor(format="coco_panoptic"    )
											__lowerCAmelCase            = image_processing(images=UpperCAmelCase_	,    annotations=UpperCAmelCase_	,    masks_path=UpperCAmelCase_	,    return_tensors="pt"    )

											# verify pixel values
											__lowerCAmelCase            = torch.Size([1, 3, 8_0_0, 1_0_6_6]    )
											self.assertEqual(encoding["pixel_values"].shape	,    UpperCAmelCase_    )

											__lowerCAmelCase            = torch.tensor([0.27_96, 0.31_38, 0.34_81]    )
											self.assertTrue(torch.allclose(encoding["pixel_values"][0, 0, 0, :3]	,    UpperCAmelCase_	,    atol=1E-4    )    )

											# verify area
											__lowerCAmelCase            = torch.tensor([14_79_79.68_75, 16_55_27.04_69, 48_46_38.59_38, 1_12_92.93_75, 58_79.65_62, 76_34.11_47]    )
											self.assertTrue(torch.allclose(encoding["labels"][0]["area"]	,    UpperCAmelCase_    )    )
											# verify boxes
											__lowerCAmelCase            = torch.Size([6, 4]    )
											self.assertEqual(encoding["labels"][0]["boxes"].shape	,    UpperCAmelCase_    )
											__lowerCAmelCase            = torch.tensor([0.26_25, 0.54_37, 0.46_88, 0.86_25]    )
											self.assertTrue(torch.allclose(encoding["labels"][0]["boxes"][0]	,    UpperCAmelCase_	,    atol=1E-3    )    )
											# verify image_id
											__lowerCAmelCase            = torch.tensor([3_9_7_6_9]    )
											self.assertTrue(torch.allclose(encoding["labels"][0]["image_id"]	,    UpperCAmelCase_    )    )
											# verify is_crowd
											__lowerCAmelCase            = torch.tensor([0, 0, 0, 0, 0, 0]    )
											self.assertTrue(torch.allclose(encoding["labels"][0]["iscrowd"]	,    UpperCAmelCase_    )    )
											# verify class_labels
											__lowerCAmelCase            = torch.tensor([1_7, 1_7, 6_3, 7_5, 7_5, 9_3]    )
											self.assertTrue(torch.allclose(encoding["labels"][0]["class_labels"]	,    UpperCAmelCase_    )    )
											# verify masks
											__lowerCAmelCase            = 8_2_2_8_7_3
											self.assertEqual(encoding["labels"][0]["masks"].sum().item()	,    UpperCAmelCase_    )
											# verify orig_size
											__lowerCAmelCase            = torch.tensor([4_8_0, 6_4_0]    )
											self.assertTrue(torch.allclose(encoding["labels"][0]["orig_size"]	,    UpperCAmelCase_    )    )
											# verify size
											__lowerCAmelCase            = torch.tensor([8_0_0, 1_0_6_6]    )
											self.assertTrue(torch.allclose(encoding["labels"][0]["size"]	,    UpperCAmelCase_    )    )










from __future__ import annotations

import unittest

from transformers import DebertaVaConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
					import tensorflow as tf

					from transformers import (
					    TFDebertaVaForMaskedLM,
					    TFDebertaVaForQuestionAnswering,
					    TFDebertaVaForSequenceClassification,
					    TFDebertaVaForTokenClassification,
					    TFDebertaVaModel,
					)
class     a__					:






						def __init__(     self	,    _A	,    _A=1_3	,    _A=7	,    _A=True	,    _A=True	,    _A=True	,    _A=True	,    _A=9_9	,    _A=3_2	,    _A=2	,    _A=4	,    _A=3_7	,    _A="gelu"	,    _A=0.1	,    _A=0.1	,    _A=5_1_2	,    _A=1_6	,    _A=2	,    _A=0.02	,    _A=False	,    _A=True	,    _A="None"	,    _A=3	,    _A=4	,    _A=None	,    ):




											"""simple docstring"""



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






						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



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

											__lowerCAmelCase            = None
											if self.use_input_mask:
																__lowerCAmelCase            = random_attention_mask([self.batch_size, self.seq_length]    )

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

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

											__lowerCAmelCase            = 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	,    relative_attention=self.relative_attention	,    position_biased_input=self.position_biased_input	,    initializer_range=self.initializer_range	,    return_dict=_A	,    )

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






						def        __SCREAMING_SNAKE_CASE(     self	,    _A	,    _A	,    _A	,    _A	,    _A	,    _A	,    _A    ):




											"""simple docstring"""



											__lowerCAmelCase            = TFDebertaVaModel(config=_A    )
											__lowerCAmelCase            = {"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}

											__lowerCAmelCase            = [input_ids, input_mask]
											__lowerCAmelCase            = model(_A    )

											__lowerCAmelCase            = model(_A    )

											self.parent.assertEqual(result.last_hidden_state.shape	,    (self.batch_size, self.seq_length, self.hidden_size)    )






						def        __SCREAMING_SNAKE_CASE(     self	,    _A	,    _A	,    _A	,    _A	,    _A	,    _A	,    _A    ):




											"""simple docstring"""



											__lowerCAmelCase            = TFDebertaVaForMaskedLM(config=_A    )
											__lowerCAmelCase            = {
											    "input_ids": input_ids,
											    "attention_mask": input_mask,
											    "token_type_ids": token_type_ids,
											}
											__lowerCAmelCase            = model(_A    )
											self.parent.assertEqual(result.logits.shape	,    (self.batch_size, self.seq_length, self.vocab_size)    )






						def        __SCREAMING_SNAKE_CASE(     self	,    _A	,    _A	,    _A	,    _A	,    _A	,    _A	,    _A    ):




											"""simple docstring"""



											__lowerCAmelCase            = self.num_labels
											__lowerCAmelCase            = TFDebertaVaForSequenceClassification(config=_A    )
											__lowerCAmelCase            = {
											    "input_ids": input_ids,
											    "attention_mask": input_mask,
											    "token_type_ids": token_type_ids,
											}

											__lowerCAmelCase            = model(_A    )
											self.parent.assertEqual(result.logits.shape	,    (self.batch_size, self.num_labels)    )






						def        __SCREAMING_SNAKE_CASE(     self	,    _A	,    _A	,    _A	,    _A	,    _A	,    _A	,    _A    ):




											"""simple docstring"""



											__lowerCAmelCase            = self.num_labels
											__lowerCAmelCase            = TFDebertaVaForTokenClassification(config=_A    )
											__lowerCAmelCase            = {
											    "input_ids": input_ids,
											    "attention_mask": input_mask,
											    "token_type_ids": token_type_ids,
											}
											__lowerCAmelCase            = model(_A    )
											self.parent.assertEqual(result.logits.shape	,    (self.batch_size, self.seq_length, self.num_labels)    )






						def        __SCREAMING_SNAKE_CASE(     self	,    _A	,    _A	,    _A	,    _A	,    _A	,    _A	,    _A    ):




											"""simple docstring"""



											__lowerCAmelCase            = TFDebertaVaForQuestionAnswering(config=_A    )
											__lowerCAmelCase            = {
											    "input_ids": input_ids,
											    "attention_mask": input_mask,
											    "token_type_ids": token_type_ids,
											}

											__lowerCAmelCase            = model(_A    )
											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        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



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






@require_tf
class     a__					(      snake_case__				,       snake_case__				,       unittest.TestCase   ):
						_a							:					Optional[Any]      =					(
						    (
						        TFDebertaVaModel,
						        TFDebertaVaForMaskedLM,
						        TFDebertaVaForQuestionAnswering,
						        TFDebertaVaForSequenceClassification,
						        TFDebertaVaForTokenClassification,
						    )
						    if is_tf_available()
						    else ()
						)
						_a							:					Union[str, Any]      =					(
						    {
						        """feature-extraction""": TFDebertaVaModel,
						        """fill-mask""": TFDebertaVaForMaskedLM,
						        """question-answering""": TFDebertaVaForQuestionAnswering,
						        """text-classification""": TFDebertaVaForSequenceClassification,
						        """token-classification""": TFDebertaVaForTokenClassification,
						        """zero-shot""": TFDebertaVaForSequenceClassification,
						    }
						    if is_tf_available()
						    else {}
						)

						_a							:					str      =					False
						_a							:					List[str]      =					False






						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											__lowerCAmelCase            = TFDebertaVaModelTester(self    )
											__lowerCAmelCase            = ConfigTester(self	,    config_class=_A	,    hidden_size=3_7    )






						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											self.config_tester.run_common_tests()






						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											__lowerCAmelCase            = self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_model(*_A    )






						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											__lowerCAmelCase            = self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_masked_lm(*_A    )






						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											__lowerCAmelCase            = self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_question_answering(*_A    )






						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											__lowerCAmelCase            = self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_sequence_classification(*_A    )






						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											__lowerCAmelCase            = self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_token_classification(*_A    )






						@slow
						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											__lowerCAmelCase            = TFDebertaVaModel.from_pretrained("kamalkraj/deberta-v2-xlarge"    )
											self.assertIsNotNone(_A    )






@require_tf
class     a__					(      unittest.TestCase   ):






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




											"""simple docstring"""



											pass






						@slow
						def        __SCREAMING_SNAKE_CASE(     self    ):




											"""simple docstring"""



											__lowerCAmelCase            = TFDebertaVaModel.from_pretrained("kamalkraj/deberta-v2-xlarge"    )
											__lowerCAmelCase            = tf.constant([[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]]    )
											__lowerCAmelCase            = tf.constant([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]    )
											__lowerCAmelCase            = model(_A	,    attention_mask=_A    )[0]

											__lowerCAmelCase            = tf.constant(
											    [[[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]]]    )
											tf.debugging.assert_near(output[:, 1:4, 1:4]	,    _A	,    atol=1E-4    )




