




from typing import Dict, Tuple, overload

import torch
import torch.types
from torch import nn

from . import residue_constants as rc
from .rigid_utils import Rigid, Rotation
from .tensor_utils import batched_gather





@overload
def 							A__   (snake_case      :		torch.Tensor		,  snake_case      :		torch.Tensor		,  snake_case      :		None							)    ->	torch.Tensor:
					...





@overload
def 							A__   (snake_case      :		torch.Tensor		,  snake_case      :		torch.Tensor		,  snake_case      :		torch.Tensor							)    ->	Tuple[torch.Tensor, torch.Tensor]:
					...





def 							A__   (snake_case      :		str		,  snake_case      :		int		,  snake_case      :		Optional[Any]							)    ->	str:
					__UpperCamelCase				:  Optional[Any]								=			aatype == rc.restype_order["""G"""]
					__UpperCamelCase				:  int								=			rc.atom_order["""CA"""]
					__UpperCamelCase				:  Dict								=			rc.atom_order["""CB"""]
					__UpperCamelCase				:  int								=			torch.where(
					    is_gly[..., None].expand(*((-1,) * len(is_gly.shape							))		,  3							)		,  all_atom_positions[..., ca_idx, :]		,  all_atom_positions[..., cb_idx, :]		,  )

					if all_atom_masks is not None:
										__UpperCamelCase				:  Any								=			torch.where(
										    snake_case		,  all_atom_masks[..., ca_idx]		,  all_atom_masks[..., cb_idx]		,  )
										return pseudo_beta, pseudo_beta_mask
					else:
										return pseudo_beta





def 							A__   (snake_case      :		torch.Tensor		,  snake_case      :		Dict[str, torch.Tensor]							)    ->	torch.Tensor:
					__UpperCamelCase				:  Tuple								=			batched_gather(
					    snake_case		,  batch["""residx_atom37_to_atom14"""]		,  dim=-2		,  no_batch_dims=len(atomaa.shape[:-2]							)		,  )

					__UpperCamelCase				:  List[Any]								=			atomaa_data * batch["""atom37_atom_exists"""][..., None]

					return atomaa_data





def 							A__   (snake_case      :		Dict[str, torch.Tensor]							)    ->	torch.Tensor:
					__UpperCamelCase				:  str								=			template_feats["""template_aatype"""]
					__UpperCamelCase				:  Optional[int]								=			template_feats["""template_torsion_angles_sin_cos"""]
					__UpperCamelCase				:  Any								=			template_feats["""template_alt_torsion_angles_sin_cos"""]
					__UpperCamelCase				:  Tuple								=			template_feats["""template_torsion_angles_mask"""]
					__UpperCamelCase				:  Dict								=			torch.cat(
					    [
					        nn.functional.one_hot(snake_case		,  22							),
					        torsion_angles_sin_cos.reshape(*torsion_angles_sin_cos.shape[:-2]		,  14							),
					        alt_torsion_angles_sin_cos.reshape(*alt_torsion_angles_sin_cos.shape[:-2]		,  14							),
					        torsion_angles_mask,
					    ]		,  dim=-1		,  )

					return template_angle_feat





