


from collections import OrderedDict
from typing import Any, Mapping, Optional

from ... import PreTrainedTokenizer
from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast
from ...onnx.utils import compute_effective_axis_dimension
from ...utils import TensorType, is_torch_available, logging


snake_case_  :	str							  =							logging.get_logger(__name__)

snake_case_  :	Optional[int]							  =							{
    '''facebook/mbart-large-cc25''': '''https://huggingface.co/facebook/mbart-large-cc25/resolve/main/config.json''',
    # See all MBART models at https://huggingface.co/models?filter=mbart
}

class   A__							(						UpperCamelCase__     ):
						UpperCAmelCase									=  "mbart"
						UpperCAmelCase									=  ["past_key_values"]
						UpperCAmelCase									=  {"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}




						def __init__(				self    :					List[str] ,			_a    :					Tuple=5_0265 ,			_a    :					List[str]=1024 ,			_a    :					List[str]=12 ,			_a    :					Tuple=4096 ,			_a    :					Optional[int]=16 ,			_a    :					Union[str, Any]=12 ,			_a    :					Optional[Any]=4096 ,			_a    :					Optional[Any]=16 ,			_a    :					Union[str, Any]=0.0 ,			_a    :					List[Any]=0.0 ,			_a    :					Dict=True ,			_a    :					List[str]=True ,			_a    :					Optional[Any]="gelu" ,			_a    :					Optional[int]=1024 ,			_a    :					str=0.1 ,			_a    :					Tuple=0.0 ,			_a    :					Tuple=0.0 ,			_a    :					List[Any]=0.02 ,			_a    :					Dict=0.0 ,			_a    :					Any=False ,			_a    :					Union[str, Any]=1 ,			_a    :					Tuple=0 ,			_a    :					List[Any]=2 ,			_a    :					List[str]=2 ,			**_a    :					Union[str, Any] ,			)							->   Union[str, Any]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE	     =vocab_size
										_SCREAMING_SNAKE_CASE	     =max_position_embeddings
										_SCREAMING_SNAKE_CASE	     =d_model
										_SCREAMING_SNAKE_CASE	     =encoder_ffn_dim
										_SCREAMING_SNAKE_CASE	     =encoder_layers
										_SCREAMING_SNAKE_CASE	     =encoder_attention_heads
										_SCREAMING_SNAKE_CASE	     =decoder_ffn_dim
										_SCREAMING_SNAKE_CASE	     =decoder_layers
										_SCREAMING_SNAKE_CASE	     =decoder_attention_heads
										_SCREAMING_SNAKE_CASE	     =dropout
										_SCREAMING_SNAKE_CASE	     =attention_dropout
										_SCREAMING_SNAKE_CASE	     =activation_dropout
										_SCREAMING_SNAKE_CASE	     =activation_function
										_SCREAMING_SNAKE_CASE	     =init_std
										_SCREAMING_SNAKE_CASE	     =encoder_layerdrop
										_SCREAMING_SNAKE_CASE	     =decoder_layerdrop
										_SCREAMING_SNAKE_CASE	     =classifier_dropout
										_SCREAMING_SNAKE_CASE	     =use_cache
										_SCREAMING_SNAKE_CASE	     =encoder_layers
										_SCREAMING_SNAKE_CASE	     =scale_embedding  # scale factor will be sqrt(d_model) if True
										super().__init__(
										    pad_token_id=_a ,			bos_token_id=_a ,			eos_token_id=_a ,			is_encoder_decoder=_a ,			forced_eos_token_id=_a ,			**_a ,			)

class   A__							(						UpperCamelCase__     ):




						@property
						def 							__UpperCamelCase (				self    :					int     )							->   Mapping[str, Mapping[int, str]]:


										"""simple docstring"""





										if self.task in ["default", "seq2seq-lm"]:
														_SCREAMING_SNAKE_CASE	     =OrderedDict(
														    [
														        ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
														        ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
														    ]     )

														if self.use_past:
																		_SCREAMING_SNAKE_CASE	     ={0: '''batch'''}
																		_SCREAMING_SNAKE_CASE	     ={0: '''batch''', 1: '''past_decoder_sequence + sequence'''}
														else:
																		_SCREAMING_SNAKE_CASE	     ={0: '''batch''', 1: '''decoder_sequence'''}
																		_SCREAMING_SNAKE_CASE	     ={0: '''batch''', 1: '''decoder_sequence'''}

														if self.use_past:
																		self.fill_with_past_key_values_(_a ,			direction='''inputs'''     )
										elif self.task == "causal-lm":
														# TODO: figure this case out.
														_SCREAMING_SNAKE_CASE	     =OrderedDict(
														    [
														        ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
														        ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
														    ]     )
														if self.use_past:
																		_SCREAMING_SNAKE_CASE     , _SCREAMING_SNAKE_CASE	     =self.num_layers
																		for i in range(_a     ):
																						_SCREAMING_SNAKE_CASE	     ={0: '''batch''', 2: '''past_sequence + sequence'''}
																						_SCREAMING_SNAKE_CASE	     ={0: '''batch''', 2: '''past_sequence + sequence'''}
										else:
														_SCREAMING_SNAKE_CASE	     =OrderedDict(
														    [
														        ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
														        ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
														        ('''decoder_input_ids''', {0: '''batch''', 1: '''decoder_sequence'''}),
														        ('''decoder_attention_mask''', {0: '''batch''', 1: '''decoder_sequence'''}),
														    ]     )

										return common_inputs




						@property
						def 							__UpperCamelCase (				self    :					List[str]     )							->   Mapping[str, Mapping[int, str]]:


										"""simple docstring"""





										if self.task in ["default", "seq2seq-lm"]:
														_SCREAMING_SNAKE_CASE	     =super().outputs
										else:
														_SCREAMING_SNAKE_CASE	     =super(_a ,			self     ).outputs
														if self.use_past:
																		_SCREAMING_SNAKE_CASE     , _SCREAMING_SNAKE_CASE	     =self.num_layers
																		for i in range(_a     ):
																						_SCREAMING_SNAKE_CASE	     ={0: '''batch''', 2: '''past_sequence + sequence'''}
																						_SCREAMING_SNAKE_CASE	     ={0: '''batch''', 2: '''past_sequence + sequence'''}
										return common_outputs




						def 							__UpperCamelCase (				self    :					Optional[Any] ,			_a    :					PreTrainedTokenizer ,			_a    :					int = -1 ,			_a    :					int = -1 ,			_a    :					bool = False ,			_a    :					Optional[TensorType] = None ,			)							->   Mapping[str, Any]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE	     =self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
										    _a ,			_a ,			_a ,			_a ,			_a     )

										# Generate decoder inputs
										_SCREAMING_SNAKE_CASE	     =seq_length if not self.use_past else 1
										_SCREAMING_SNAKE_CASE	     =self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
										    _a ,			_a ,			_a ,			_a ,			_a     )
										_SCREAMING_SNAKE_CASE	     ={f"decoder_{name}": tensor for name, tensor in decoder_inputs.items()}
										_SCREAMING_SNAKE_CASE	     =dict(**_a ,			**_a     )

										if self.use_past:
														if not is_torch_available():
																		raise ValueError('''Cannot generate dummy past_keys inputs without PyTorch installed.'''     )
														else:
																		import torch
														_SCREAMING_SNAKE_CASE     , _SCREAMING_SNAKE_CASE	     =common_inputs['''input_ids'''].shape
														_SCREAMING_SNAKE_CASE	     =common_inputs['''decoder_input_ids'''].shape[1]
														_SCREAMING_SNAKE_CASE     , _SCREAMING_SNAKE_CASE	     =self.num_attention_heads
														_SCREAMING_SNAKE_CASE	     =(
														    batch,
														    num_encoder_attention_heads,
														    encoder_seq_length,
														    self._config.hidden_size // num_encoder_attention_heads,
														)
														_SCREAMING_SNAKE_CASE	     =decoder_seq_length + 3
														_SCREAMING_SNAKE_CASE	     =(
														    batch,
														    num_decoder_attention_heads,
														    decoder_past_length,
														    self._config.hidden_size // num_decoder_attention_heads,
														)

														_SCREAMING_SNAKE_CASE	     =torch.cat(
														    [common_inputs['''decoder_attention_mask'''], torch.ones(_a ,			_a     )] ,			dim=1     )

														_SCREAMING_SNAKE_CASE	     =[]
														# If the number of encoder and decoder layers are present in the model configuration, both are considered
														_SCREAMING_SNAKE_CASE     , _SCREAMING_SNAKE_CASE	     =self.num_layers
														_SCREAMING_SNAKE_CASE	     =min(_a ,			_a     )
														_SCREAMING_SNAKE_CASE	     =max(_a ,			_a     ) - min_num_layers
														_SCREAMING_SNAKE_CASE	     ='''encoder''' if num_encoder_layers > num_decoder_layers else '''decoder'''

														for _ in range(_a     ):
																		common_inputs["past_key_values"].append(
																		    (
																		        torch.zeros(_a     ),
																		        torch.zeros(_a     ),
																		        torch.zeros(_a     ),
																		        torch.zeros(_a     ),
																		    )     )
														# TODO: test this.
														_SCREAMING_SNAKE_CASE	     =encoder_shape if remaining_side_name == '''encoder''' else decoder_shape
														for _ in range(_a ,			_a     ):
																		common_inputs["past_key_values"].append((torch.zeros(_a     ), torch.zeros(_a     ))     )
										return common_inputs




						def 							__UpperCamelCase (				self    :					List[str] ,			_a    :					PreTrainedTokenizer ,			_a    :					int = -1 ,			_a    :					int = -1 ,			_a    :					bool = False ,			_a    :					Optional[TensorType] = None ,			)							->   Mapping[str, Any]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE	     =self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
										    _a ,			_a ,			_a ,			_a ,			_a     )

										if self.use_past:
														if not is_torch_available():
																		raise ValueError('''Cannot generate dummy past_keys inputs without PyTorch installed.'''     )
														else:
																		import torch
														_SCREAMING_SNAKE_CASE     , _SCREAMING_SNAKE_CASE	     =common_inputs['''input_ids'''].shape
														# Not using the same length for past_key_values
														_SCREAMING_SNAKE_CASE	     =seqlen + 2
														_SCREAMING_SNAKE_CASE     , _SCREAMING_SNAKE_CASE	     =self.num_layers
														_SCREAMING_SNAKE_CASE     , _SCREAMING_SNAKE_CASE	     =self.num_attention_heads
														_SCREAMING_SNAKE_CASE	     =(
														    batch,
														    num_encoder_attention_heads,
														    past_key_values_length,
														    self._config.hidden_size // num_encoder_attention_heads,
														)

														_SCREAMING_SNAKE_CASE	     =common_inputs['''attention_mask'''].dtype
														_SCREAMING_SNAKE_CASE	     =torch.cat(
														    [common_inputs['''attention_mask'''], torch.ones(_a ,			_a ,			dtype=_a     )] ,			dim=1     )
														_SCREAMING_SNAKE_CASE	     =[
														    (torch.zeros(_a     ), torch.zeros(_a     )) for _ in range(_a     )
														]
										return common_inputs




						def 							__UpperCamelCase (				self    :					Optional[Any] ,			_a    :					PreTrainedTokenizer ,			_a    :					int = -1 ,			_a    :					int = -1 ,			_a    :					bool = False ,			_a    :					Optional[TensorType] = None ,			)							->   Mapping[str, Any]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE	     =compute_effective_axis_dimension(
										    _a ,			fixed_dimension=OnnxConfig.default_fixed_batch ,			num_token_to_add=0     )

										# If dynamic axis (-1) we forward with a fixed dimension of 8 tokens to avoid optimizations made by ONNX
										_SCREAMING_SNAKE_CASE	     =tokenizer.num_special_tokens_to_add(_a     )
										_SCREAMING_SNAKE_CASE	     =compute_effective_axis_dimension(
										    _a ,			fixed_dimension=OnnxConfig.default_fixed_sequence ,			num_token_to_add=_a     )

										# Generate dummy inputs according to compute batch and sequence
										_SCREAMING_SNAKE_CASE	     =[''' '''.join([tokenizer.unk_token]     ) * seq_length] * batch_size
										_SCREAMING_SNAKE_CASE	     =dict(tokenizer(_a ,			return_tensors=_a     )     )
										return common_inputs




						def 							__UpperCamelCase (				self    :					List[str] ,			_a    :					PreTrainedTokenizer ,			_a    :					int = -1 ,			_a    :					int = -1 ,			_a    :					bool = False ,			_a    :					Optional[TensorType] = None ,			)							->   Mapping[str, Any]:


										"""simple docstring"""





										if self.task in ["default", "seq2seq-lm"]:
														_SCREAMING_SNAKE_CASE	     =self._generate_dummy_inputs_for_default_and_seqaseq_lm(
														    _a ,			batch_size=_a ,			seq_length=_a ,			is_pair=_a ,			framework=_a     )

										elif self.task == "causal-lm":
														_SCREAMING_SNAKE_CASE	     =self._generate_dummy_inputs_for_causal_lm(
														    _a ,			batch_size=_a ,			seq_length=_a ,			is_pair=_a ,			framework=_a     )
										else:
														_SCREAMING_SNAKE_CASE	     =self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
														    _a ,			batch_size=_a ,			seq_length=_a ,			is_pair=_a ,			framework=_a     )

										return common_inputs




						def 							__UpperCamelCase (				self    :					Union[str, Any] ,			_a    :					Optional[Any] ,			_a    :					List[str] ,			_a    :					Tuple ,			_a    :					Any     )							->   Optional[Any]:


										"""simple docstring"""





										if self.task in ["default", "seq2seq-lm"]:
														_SCREAMING_SNAKE_CASE	     =super()._flatten_past_key_values_(_a ,			_a ,			_a ,			_a     )
										else:
														_SCREAMING_SNAKE_CASE	     =super(_a ,			self     )._flatten_past_key_values_(
														    _a ,			_a ,			_a ,			_a     )



