






"""simple docstring"""


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


   '''simple docstring'''

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

     '''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 				_SCREAMING_SNAKE_CASE				(	self :     Tuple  ):

     '''simple docstring'''
     __A									= ids_tensor([self.batch_size, self.seq_length],       self.vocab_size  )

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

     __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									= 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=_lowerCamelCase,       )

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


   def 				_SCREAMING_SNAKE_CASE				(	self :     Dict,       _lowerCamelCase :     Union[str, Any],       _lowerCamelCase :     Any,       _lowerCamelCase :     Optional[int],       _lowerCamelCase :     str,       _lowerCamelCase :     Optional[int],       _lowerCamelCase :     Tuple,       _lowerCamelCase :     List[str]  ):

     '''simple docstring'''
     __A									= TFDebertaVaModel(config=_lowerCamelCase  )
     __A									= {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}

     __A									= [input_ids, input_mask]
     __A									= model(_lowerCamelCase  )

     __A									= model(_lowerCamelCase  )

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


   def 				_SCREAMING_SNAKE_CASE				(	self :     int,       _lowerCamelCase :     int,       _lowerCamelCase :     Union[str, Any],       _lowerCamelCase :     Tuple,       _lowerCamelCase :     Optional[Any],       _lowerCamelCase :     Optional[int],       _lowerCamelCase :     int,       _lowerCamelCase :     Optional[int]  ):

     '''simple docstring'''
     __A									= TFDebertaVaForMaskedLM(config=_lowerCamelCase  )
     __A									= {
         '''input_ids''': input_ids,
         '''attention_mask''': input_mask,
         '''token_type_ids''': token_type_ids,
     }
     __A									= model(_lowerCamelCase  )
     self.parent.assertEqual(result.logits.shape,       (self.batch_size, self.seq_length, self.vocab_size)  )


   def 				_SCREAMING_SNAKE_CASE				(	self :     Any,       _lowerCamelCase :     Optional[int],       _lowerCamelCase :     Union[str, Any],       _lowerCamelCase :     Union[str, Any],       _lowerCamelCase :     Tuple,       _lowerCamelCase :     Any,       _lowerCamelCase :     Optional[int],       _lowerCamelCase :     Any  ):

     '''simple docstring'''
     __A									= self.num_labels
     __A									= TFDebertaVaForSequenceClassification(config=_lowerCamelCase  )
     __A									= {
         '''input_ids''': input_ids,
         '''attention_mask''': input_mask,
         '''token_type_ids''': token_type_ids,
     }

     __A									= model(_lowerCamelCase  )
     self.parent.assertEqual(result.logits.shape,       (self.batch_size, self.num_labels)  )


   def 				_SCREAMING_SNAKE_CASE				(	self :     Union[str, Any],       _lowerCamelCase :     str,       _lowerCamelCase :     List[Any],       _lowerCamelCase :     Any,       _lowerCamelCase :     Union[str, Any],       _lowerCamelCase :     int,       _lowerCamelCase :     Tuple,       _lowerCamelCase :     Optional[int]  ):

     '''simple docstring'''
     __A									= self.num_labels
     __A									= TFDebertaVaForTokenClassification(config=_lowerCamelCase  )
     __A									= {
         '''input_ids''': input_ids,
         '''attention_mask''': input_mask,
         '''token_type_ids''': token_type_ids,
     }
     __A									= model(_lowerCamelCase  )
     self.parent.assertEqual(result.logits.shape,       (self.batch_size, self.seq_length, self.num_labels)  )


   def 				_SCREAMING_SNAKE_CASE				(	self :     List[Any],       _lowerCamelCase :     Optional[int],       _lowerCamelCase :     str,       _lowerCamelCase :     Optional[int],       _lowerCamelCase :     Dict,       _lowerCamelCase :     Union[str, Any],       _lowerCamelCase :     int,       _lowerCamelCase :     List[str]  ):

     '''simple docstring'''
     __A									= TFDebertaVaForQuestionAnswering(config=_lowerCamelCase  )
     __A									= {
         '''input_ids''': input_ids,
         '''attention_mask''': input_mask,
         '''token_type_ids''': token_type_ids,
     }

     __A									= 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 				_SCREAMING_SNAKE_CASE				(	self :     Tuple  ):

     '''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_tf