def 							A__   (snake_case      :		Dict[str, torch.Tensor]		,  snake_case      :		torch.types.Number		,  snake_case      :		torch.types.Number		,  snake_case      :		int		,  snake_case      :		bool = False		,  snake_case      :		float = 1e-20		,  snake_case      :		float = 1e8		,  )    ->	torch.Tensor:
					__UpperCamelCase				:  Tuple								=			batch["""template_pseudo_beta_mask"""]
					__UpperCamelCase				:  Optional[int]								=			template_mask[..., None] * template_mask[..., None, :]

					# Compute distogram (this seems to differ slightly from Alg. 5)
					__UpperCamelCase				:  Any								=			batch["""template_pseudo_beta"""]
					__UpperCamelCase				:  Optional[int]								=			torch.sum((tpb[..., None, :] - tpb[..., None, :, :]) ** 2		,  dim=-1		,  keepdim=snake_case							)
					__UpperCamelCase				:  Optional[int]								=			torch.linspace(snake_case		,  snake_case		,  snake_case		,  device=tpb.device							) ** 2
					__UpperCamelCase				:  Any								=			torch.cat([lower[1:], lower.new_tensor([inf]							)]		,  dim=-1							)
					__UpperCamelCase				:  int								=			((dgram > lower) * (dgram < upper)).type(dgram.dtype							)

					__UpperCamelCase				:  str								=			[dgram, template_mask_ad[..., None]]

					__UpperCamelCase				:  torch.LongTensor								=			nn.functional.one_hot(
					    batch["""template_aatype"""]		,  rc.restype_num + 2		,  )

					__UpperCamelCase				:  List[Any]								=			batch["""template_aatype"""].shape[-1]
					to_concat.append(aatype_one_hot[..., None, :, :].expand(*aatype_one_hot.shape[:-2]		,  snake_case		,  -1		,  -1							)							)
					to_concat.append(aatype_one_hot[..., None, :].expand(*aatype_one_hot.shape[:-2]		,  -1		,  snake_case		,  -1							)							)

					__UpperCamelCase				:  List[Any]								=			[rc.atom_order[a] for a in ["""N""", """CA""", """C"""]]
					__UpperCamelCase				:  int								=			Rigid.make_transform_from_reference(
					    n_xyz=batch["""template_all_atom_positions"""][..., n, :]		,  ca_xyz=batch["""template_all_atom_positions"""][..., ca, :]		,  c_xyz=batch["""template_all_atom_positions"""][..., c, :]		,  eps=snake_case		,  )
					__UpperCamelCase				:  int								=			rigids.get_trans()[..., None, :, :]
					__UpperCamelCase				:  int								=			rigids[..., None].invert_apply(snake_case							)

					__UpperCamelCase				:  List[str]								=			torch.rsqrt(eps + torch.sum(rigid_vec**2		,  dim=-1							)							)

					__UpperCamelCase				:  Union[str, Any]								=			batch["""template_all_atom_mask"""]
					__UpperCamelCase				:  int								=			t_aa_masks[..., n] * t_aa_masks[..., ca] * t_aa_masks[..., c]
					__UpperCamelCase				:  List[Any]								=			template_mask[..., None] * template_mask[..., None, :]

					__UpperCamelCase				:  Optional[Any]								=			inv_distance_scalar * template_mask_ad
					__UpperCamelCase				:  List[Any]								=			rigid_vec * inv_distance_scalar[..., None]

					if not use_unit_vector:
										__UpperCamelCase				:  List[str]								=			unit_vector * 0.0

					to_concat.extend(torch.unbind(unit_vector[..., None, :]		,  dim=-1							)							)
					to_concat.append(template_mask_ad[..., None]							)

					__UpperCamelCase				:  int								=			torch.cat(snake_case		,  dim=-1							)
					__UpperCamelCase				:  Union[str, Any]								=			act * template_mask_ad[..., None]

					return act





def 							A__   (snake_case      :		Dict[str, torch.Tensor]							)    ->	torch.Tensor:
					__UpperCamelCase				:  torch.LongTensor								=			nn.functional.one_hot(batch["""extra_msa"""]		,  23							)
					__UpperCamelCase				:  Union[str, Any]								=			[
					    msa_ahot,
					    batch["""extra_has_deletion"""].unsqueeze(-1							),
					    batch["""extra_deletion_value"""].unsqueeze(-1							),
					]
					return torch.cat(snake_case		,  dim=-1							)





