code: 
  
  
  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 						snake_case			:
  			'''simple docstring'''
  
  			def __init__(	self     :     Tuple							,							lowerCAmelCase_     :     Union[str, Any]							,							lowerCAmelCase_     :     str=13							,							lowerCAmelCase_     :     Union[str, Any]=7							,							lowerCAmelCase_     :     Union[str, Any]=True							,							lowerCAmelCase_     :     List[str]=True							,							lowerCAmelCase_     :     Dict=True							,							lowerCAmelCase_     :     str=True							,							lowerCAmelCase_     :     Any=99							,							lowerCAmelCase_     :     int=32							,							lowerCAmelCase_     :     Tuple=2							,							lowerCAmelCase_     :     int=4							,							lowerCAmelCase_     :     Tuple=37							,							lowerCAmelCase_     :     Optional[int]="gelu"							,							lowerCAmelCase_     :     List[str]=0.1							,							lowerCAmelCase_     :     Optional[Any]=0.1							,							lowerCAmelCase_     :     Optional[int]=512							,							lowerCAmelCase_     :     Optional[Any]=16							,							lowerCAmelCase_     :     List[str]=2							,							lowerCAmelCase_     :     Optional[Any]=0.02							,							lowerCAmelCase_     :     Any=3							,							lowerCAmelCase_     :     List[Any]=4							,							lowerCAmelCase_     :     Optional[Any]=None							,							)					->					List[str]:
  
  
  
  
  								"""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 _lowercase (	self     :     List[Any]					)					->					Union[str, 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=lowerCAmelCase_							,							)
  
  								return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels
  
  			def _lowercase (	self     :     str							,							lowerCAmelCase_     :     Any							,							lowerCAmelCase_     :     Tuple							,							lowerCAmelCase_     :     Union[str, Any]							,							lowerCAmelCase_     :     Tuple							,							lowerCAmelCase_     :     int							,							lowerCAmelCase_     :     Optional[int]							,							lowerCAmelCase_     :     str					)					->					str:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								SCREAMING_SNAKE_CASE_	      =       TFDebertaModel(config=lowerCAmelCase_					)
  								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(lowerCAmelCase_					)
  
  								SCREAMING_SNAKE_CASE_	      =       model(lowerCAmelCase_					)
  
  								self.parent.assertEqual(result.last_hidden_state.shape							,							(self.batch_size, self.seq_length, self.hidden_size)					)
  
  			def _lowercase (	self     :     Optional[Any]							,							lowerCAmelCase_     :     Dict							,							lowerCAmelCase_     :     List[Any]							,							lowerCAmelCase_     :     Optional[int]							,							lowerCAmelCase_     :     int							,							lowerCAmelCase_     :     List[str]							,							lowerCAmelCase_     :     Optional[Any]							,							lowerCAmelCase_     :     Optional[Any]					)					->					List[str]:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								SCREAMING_SNAKE_CASE_	      =       TFDebertaForMaskedLM(config=lowerCAmelCase_					)
  								SCREAMING_SNAKE_CASE_	      =       {
  								    '''input_ids''': input_ids,
  								    '''attention_mask''': input_mask,
  								    '''token_type_ids''': token_type_ids,
  								}
  								SCREAMING_SNAKE_CASE_	      =       model(lowerCAmelCase_					)
  								self.parent.assertEqual(result.logits.shape							,							(self.batch_size, self.seq_length, self.vocab_size)					)
  
  			def _lowercase (	self     :     str							,							lowerCAmelCase_     :     Union[str, Any]							,							lowerCAmelCase_     :     Optional[Any]							,							lowerCAmelCase_     :     Optional[Any]							,							lowerCAmelCase_     :     Any							,							lowerCAmelCase_     :     Any							,							lowerCAmelCase_     :     List[str]							,							lowerCAmelCase_     :     List[Any]					)					->					Optional[Any]:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								SCREAMING_SNAKE_CASE_	      =       self.num_labels
  								SCREAMING_SNAKE_CASE_	      =       TFDebertaForSequenceClassification(config=lowerCAmelCase_					)
  								SCREAMING_SNAKE_CASE_	      =       {
  								    '''input_ids''': input_ids,
  								    '''attention_mask''': input_mask,
  								    '''token_type_ids''': token_type_ids,
  								}
  
  								SCREAMING_SNAKE_CASE_	      =       model(lowerCAmelCase_					)
  								self.parent.assertEqual(result.logits.shape							,							(self.batch_size, self.num_labels)					)
  
  			def _lowercase (	self     :     str							,							lowerCAmelCase_     :     List[Any]							,							lowerCAmelCase_     :     Optional[Any]							,							lowerCAmelCase_     :     str							,							lowerCAmelCase_     :     List[str]							,							lowerCAmelCase_     :     Union[str, Any]							,							lowerCAmelCase_     :     List[str]							,							lowerCAmelCase_     :     Optional[int]					)					->					Dict:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								SCREAMING_SNAKE_CASE_	      =       self.num_labels
  								SCREAMING_SNAKE_CASE_	      =       TFDebertaForTokenClassification(config=lowerCAmelCase_					)
  								SCREAMING_SNAKE_CASE_	      =       {
  								    '''input_ids''': input_ids,
  								    '''attention_mask''': input_mask,
  								    '''token_type_ids''': token_type_ids,
  								}
  								SCREAMING_SNAKE_CASE_	      =       model(lowerCAmelCase_					)
  								self.parent.assertEqual(result.logits.shape							,							(self.batch_size, self.seq_length, self.num_labels)					)
  
  			def _lowercase (	self     :     Optional[Any]							,							lowerCAmelCase_     :     str							,							lowerCAmelCase_     :     Any							,							lowerCAmelCase_     :     Optional[Any]							,							lowerCAmelCase_     :     Optional[Any]							,							lowerCAmelCase_     :     int							,							lowerCAmelCase_     :     Optional[Any]							,							lowerCAmelCase_     :     Optional[int]					)					->					str:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								SCREAMING_SNAKE_CASE_	      =       TFDebertaForQuestionAnswering(config=lowerCAmelCase_					)
  								SCREAMING_SNAKE_CASE_	      =       {
  								    '''input_ids''': input_ids,
  								    '''attention_mask''': input_mask,
  								    '''token_type_ids''': token_type_ids,
  								}
  
  								SCREAMING_SNAKE_CASE_	      =       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 _lowercase (	self     :     Tuple					)					->					Dict:
  
  
  
  
  								"""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 						snake_case			(       UpperCAmelCase_	, UpperCAmelCase_	, unittest.TestCase	):
  			'''simple docstring'''
  
  			UpperCAmelCase       :       str       = (
  			    (
  			        TFDebertaModel,
  			        TFDebertaForMaskedLM,
  			        TFDebertaForQuestionAnswering,
  			        TFDebertaForSequenceClassification,
  			        TFDebertaForTokenClassification,
  			    )
  			    if is_tf_available()
  			    else ()
  			)
  			UpperCAmelCase       :       Optional[int]       = (
  			    {
  			        """feature-extraction""": TFDebertaModel,
  			        """fill-mask""": TFDebertaForMaskedLM,
  			        """question-answering""": TFDebertaForQuestionAnswering,
  			        """text-classification""": TFDebertaForSequenceClassification,
  			        """token-classification""": TFDebertaForTokenClassification,
  			        """zero-shot""": TFDebertaForSequenceClassification,
  			    }
  			    if is_tf_available()
  			    else {}
  			)
  
  			UpperCAmelCase       :       str       = False
  			UpperCAmelCase       :       Optional[int]       = False
  
  			def _lowercase (	self     :     List[str]					)					->					Dict:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								SCREAMING_SNAKE_CASE_	      =       TFDebertaModelTester(self					)
  								SCREAMING_SNAKE_CASE_	      =       ConfigTester(self							,							config_class=lowerCAmelCase_							,							hidden_size=37					)
  
  			def _lowercase (	self     :     List[str]					)					->					Union[str, Any]:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								self.config_tester.run_common_tests()
  
  			def _lowercase (	self     :     Any					)					->					Optional[Any]:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								SCREAMING_SNAKE_CASE_	      =       self.model_tester.prepare_config_and_inputs()
  								self.model_tester.create_and_check_model(*lowerCAmelCase_					)
  
  			def _lowercase (	self     :     Optional[Any]					)					->					int:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								SCREAMING_SNAKE_CASE_	      =       self.model_tester.prepare_config_and_inputs()
  								self.model_tester.create_and_check_for_masked_lm(*lowerCAmelCase_					)
  
  			def _lowercase (	self     :     Dict					)					->					str:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								SCREAMING_SNAKE_CASE_	      =       self.model_tester.prepare_config_and_inputs()
  								self.model_tester.create_and_check_for_question_answering(*lowerCAmelCase_					)
  
  			def _lowercase (	self     :     Optional[Any]					)					->					Union[str, Any]:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								SCREAMING_SNAKE_CASE_	      =       self.model_tester.prepare_config_and_inputs()
  								self.model_tester.create_and_check_for_sequence_classification(*lowerCAmelCase_					)
  
  			def _lowercase (	self     :     Tuple					)					->					Optional[Any]:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								SCREAMING_SNAKE_CASE_	      =       self.model_tester.prepare_config_and_inputs()
  								self.model_tester.create_and_check_for_token_classification(*lowerCAmelCase_					)
  
  
  
  
  			@slow
  			def _lowercase (	self     :     Union[str, Any]					)					->					Dict:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								SCREAMING_SNAKE_CASE_	      =       TFDebertaModel.from_pretrained('''kamalkraj/deberta-base'''					)
  								self.assertIsNotNone(lowerCAmelCase_					)
  
  @require_tf
  class 						snake_case			(       unittest.TestCase	):
  			'''simple docstring'''
  
  			@unittest.skip(reason='''Model not available yet'''					)
  			def _lowercase (	self     :     List[str]					)					->					int:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								pass
  
  
  
  
  			@slow
  			def _lowercase (	self     :     int					)					->					Optional[int]:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								SCREAMING_SNAKE_CASE_	      =       TFDebertaModel.from_pretrained('''kamalkraj/deberta-base'''					)
  								SCREAMING_SNAKE_CASE_	      =       tf.constant([[0, 31_414, 232, 328, 740, 1_140, 12_695, 69, 46_078, 1_588, 2]]					)
  								SCREAMING_SNAKE_CASE_	      =       tf.constant([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]					)
  								SCREAMING_SNAKE_CASE_	      =       model(lowerCAmelCase_							,							attention_mask=lowerCAmelCase_					)[0]
  
  								SCREAMING_SNAKE_CASE_	      =       tf.constant(
  								    [
  								        [
  								            [-0.59_855_896, -0.80_552_566, -0.8_462_135],
  								            [1.4_484_025, -0.93_483_794, -0.80_593_085],
  								            [0.3_122_741, 0.00_316_059, -1.4_131_377],
  								        ]
  								    ]					)
  								tf.debugging.assert_near(output[:, 1:4, 1:4]							,							lowerCAmelCase_							,							atol=1e-4					)
  
  
  
style_context: 
  
  
  def 							UpperCAmelCase				(     UpperCAmelCase				,UpperCAmelCase      )->		int:
  
  
  
  
  
  
  
  					'''simple docstring'''
  
  
  
  					return (input_a, input_a).count(0      ) % 2
  
  
  
  
  
  
  
  def 							UpperCAmelCase				(     )->		None:
  
  
  
  
  
  
  
  					'''simple docstring'''
  
  
  
  					assert xor_gate(0				,0      ) == 0
  					assert xor_gate(0				,1      ) == 1
  					assert xor_gate(1				,0      ) == 1
  					assert xor_gate(1				,1      ) == 0
  
  
  if __name__ == "__main__":
  		print(xor_gate(0, 0))
  		print(xor_gate(0, 1))
  
  
  