from __future__ import annotations

import unittest

from transformers import DebertaConfig, 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 (
							    TFDebertaForMaskedLM,
							    TFDebertaForQuestionAnswering,
							    TFDebertaForSequenceClassification,
							    TFDebertaForTokenClassification,
							    TFDebertaModel,
							)

class   A__							:




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


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE	     =parent
										_SCREAMING_SNAKE_CASE	     =13
										_SCREAMING_SNAKE_CASE	     =7
										_SCREAMING_SNAKE_CASE	     =True
										_SCREAMING_SNAKE_CASE	     =True
										_SCREAMING_SNAKE_CASE	     =True
										_SCREAMING_SNAKE_CASE	     =True
										_SCREAMING_SNAKE_CASE	     =99
										_SCREAMING_SNAKE_CASE	     =32
										_SCREAMING_SNAKE_CASE	     =2
										_SCREAMING_SNAKE_CASE	     =4
										_SCREAMING_SNAKE_CASE	     =37
										_SCREAMING_SNAKE_CASE	     ='''gelu'''
										_SCREAMING_SNAKE_CASE	     =0.1
										_SCREAMING_SNAKE_CASE	     =0.1
										_SCREAMING_SNAKE_CASE	     =512
										_SCREAMING_SNAKE_CASE	     =16
										_SCREAMING_SNAKE_CASE	     =False
										_SCREAMING_SNAKE_CASE	     =-1
										_SCREAMING_SNAKE_CASE	     =True
										_SCREAMING_SNAKE_CASE	     =2
										_SCREAMING_SNAKE_CASE	     =0.02
										_SCREAMING_SNAKE_CASE	     =3
										_SCREAMING_SNAKE_CASE	     =4
										_SCREAMING_SNAKE_CASE	     =None




						def 							__UpperCamelCase (				self    :					Tuple     )							->   Any:


										"""simple docstring"""





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

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

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

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

										_SCREAMING_SNAKE_CASE	     =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 ,			relative_attention=self.relative_attention ,			max_relative_positions=self.max_relative_positions ,			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 							__UpperCamelCase (				self    :					Optional[int] ,			_a    :					Optional[Any] ,			_a    :					Dict ,			_a    :					List[str] ,			_a    :					Dict ,			_a    :					List[Any] ,			_a    :					Dict ,			_a    :					Tuple     )							->   Optional[int]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE	     =TFDebertaModel(config=_a     )
										_SCREAMING_SNAKE_CASE	     ={'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}

										_SCREAMING_SNAKE_CASE	     =[input_ids, input_mask]
										_SCREAMING_SNAKE_CASE	     =model(_a     )

										_SCREAMING_SNAKE_CASE	     =model(_a     )

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




						def 							__UpperCamelCase (				self    :					int ,			_a    :					List[Any] ,			_a    :					Tuple ,			_a    :					List[str] ,			_a    :					Optional[int] ,			_a    :					Union[str, Any] ,			_a    :					Optional[Any] ,			_a    :					Optional[int]     )							->   int:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE	     =TFDebertaForMaskedLM(config=_a     )
										_SCREAMING_SNAKE_CASE	     ={
										    '''input_ids''': input_ids,
										    '''attention_mask''': input_mask,
										    '''token_type_ids''': token_type_ids,
										}
										_SCREAMING_SNAKE_CASE	     =model(_a     )
										self.parent.assertEqual(result.logits.shape ,			(self.batch_size, self.seq_length, self.vocab_size)     )




						def 							__UpperCamelCase (				self    :					Union[str, Any] ,			_a    :					List[str] ,			_a    :					List[Any] ,			_a    :					Optional[int] ,			_a    :					List[Any] ,			_a    :					Optional[Any] ,			_a    :					Dict ,			_a    :					Optional[int]     )							->   List[str]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE	     =self.num_labels
										_SCREAMING_SNAKE_CASE	     =TFDebertaForSequenceClassification(config=_a     )
										_SCREAMING_SNAKE_CASE	     ={
										    '''input_ids''': input_ids,
										    '''attention_mask''': input_mask,
										    '''token_type_ids''': token_type_ids,
										}

										_SCREAMING_SNAKE_CASE	     =model(_a     )
										self.parent.assertEqual(result.logits.shape ,			(self.batch_size, self.num_labels)     )




						def 							__UpperCamelCase (				self    :					List[Any] ,			_a    :					Any ,			_a    :					Optional[int] ,			_a    :					Optional[Any] ,			_a    :					Optional[Any] ,			_a    :					Optional[int] ,			_a    :					Optional[int] ,			_a    :					Any     )							->   Optional[Any]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE	     =self.num_labels
										_SCREAMING_SNAKE_CASE	     =TFDebertaForTokenClassification(config=_a     )
										_SCREAMING_SNAKE_CASE	     ={
										    '''input_ids''': input_ids,
										    '''attention_mask''': input_mask,
										    '''token_type_ids''': token_type_ids,
										}
										_SCREAMING_SNAKE_CASE	     =model(_a     )
										self.parent.assertEqual(result.logits.shape ,			(self.batch_size, self.seq_length, self.num_labels)     )




						def 							__UpperCamelCase (				self    :					List[Any] ,			_a    :					Dict ,			_a    :					str ,			_a    :					List[Any] ,			_a    :					Optional[Any] ,			_a    :					Optional[int] ,			_a    :					Optional[int] ,			_a    :					List[str]     )							->   Any:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE	     =TFDebertaForQuestionAnswering(config=_a     )
										_SCREAMING_SNAKE_CASE	     ={
										    '''input_ids''': input_ids,
										    '''attention_mask''': input_mask,
										    '''token_type_ids''': token_type_ids,
										}

										_SCREAMING_SNAKE_CASE	     =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 							__UpperCamelCase (				self    :					str     )							->   List[Any]:


										"""simple docstring"""





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

@require_tf
class   A__							(						UpperCamelCase__      ,   UpperCamelCase__      ,   unittest.TestCase     ):
						UpperCAmelCase									=  (
						    (
						        TFDebertaModel,
						        TFDebertaForMaskedLM,
						        TFDebertaForQuestionAnswering,
						        TFDebertaForSequenceClassification,
						        TFDebertaForTokenClassification,
						    )
						    if is_tf_available()
						    else ()
						)
						UpperCAmelCase									=  (
						    {
						        "feature-extraction": TFDebertaModel,
						        "fill-mask": TFDebertaForMaskedLM,
						        "question-answering": TFDebertaForQuestionAnswering,
						        "text-classification": TFDebertaForSequenceClassification,
						        "token-classification": TFDebertaForTokenClassification,
						        "zero-shot": TFDebertaForSequenceClassification,
						    }
						    if is_tf_available()
						    else {}
						)

						UpperCAmelCase									=  False
						UpperCAmelCase									=  False




						def 							__UpperCamelCase (				self    :					Optional[int]     )							->   Optional[Any]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE	     =TFDebertaModelTester(self     )
										_SCREAMING_SNAKE_CASE	     =ConfigTester(self ,			config_class=_a ,			hidden_size=37     )




						def 							__UpperCamelCase (				self    :					List[str]     )							->   Any:


										"""simple docstring"""





										self.config_tester.run_common_tests()




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


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE	     =self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_model(*_a     )




						def 							__UpperCamelCase (				self    :					Any     )							->   List[str]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE	     =self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_masked_lm(*_a     )




						def 							__UpperCamelCase (				self    :					List[Any]     )							->   List[str]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE	     =self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_question_answering(*_a     )




						def 							__UpperCamelCase (				self    :					Dict     )							->   Optional[Any]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE	     =self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_sequence_classification(*_a     )




						def 							__UpperCamelCase (				self    :					Optional[Any]     )							->   Dict:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE	     =self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_token_classification(*_a     )




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


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE	     =TFDebertaModel.from_pretrained('''kamalkraj/deberta-base'''     )
										self.assertIsNotNone(_a     )

@require_tf
class   A__							(						unittest.TestCase     ):




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


										"""simple docstring"""





										pass




						@slow
						def 							__UpperCamelCase (				self    :					List[Any]     )							->   int:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE	     =TFDebertaModel.from_pretrained('''kamalkraj/deberta-base'''     )
										_SCREAMING_SNAKE_CASE	     =tf.constant([[0, 3_1414, 232, 328, 740, 1140, 1_2695, 69, 4_6078, 1588, 2]]     )
										_SCREAMING_SNAKE_CASE	     =tf.constant([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]     )
										_SCREAMING_SNAKE_CASE	     =model(_a ,			attention_mask=_a     )[0]

										_SCREAMING_SNAKE_CASE	     =tf.constant(
										    [
										        [
										            [-0.59_85_58_96, -0.80_55_25_66, -0.8_46_21_35],
										            [1.4_48_40_25, -0.93_48_37_94, -0.80_59_30_85],
										            [0.3_12_27_41, 0.00_31_60_59, -1.4_13_13_77],
										        ]
										    ]     )
										tf.debugging.assert_near(output[:, 1:4, 1:4] ,			_a ,			atol=1E-4     )