def 							A__   (snake_case      :		Rigid		,  snake_case      :		torch.Tensor		,  snake_case      :		torch.Tensor		,  snake_case      :		torch.Tensor		,  )    ->	Rigid:
					# [*, N, 8, 4, 4]
					__UpperCamelCase				:  Optional[Any]								=			rrgdf[aatype, ...]

					# [*, N, 8] transformations, i.e.
					#   One [*, N, 8, 3, 3] rotation matrix and
					#   One [*, N, 8, 3]    translation matrix
					__UpperCamelCase				:  List[Any]								=			r.from_tensor_axa(snake_case							)

					__UpperCamelCase				:  str								=			alpha.new_zeros((*((1,) * len(alpha.shape[:-1]							)), 2)							)
					__UpperCamelCase				:  Any								=			1

					# [*, N, 8, 2]
					__UpperCamelCase				:  Optional[int]								=			torch.cat([bb_rot.expand(*alpha.shape[:-2]		,  -1		,  -1							), alpha]		,  dim=-2							)

					# [*, N, 8, 3, 3]
					# Produces rotation matrices of the form:
					# [
					#   [1, 0  , 0  ],
					#   [0, a_2,-a_1],
					#   [0, a_1, a_2]
					# ]
					# This follows the original code rather than the supplement, which uses
					# different indices.

					__UpperCamelCase				:  Optional[int]								=			alpha.new_zeros(default_r.get_rots().get_rot_mats().shape							)
					__UpperCamelCase				:  Any								=			1
					__UpperCamelCase				:  int								=			alpha[..., 1]
					__UpperCamelCase				:  int								=			-alpha[..., 0]
					__UpperCamelCase				:  List[str]								=			alpha

					__UpperCamelCase				:  Optional[int]								=			default_r.compose(Rigid(Rotation(rot_mats=snake_case							)		,  snake_case							)							)

					__UpperCamelCase				:  Any								=			all_frames[..., 5]
					__UpperCamelCase				:  Optional[int]								=			all_frames[..., 6]
					__UpperCamelCase				:  Dict								=			all_frames[..., 7]

					__UpperCamelCase				:  Tuple								=			all_frames[..., 4]
					__UpperCamelCase				:  Union[str, Any]								=			chia_frame_to_bb.compose(snake_case							)
					__UpperCamelCase				:  Union[str, Any]								=			chia_frame_to_bb.compose(snake_case							)
					__UpperCamelCase				:  int								=			chia_frame_to_bb.compose(snake_case							)

					__UpperCamelCase				:  Optional[Any]								=			Rigid.cat(
					    [
					        all_frames[..., :5],
					        chia_frame_to_bb.unsqueeze(-1							),
					        chia_frame_to_bb.unsqueeze(-1							),
					        chia_frame_to_bb.unsqueeze(-1							),
					    ]		,  dim=-1		,  )

					__UpperCamelCase				:  str								=			r[..., None].compose(snake_case							)

					return all_frames_to_global