class 					snake_case		(							_lowerCAmelCase   ,	_lowerCAmelCase   ,	unittest.TestCase						):


   '''simple docstring'''

   A_						:	List[Any]						 = (
       (
           TFDebertaVaModel,
           TFDebertaVaForMaskedLM,
           TFDebertaVaForQuestionAnswering,
           TFDebertaVaForSequenceClassification,
           TFDebertaVaForTokenClassification,
       )
       if is_tf_available()
       else ()
   )
   A_						:	Optional[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_						:	List[Any]						 = False
   A_						:	List[str]						 = False


   def 				_SCREAMING_SNAKE_CASE				(	self :     Any  ):

     '''simple docstring'''
     __A									= TFDebertaVaModelTester(self  )
     __A									= ConfigTester(self,       config_class=_lowerCamelCase,       hidden_size=37  )


   def 				_SCREAMING_SNAKE_CASE				(	self :     Dict  ):

     '''simple docstring'''
     self.config_tester.run_common_tests()


   def 				_SCREAMING_SNAKE_CASE				(	self :     List[str]  ):

     '''simple docstring'''
     __A									= self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_model(*_lowerCamelCase  )


   def 				_SCREAMING_SNAKE_CASE				(	self :     Optional[int]  ):

     '''simple docstring'''
     __A									= self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_masked_lm(*_lowerCamelCase  )


   def 				_SCREAMING_SNAKE_CASE				(	self :     int  ):

     '''simple docstring'''
     __A									= self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_question_answering(*_lowerCamelCase  )


   def 				_SCREAMING_SNAKE_CASE				(	self :     List[Any]  ):

     '''simple docstring'''
     __A									= self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_sequence_classification(*_lowerCamelCase  )


   def 				_SCREAMING_SNAKE_CASE				(	self :     List[str]  ):

     '''simple docstring'''
     __A									= self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_token_classification(*_lowerCamelCase  )






   @slow
   def 				_SCREAMING_SNAKE_CASE				(	self :     List[str]  ):

     '''simple docstring'''
     __A									= TFDebertaVaModel.from_pretrained('''kamalkraj/deberta-v2-xlarge'''  )
     self.assertIsNotNone(_lowerCamelCase  )





@require_tf
class 					snake_case		(							unittest.TestCase						):


   '''simple docstring'''

   @unittest.skip(reason='''Model not available yet'''  )
   def 				_SCREAMING_SNAKE_CASE				(	self :     int  ):

     '''simple docstring'''
     pass






   @slow
   def 				_SCREAMING_SNAKE_CASE				(	self :     Tuple  ):

     '''simple docstring'''
     __A									= TFDebertaVaModel.from_pretrained('''kamalkraj/deberta-v2-xlarge'''  )
     __A									= tf.constant([[0, 3_14_14, 2_32, 3_28, 7_40, 11_40, 1_26_95, 69, 4_60_78, 15_88, 2]]  )
     __A									= tf.constant([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]  )
     __A									= model(_lowerCamelCase,       attention_mask=_lowerCamelCase  )[0]

     __A									= 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],       _lowerCamelCase,       atol=1e-4  )












"""simple docstring"""


from __future__ import annotations


class 					snake_case		:


   '''simple docstring'''

   def __init__(	self :     int,       _lowerCamelCase :     List[Any]=None  ):

     '''simple docstring'''
     __A									= data
     __A									= None






   def __repr__(	self :     Union[str, Any]  ):

     '''simple docstring'''
     __A									= []
     __A									= self
     while temp:
       string_rep.append(f'{temp.data}'  )
       __A									= temp.next
     return "->".join(_lowerCamelCase  )





def 					lowerCAmelCase				(    __UpperCamelCase ):




  """simple docstring"""







  if not elements_list:
    raise Exception('''The Elements List is empty''' )

  __A									= __A									= Node(elements_list[0] )
  for i in range(1		,       len(__UpperCamelCase ) ):
    __A									= Node(elements_list[i] )
    __A									= current.next
  return head



def 					lowerCAmelCase				(    __UpperCamelCase ):




  """simple docstring"""







  if head_node is not None and isinstance(__UpperCamelCase		,       __UpperCamelCase ):
    print_reverse(head_node.next )
    print(head_node.data )



def 					lowerCAmelCase				(    ):




  """simple docstring"""







  from doctest import testmod

  testmod()

  __A									= make_linked_list([1_4, 5_2, 1_4, 1_2, 4_3] )
  print('''Linked List:''' )
  print(__UpperCamelCase )
  print('''Elements in Reverse:''' )
  print_reverse(__UpperCamelCase )


if __name__ == "__main__":
       main()




