





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     (SCREAMING_SNAKE_CASE       ):
			'''simple docstring'''




			def __init__(     self  :       Dict				,      __lowerCAmelCase  :       List[str]				,      __lowerCAmelCase  :       Any=13				,      __lowerCAmelCase  :       List[str]=7				,      __lowerCAmelCase  :       Any=True				,      __lowerCAmelCase  :       Dict=True				,      __lowerCAmelCase  :       List[str]=True				,      __lowerCAmelCase  :       Dict=True				,      __lowerCAmelCase  :       Optional[Any]=99				,      __lowerCAmelCase  :       Optional[int]=32				,      __lowerCAmelCase  :       List[str]=5				,      __lowerCAmelCase  :       Union[str, Any]=4				,      __lowerCAmelCase  :       List[Any]=37				,      __lowerCAmelCase  :       Tuple="gelu"				,      __lowerCAmelCase  :       Tuple=0.1				,      __lowerCAmelCase  :       Dict=0.1				,      __lowerCAmelCase  :       List[Any]=5_12				,      __lowerCAmelCase  :       Any=16				,      __lowerCAmelCase  :       Dict=2				,      __lowerCAmelCase  :       Optional[Any]=0.0_2				,      __lowerCAmelCase  :       List[str]=False				,      __lowerCAmelCase  :       Any=True				,      __lowerCAmelCase  :       str="None"				,      __lowerCAmelCase  :       Any=3				,      __lowerCAmelCase  :       Tuple=4				,      __lowerCAmelCase  :       Any=None				,      )      ->      Dict:







					"""simple docstring"""






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






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







					"""simple docstring"""






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

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

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

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

					A__     =  self.get_config()

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






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







					"""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   a_			(     self  :       List[Any]  )      ->      Optional[int]:







					"""simple docstring"""






					A__     =  self.get_config()
					A__     =  3_00
					return config






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







					"""simple docstring"""






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






			def   a_			(     self  :       int				,      __lowerCAmelCase  :       Any				,      __lowerCAmelCase  :       Tuple				,      __lowerCAmelCase  :       Any				,      __lowerCAmelCase  :       Optional[int]				,      __lowerCAmelCase  :       List[Any]				,      __lowerCAmelCase  :       Tuple				,      __lowerCAmelCase  :       Tuple  )      ->      Optional[int]:







					"""simple docstring"""






					A__     =  DebertaModel(config=__lowerCAmelCase  )
					model.to(__lowerCAmelCase  )
					model.eval()
					A__     =  model(__lowerCAmelCase				,      attention_mask=__lowerCAmelCase				,      token_type_ids=__lowerCAmelCase  )[0]
					A__     =  model(__lowerCAmelCase				,      token_type_ids=__lowerCAmelCase  )[0]
					A__     =  model(__lowerCAmelCase  )[0]

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






			def   a_			(     self  :       Tuple				,      __lowerCAmelCase  :       List[Any]				,      __lowerCAmelCase  :       Dict				,      __lowerCAmelCase  :       Union[str, Any]				,      __lowerCAmelCase  :       int				,      __lowerCAmelCase  :       List[str]				,      __lowerCAmelCase  :       Union[str, Any]				,      __lowerCAmelCase  :       Union[str, Any]  )      ->      Optional[int]:







					"""simple docstring"""






					A__     =  DebertaForMaskedLM(config=__lowerCAmelCase  )
					model.to(__lowerCAmelCase  )
					model.eval()
					A__     =  model(__lowerCAmelCase				,      attention_mask=__lowerCAmelCase				,      token_type_ids=__lowerCAmelCase				,      labels=__lowerCAmelCase  )

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






			def   a_			(     self  :       Optional[Any]				,      __lowerCAmelCase  :       Tuple				,      __lowerCAmelCase  :       Optional[Any]				,      __lowerCAmelCase  :       Dict				,      __lowerCAmelCase  :       Optional[int]				,      __lowerCAmelCase  :       Optional[Any]				,      __lowerCAmelCase  :       List[str]				,      __lowerCAmelCase  :       Any  )      ->      Optional[int]:







					"""simple docstring"""






					A__     =  self.num_labels
					A__     =  DebertaForSequenceClassification(__lowerCAmelCase  )
					model.to(__lowerCAmelCase  )
					model.eval()
					A__     =  model(__lowerCAmelCase				,      attention_mask=__lowerCAmelCase				,      token_type_ids=__lowerCAmelCase				,      labels=__lowerCAmelCase  )
					self.parent.assertListEqual(list(result.logits.size()  )				,      [self.batch_size, self.num_labels]  )
					self.check_loss_output(__lowerCAmelCase  )






			def   a_			(     self  :       List[str]				,      __lowerCAmelCase  :       int				,      __lowerCAmelCase  :       int				,      __lowerCAmelCase  :       Any				,      __lowerCAmelCase  :       Tuple				,      __lowerCAmelCase  :       Optional[Any]				,      __lowerCAmelCase  :       Any				,      __lowerCAmelCase  :       Dict  )      ->      Any:







					"""simple docstring"""






					A__     =  self.num_labels
					A__     =  DebertaForTokenClassification(config=__lowerCAmelCase  )
					model.to(__lowerCAmelCase  )
					model.eval()
					A__     =  model(__lowerCAmelCase				,      attention_mask=__lowerCAmelCase				,      token_type_ids=__lowerCAmelCase				,      labels=__lowerCAmelCase  )
					self.parent.assertEqual(result.logits.shape				,      (self.batch_size, self.seq_length, self.num_labels)  )






			def   a_			(     self  :       str				,      __lowerCAmelCase  :       Optional[int]				,      __lowerCAmelCase  :       Any				,      __lowerCAmelCase  :       int				,      __lowerCAmelCase  :       str				,      __lowerCAmelCase  :       int				,      __lowerCAmelCase  :       Dict				,      __lowerCAmelCase  :       List[Any]  )      ->      Tuple:







					"""simple docstring"""






					A__     =  DebertaForQuestionAnswering(config=__lowerCAmelCase  )
					model.to(__lowerCAmelCase  )
					model.eval()
					A__     =  model(
					    __lowerCAmelCase				,      attention_mask=__lowerCAmelCase				,      token_type_ids=__lowerCAmelCase				,      start_positions=__lowerCAmelCase				,      end_positions=__lowerCAmelCase				,      )
					self.parent.assertEqual(result.start_logits.shape				,      (self.batch_size, self.seq_length)  )
					self.parent.assertEqual(result.end_logits.shape				,      (self.batch_size, self.seq_length)  )







			def   a_			(     self  :       Tuple  )      ->      List[str]:







					"""simple docstring"""






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


@require_torch
class     A     (SCREAMING_SNAKE_CASE  ,	SCREAMING_SNAKE_CASE  ,	unittest.TestCase       ):
			'''simple docstring'''




			__lowerCamelCase      :			Union[str, Any]							     =       (
			    (
			        DebertaModel,
			        DebertaForMaskedLM,
			        DebertaForSequenceClassification,
			        DebertaForTokenClassification,
			        DebertaForQuestionAnswering,
			    )
			    if is_torch_available()
			    else ()
			)
			__lowerCamelCase      :			str							     =       (
			    {
			        '''feature-extraction''': DebertaModel,
			        '''fill-mask''': DebertaForMaskedLM,
			        '''question-answering''': DebertaForQuestionAnswering,
			        '''text-classification''': DebertaForSequenceClassification,
			        '''token-classification''': DebertaForTokenClassification,
			        '''zero-shot''': DebertaForSequenceClassification,
			    }
			    if is_torch_available()
			    else {}
			)

			__lowerCamelCase      :			Optional[Any]							     =       True
			__lowerCamelCase      :			Union[str, Any]							     =       False
			__lowerCamelCase      :			Optional[int]							     =       False
			__lowerCamelCase      :			Optional[int]							     =       False
			__lowerCamelCase      :			List[Any]							     =       False






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







					"""simple docstring"""






					A__     =  DebertaModelTester(self  )
					A__     =  ConfigTester(self				,      config_class=__lowerCAmelCase				,      hidden_size=37  )






			def   a_			(     self  :       Any  )      ->      Dict:







					"""simple docstring"""






					self.config_tester.run_common_tests()






			def   a_			(     self  :       Tuple  )      ->      Union[str, Any]:







					"""simple docstring"""






					A__     =  self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_deberta_model(*__lowerCAmelCase  )






			def   a_			(     self  :       int  )      ->      List[str]:







					"""simple docstring"""






					A__     =  self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_deberta_for_sequence_classification(*__lowerCAmelCase  )






			def   a_			(     self  :       Any  )      ->      List[Any]:







					"""simple docstring"""






					A__     =  self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_deberta_for_masked_lm(*__lowerCAmelCase  )






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







					"""simple docstring"""






					A__     =  self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_deberta_for_question_answering(*__lowerCAmelCase  )






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







					"""simple docstring"""






					A__     =  self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_deberta_for_token_classification(*__lowerCAmelCase  )







			@slow
			def   a_			(     self  :       int  )      ->      Optional[Any]:







					"""simple docstring"""






					for model_name in DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
							A__     =  DebertaModel.from_pretrained(__lowerCAmelCase  )
							self.assertIsNotNone(__lowerCAmelCase  )


@require_torch
@require_sentencepiece
@require_tokenizers
class     A     (unittest.TestCase       ):
			'''simple docstring'''




			@unittest.skip(reason="""Model not available yet"""  )
			def   a_			(     self  :       Dict  )      ->      int:







					"""simple docstring"""






					pass







			@slow
			def   a_			(     self  :       Tuple  )      ->      Tuple:







					"""simple docstring"""






					A__     =  DebertaModel.from_pretrained("""microsoft/deberta-base"""  )

					A__     =  torch.tensor([[0, 3_14_14, 2_32, 3_28, 7_40, 11_40, 1_26_95, 69, 4_60_78, 15_88, 2]]  )
					A__     =  torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]  )
					with torch.no_grad():
							A__     =  model(__lowerCAmelCase				,      attention_mask=__lowerCAmelCase  )[0]
					# compare the actual values for a slice.
					A__     =  torch.tensor(
					    [[[-0.5_9_8_6, -0.8_0_5_5, -0.8_4_6_2], [1.4_4_8_4, -0.9_3_4_8, -0.8_0_5_9], [0.3_1_2_3, 0.0_0_3_2, -1.4_1_3_1]]]  )
					self.assertTrue(torch.allclose(output[:, 1:4, 1:4]				,      __lowerCAmelCase				,      atol=1e-4  )				,      f'{output[:, 1:4, 1:4]}'  )










def   __lowerCamelCase   (				__a  :int = 4_0_0_0_0_0_0       )						->							int:






		"""simple docstring"""

		A__     =  []
		A__ ,     A__     =  0, 1
		while b <= n:
				if b % 2 == 0:
						even_fibs.append(__a       )
				A__ ,     A__     =  b, a + b
		return sum(__a       )


if __name__ == "__main__":
					print(F'''{solution() = }''')