def 							A__   (snake_case      :		Rigid		,  snake_case      :		torch.Tensor		,  snake_case      :		torch.Tensor		,  snake_case      :		torch.Tensor		,  snake_case      :		torch.Tensor		,  snake_case      :		torch.Tensor		,  )    ->	torch.Tensor:
					# [*, N, 14]
					__UpperCamelCase				:  Tuple								=			group_idx[aatype, ...]

					# [*, N, 14, 8]
					__UpperCamelCase				:  torch.LongTensor								=			nn.functional.one_hot(
					    snake_case		,  num_classes=default_frames.shape[-3]		,  )

					# [*, N, 14, 8]
					__UpperCamelCase				:  List[str]								=			r[..., None, :] * group_mask_one_hot

					# [*, N, 14]
					__UpperCamelCase				:  Optional[int]								=			t_atoms_to_global.map_tensor_fn(lambda snake_case							: torch.sum(snake_case		,  dim=-1							)							)

					# [*, N, 14, 1]
					__UpperCamelCase				:  Optional[Any]								=			atom_mask[aatype, ...].unsqueeze(-1							)

					# [*, N, 14, 3]
					__UpperCamelCase				:  List[str]								=			lit_positions[aatype, ...]
					__UpperCamelCase				:  Optional[int]								=			t_atoms_to_global.apply(snake_case							)
					__UpperCamelCase				:  Union[str, Any]								=			pred_positions * atom_mask

					return pred_positions












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       SCREAMING_SNAKE_CASE_							:



	"""simple docstring"""


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







						"""simple docstring"""







						__UpperCamelCase				:  Union[str, Any]								=			parent
						__UpperCamelCase				:  Any								=			13
						__UpperCamelCase				:  Union[str, Any]								=			7
						__UpperCamelCase				:  List[str]								=			True
						__UpperCamelCase				:  List[Any]								=			True
						__UpperCamelCase				:  Union[str, Any]								=			True
						__UpperCamelCase				:  Any								=			True
						__UpperCamelCase				:  Optional[int]								=			99
						__UpperCamelCase				:  int								=			32
						__UpperCamelCase				:  List[str]								=			2
						__UpperCamelCase				:  List[Any]								=			4
						__UpperCamelCase				:  Any								=			37
						__UpperCamelCase				:  str								=			"""gelu"""
						__UpperCamelCase				:  Any								=			0.1
						__UpperCamelCase				:  List[str]								=			0.1
						__UpperCamelCase				:  Optional[Any]								=			512
						__UpperCamelCase				:  Dict								=			16
						__UpperCamelCase				:  Tuple								=			False
						__UpperCamelCase				:  Optional[Any]								=			-1
						__UpperCamelCase				:  Optional[int]								=			True
						__UpperCamelCase				:  Optional[Any]								=			2
						__UpperCamelCase				:  List[str]								=			0.02
						__UpperCamelCase				:  Union[str, Any]								=			3
						__UpperCamelCase				:  Optional[int]								=			4
						__UpperCamelCase				:  List[Any]								=			None






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







						"""simple docstring"""







						__UpperCamelCase				:  Dict								=			ids_tensor([self.batch_size, self.seq_length]				,    self.vocab_size  )

						__UpperCamelCase				:  List[Any]								=			None
						if self.use_input_mask:
											__UpperCamelCase				:  Any								=			random_attention_mask([self.batch_size, self.seq_length]  )

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

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

						__UpperCamelCase				:  Optional[Any]								=			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=lowerCAmelCase				,    )

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






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







						"""simple docstring"""







						__UpperCamelCase				:  str								=			TFDebertaModel(config=lowerCAmelCase  )
						__UpperCamelCase				:  Optional[Any]								=			{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}

						__UpperCamelCase				:  Optional[int]								=			[input_ids, input_mask]
						__UpperCamelCase				:  Any								=			model(lowerCAmelCase  )

						__UpperCamelCase				:  int								=			model(lowerCAmelCase  )

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






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







						"""simple docstring"""







						__UpperCamelCase				:  Tuple								=			TFDebertaForMaskedLM(config=lowerCAmelCase  )
						__UpperCamelCase				:  Dict								=			{
						    """input_ids""": input_ids,
						    """attention_mask""": input_mask,
						    """token_type_ids""": token_type_ids,
						}
						__UpperCamelCase				:  Union[str, Any]								=			model(lowerCAmelCase  )
						self.parent.assertEqual(result.logits.shape				,    (self.batch_size, self.seq_length, self.vocab_size)  )






	def 				lowerCamelCase__    (				self		:	str				,    lowerCAmelCase		:	List[str]				,    lowerCAmelCase		:	List[Any]				,    lowerCAmelCase		:	str				,    lowerCAmelCase		:	List[str]				,    lowerCAmelCase		:	Union[str, Any]				,    lowerCAmelCase		:	str				,    lowerCAmelCase		:	str  )  ->					Any:







						"""simple docstring"""







						__UpperCamelCase				:  List[Any]								=			self.num_labels
						__UpperCamelCase				:  Optional[Any]								=			TFDebertaForSequenceClassification(config=lowerCAmelCase  )
						__UpperCamelCase				:  Any								=			{
						    """input_ids""": input_ids,
						    """attention_mask""": input_mask,
						    """token_type_ids""": token_type_ids,
						}

						__UpperCamelCase				:  Any								=			model(lowerCAmelCase  )
						self.parent.assertEqual(result.logits.shape				,    (self.batch_size, self.num_labels)  )






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







						"""simple docstring"""







						__UpperCamelCase				:  List[Any]								=			self.num_labels
						__UpperCamelCase				:  Optional[Any]								=			TFDebertaForTokenClassification(config=lowerCAmelCase  )
						__UpperCamelCase				:  List[Any]								=			{
						    """input_ids""": input_ids,
						    """attention_mask""": input_mask,
						    """token_type_ids""": token_type_ids,
						}
						__UpperCamelCase				:  int								=			model(lowerCAmelCase  )
						self.parent.assertEqual(result.logits.shape				,    (self.batch_size, self.seq_length, self.num_labels)  )






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







						"""simple docstring"""







						__UpperCamelCase				:  Optional[Any]								=			TFDebertaForQuestionAnswering(config=lowerCAmelCase  )
						__UpperCamelCase				:  int								=			{
						    """input_ids""": input_ids,
						    """attention_mask""": input_mask,
						    """token_type_ids""": token_type_ids,
						}

						__UpperCamelCase				:  Tuple								=			model(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 				lowerCamelCase__    (				self		:	Optional[Any]  )  ->					Optional[int]:







						"""simple docstring"""







						__UpperCamelCase				:  Tuple								=			self.prepare_config_and_inputs()
						(
						    (
						    __UpperCamelCase
						)			, (
						    __UpperCamelCase
						)			, (
						    __UpperCamelCase
						)			, (
						    __UpperCamelCase
						)			, (
						    __UpperCamelCase
						)			, (
						    __UpperCamelCase
						)			, (
						    __UpperCamelCase
						)			, 
						)				:  int								=			config_and_inputs
						__UpperCamelCase				:  str								=			{"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
						return config, inputs_dict






@require_tf
class       SCREAMING_SNAKE_CASE_							(					_UpperCamelCase  ,     _UpperCamelCase  ,     unittest.TestCase      ):



	"""simple docstring"""


	__magic_name__      :					str			  =		(
	    (
	        TFDebertaModel,
	        TFDebertaForMaskedLM,
	        TFDebertaForQuestionAnswering,
	        TFDebertaForSequenceClassification,
	        TFDebertaForTokenClassification,
	    )
	    if is_tf_available()
	    else ()
	)
	__magic_name__      :					Optional[Any]			  =		(
	    {
	        'feature-extraction': TFDebertaModel,
	        'fill-mask': TFDebertaForMaskedLM,
	        'question-answering': TFDebertaForQuestionAnswering,
	        'text-classification': TFDebertaForSequenceClassification,
	        'token-classification': TFDebertaForTokenClassification,
	        'zero-shot': TFDebertaForSequenceClassification,
	    }
	    if is_tf_available()
	    else {}
	)

	__magic_name__      :					int			  =		False
	__magic_name__      :					List[str]			  =		False






	def 				lowerCamelCase__    (				self		:	Tuple  )  ->					int:







						"""simple docstring"""







						__UpperCamelCase				:  str								=			TFDebertaModelTester(self  )
						__UpperCamelCase				:  Union[str, Any]								=			ConfigTester(self				,    config_class=lowerCAmelCase				,    hidden_size=37  )






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







						"""simple docstring"""







						self.config_tester.run_common_tests()






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







						"""simple docstring"""







						__UpperCamelCase				:  List[Any]								=			self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_model(*lowerCAmelCase  )






	def 				lowerCamelCase__    (				self		:	List[Any]  )  ->					Optional[Any]:







						"""simple docstring"""







						__UpperCamelCase				:  Dict								=			self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_masked_lm(*lowerCAmelCase  )






	def 				lowerCamelCase__    (				self		:	Dict  )  ->					int:







						"""simple docstring"""







						__UpperCamelCase				:  Any								=			self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_question_answering(*lowerCAmelCase  )






	def 				lowerCamelCase__    (				self		:	Tuple  )  ->					Any:







						"""simple docstring"""







						__UpperCamelCase				:  Dict								=			self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_sequence_classification(*lowerCAmelCase  )






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







						"""simple docstring"""







						__UpperCamelCase				:  str								=			self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_token_classification(*lowerCAmelCase  )






	@slow
	def 				lowerCamelCase__    (				self		:	Union[str, Any]  )  ->					Tuple:







						"""simple docstring"""







						__UpperCamelCase				:  List[str]								=			TFDebertaModel.from_pretrained("""kamalkraj/deberta-base"""  )
						self.assertIsNotNone(lowerCAmelCase  )






@require_tf
class       SCREAMING_SNAKE_CASE_							(					unittest.TestCase      ):



	"""simple docstring"""


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







						"""simple docstring"""







						pass






	@slow
	def 				lowerCamelCase__    (				self		:	Tuple  )  ->					List[Any]:







						"""simple docstring"""







						__UpperCamelCase				:  str								=			TFDebertaModel.from_pretrained("""kamalkraj/deberta-base"""  )
						__UpperCamelCase				:  Optional[int]								=			tf.constant([[0, 31414, 232, 328, 740, 1140, 12695, 69, 46078, 1588, 2]]  )
						__UpperCamelCase				:  int								=			tf.constant([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]  )
						__UpperCamelCase				:  Tuple								=			model(lowerCAmelCase				,    attention_mask=lowerCAmelCase  )[0]

						__UpperCamelCase				:  Any								=			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]				,    lowerCAmelCase				,    atol=1E-4  )






