

'''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      a      :






						"""simple docstring"""




						def __init__(				self       :   List[str]      ,      snake_case_       :   Any      ,      snake_case_       :   Dict=1_3      ,      snake_case_       :   List[Any]=7      ,      snake_case_       :   Dict=True      ,      snake_case_       :   Optional[Any]=True      ,      snake_case_       :   List[str]=True      ,      snake_case_       :   List[str]=True      ,      snake_case_       :   List[Any]=9_9      ,      snake_case_       :   Optional[int]=3_2      ,      snake_case_       :   Optional[Any]=2      ,      snake_case_       :   int=4      ,      snake_case_       :   Dict=3_7      ,      snake_case_       :   int="gelu"      ,      snake_case_       :   List[str]=0.1      ,      snake_case_       :   Dict=0.1      ,      snake_case_       :   Union[str, Any]=5_1_2      ,      snake_case_       :   List[Any]=1_6      ,      snake_case_       :   List[Any]=2      ,      snake_case_       :   Optional[Any]=0.0_2      ,      snake_case_       :   List[Any]=False      ,      snake_case_       :   Tuple=True      ,      snake_case_       :   int="None"      ,      snake_case_       :   Dict=3      ,      snake_case_       :   List[Any]=4      ,      snake_case_       :   Optional[int]=None      ,      ):



								'''simple docstring'''



								snake_case__    :							Optional[Any]							    =	parent
								snake_case__    :							List[str]							    =	batch_size
								snake_case__    :							str							    =	seq_length
								snake_case__    :							int							    =	is_training
								snake_case__    :							Optional[int]							    =	use_input_mask
								snake_case__    :							List[Any]							    =	use_token_type_ids
								snake_case__    :							List[str]							    =	use_labels
								snake_case__    :							List[Any]							    =	vocab_size
								snake_case__    :							str							    =	hidden_size
								snake_case__    :							Any							    =	num_hidden_layers
								snake_case__    :							Optional[int]							    =	num_attention_heads
								snake_case__    :							Dict							    =	intermediate_size
								snake_case__    :							Any							    =	hidden_act
								snake_case__    :							Any							    =	hidden_dropout_prob
								snake_case__    :							Dict							    =	attention_probs_dropout_prob
								snake_case__    :							Optional[int]							    =	max_position_embeddings
								snake_case__    :							str							    =	type_vocab_size
								snake_case__    :							Dict							    =	type_sequence_label_size
								snake_case__    :							Tuple							    =	initializer_range
								snake_case__    :							List[Any]							    =	num_labels
								snake_case__    :							Tuple							    =	num_choices
								snake_case__    :							int							    =	relative_attention
								snake_case__    :							List[str]							    =	position_biased_input
								snake_case__    :							str							    =	pos_att_type
								snake_case__    :							Optional[int]							    =	scope







						def    __magic_name__				(				self       :   Any	):



								'''simple docstring'''



								snake_case__    :							Optional[Any]							    =	ids_tensor([self.batch_size, self.seq_length]      ,      self.vocab_size	)

								snake_case__    :							Optional[int]							    =	None
								if self.use_input_mask:
										snake_case__    :							Union[str, Any]							    =	random_attention_mask([self.batch_size, self.seq_length]	)

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

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

								snake_case__    :							List[Any]							    =	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    __magic_name__				(				self       :   List[str]      ,      snake_case_       :   int      ,      snake_case_       :   Union[str, Any]      ,      snake_case_       :   List[Any]      ,      snake_case_       :   Optional[Any]      ,      snake_case_       :   int      ,      snake_case_       :   List[str]      ,      snake_case_       :   int	):



								'''simple docstring'''



								snake_case__    :							Optional[int]							    =	TFDebertaVaModel(config=_lowerCamelCase	)
								snake_case__    :							str							    =	{'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}

								snake_case__    :							Optional[int]							    =	[input_ids, input_mask]
								snake_case__    :							List[Any]							    =	model(_lowerCamelCase	)

								snake_case__    :							List[str]							    =	model(_lowerCamelCase	)

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







						def    __magic_name__				(				self       :   Optional[int]      ,      snake_case_       :   str      ,      snake_case_       :   Tuple      ,      snake_case_       :   Union[str, Any]      ,      snake_case_       :   List[Any]      ,      snake_case_       :   Any      ,      snake_case_       :   Tuple      ,      snake_case_       :   Optional[int]	):



								'''simple docstring'''



								snake_case__    :							Tuple							    =	TFDebertaVaForMaskedLM(config=_lowerCamelCase	)
								snake_case__    :							Optional[int]							    =	{
								    '''input_ids''': input_ids,
								    '''attention_mask''': input_mask,
								    '''token_type_ids''': token_type_ids,
								}
								snake_case__    :							Any							    =	model(_lowerCamelCase	)
								self.parent.assertEqual(result.logits.shape      ,      (self.batch_size, self.seq_length, self.vocab_size)	)







						def    __magic_name__				(				self       :   Any      ,      snake_case_       :   Union[str, Any]      ,      snake_case_       :   str      ,      snake_case_       :   Optional[int]      ,      snake_case_       :   Any      ,      snake_case_       :   Optional[int]      ,      snake_case_       :   Tuple      ,      snake_case_       :   List[Any]	):



								'''simple docstring'''



								snake_case__    :							Dict							    =	self.num_labels
								snake_case__    :							Optional[int]							    =	TFDebertaVaForSequenceClassification(config=_lowerCamelCase	)
								snake_case__    :							List[Any]							    =	{
								    '''input_ids''': input_ids,
								    '''attention_mask''': input_mask,
								    '''token_type_ids''': token_type_ids,
								}

								snake_case__    :							Optional[int]							    =	model(_lowerCamelCase	)
								self.parent.assertEqual(result.logits.shape      ,      (self.batch_size, self.num_labels)	)







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



								'''simple docstring'''



								snake_case__    :							Tuple							    =	self.num_labels
								snake_case__    :							int							    =	TFDebertaVaForTokenClassification(config=_lowerCamelCase	)
								snake_case__    :							List[str]							    =	{
								    '''input_ids''': input_ids,
								    '''attention_mask''': input_mask,
								    '''token_type_ids''': token_type_ids,
								}
								snake_case__    :							Optional[int]							    =	model(_lowerCamelCase	)
								self.parent.assertEqual(result.logits.shape      ,      (self.batch_size, self.seq_length, self.num_labels)	)







						def    __magic_name__				(				self       :   Any      ,      snake_case_       :   List[Any]      ,      snake_case_       :   str      ,      snake_case_       :   int      ,      snake_case_       :   List[str]      ,      snake_case_       :   List[str]      ,      snake_case_       :   int      ,      snake_case_       :   Any	):



								'''simple docstring'''



								snake_case__    :							int							    =	TFDebertaVaForQuestionAnswering(config=_lowerCamelCase	)
								snake_case__    :							Union[str, Any]							    =	{
								    '''input_ids''': input_ids,
								    '''attention_mask''': input_mask,
								    '''token_type_ids''': token_type_ids,
								}

								snake_case__    :							Any							    =	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    __magic_name__				(				self       :   Optional[Any]	):



								'''simple docstring'''



								snake_case__    :							int							    =	self.prepare_config_and_inputs()
								(
								    (
								    snake_case__
								)    ,							(
								    snake_case__
								)    ,							(
								    snake_case__
								)    ,							(
								    snake_case__
								)    ,							(
								    snake_case__
								)    ,							(
								    snake_case__
								)    ,							(
								    snake_case__
								)    ,							
								)    :							List[Any]							    =	config_and_inputs
								snake_case__    :							Dict							    =	{'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
								return config, inputs_dict





@require_tf
class      a      (					__a      ,      __a      ,      unittest.TestCase							):






						"""simple docstring"""




						__UpperCAmelCase        =     (
						    (
						        TFDebertaVaModel,
						        TFDebertaVaForMaskedLM,
						        TFDebertaVaForQuestionAnswering,
						        TFDebertaVaForSequenceClassification,
						        TFDebertaVaForTokenClassification,
						    )
						    if is_tf_available()
						    else ()
						)
						__UpperCAmelCase        =     (
						    {
						        'feature-extraction': TFDebertaVaModel,
						        'fill-mask': TFDebertaVaForMaskedLM,
						        'question-answering': TFDebertaVaForQuestionAnswering,
						        'text-classification': TFDebertaVaForSequenceClassification,
						        'token-classification': TFDebertaVaForTokenClassification,
						        'zero-shot': TFDebertaVaForSequenceClassification,
						    }
						    if is_tf_available()
						    else {}
						)

						__UpperCAmelCase        =     False
						__UpperCAmelCase        =     False







						def    __magic_name__				(				self       :   Tuple	):



								'''simple docstring'''



								snake_case__    :							Any							    =	TFDebertaVaModelTester(self	)
								snake_case__    :							Optional[int]							    =	ConfigTester(self      ,      config_class=_lowerCamelCase      ,      hidden_size=3_7	)







						def    __magic_name__				(				self       :   Dict	):



								'''simple docstring'''



								self.config_tester.run_common_tests()







						def    __magic_name__				(				self       :   Tuple	):



								'''simple docstring'''



								snake_case__    :							Union[str, Any]							    =	self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_model(*_lowerCamelCase	)







						def    __magic_name__				(				self       :   Dict	):



								'''simple docstring'''



								snake_case__    :							Dict							    =	self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_masked_lm(*_lowerCamelCase	)







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



								'''simple docstring'''



								snake_case__    :							Tuple							    =	self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_question_answering(*_lowerCamelCase	)







						def    __magic_name__				(				self       :   Optional[Any]	):



								'''simple docstring'''



								snake_case__    :							Any							    =	self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_sequence_classification(*_lowerCamelCase	)







						def    __magic_name__				(				self       :   Tuple	):



								'''simple docstring'''



								snake_case__    :							Any							    =	self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_token_classification(*_lowerCamelCase	)







						@slow
						def    __magic_name__				(				self       :   List[Any]	):



								'''simple docstring'''



								snake_case__    :							str							    =	TFDebertaVaModel.from_pretrained('''kamalkraj/deberta-v2-xlarge'''	)
								self.assertIsNotNone(_lowerCamelCase	)





@require_tf
class      a      (					unittest.TestCase							):






						"""simple docstring"""




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



								'''simple docstring'''



								pass







						@slow
						def    __magic_name__				(				self       :   str	):



								'''simple docstring'''



								snake_case__    :							List[Any]							    =	TFDebertaVaModel.from_pretrained('''kamalkraj/deberta-v2-xlarge'''	)
								snake_case__    :							List[str]							    =	tf.constant([[0, 3_1_4_1_4, 2_3_2, 3_2_8, 7_4_0, 1_1_4_0, 1_2_6_9_5, 6_9, 4_6_0_7_8, 1_5_8_8, 2]]	)
								snake_case__    :							Optional[Any]							    =	tf.constant([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]	)
								snake_case__    :							Optional[Any]							    =	model(_lowerCamelCase      ,      attention_mask=_lowerCamelCase	)[0]

								snake_case__    :							str							    =	tf.constant(
								    [[[0.2_3_5_6, 0.1_9_4_8, 0.0_3_6_9], [-0.1_0_6_3, 0.3_5_8_6, -0.5_1_5_2], [-0.6_3_9_9, -0.0_2_5_9, -0.2_5_2_5]]]	)
								tf.debugging.assert_near(output[:, 1:4, 1:4]      ,      _lowerCamelCase      ,      atol=1e-4	)




'''simple docstring'''

from __future__ import annotations



def snake_case_      (					__snake_case  :							list[int | str])			->					None:
   create_state_space_tree(__snake_case	,   []	,   0	,   [0 for i in range(len(__snake_case))])



def snake_case_      (					__snake_case  :							list[int | str]	,   __snake_case  :							list[int | str]	,   __snake_case  :							int	,   __snake_case  :							list[int]	,   )			->					None:

   if index == len(__snake_case):
      print(__snake_case)
      return

   for i in range(len(__snake_case)):
      if not index_used[i]:
         current_sequence.append(sequence[i])
         lowerCAmelCase_			=      True
         create_state_space_tree(__snake_case	,   __snake_case	,   index + 1	,   __snake_case)
         current_sequence.pop()
         lowerCAmelCase_			=      False
A_     :						list[int | str]    							=[3, 1, 2, 4]
generate_all_permutations(sequence)

A_     :						list[int | str]    							=["A", "B", "C"]






generate_all_permutations(sequence_a)





