



"""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   :			Any ,      __UpperCamelCase   :			Optional[int] ,      __UpperCamelCase   :			Any=1_3 ,      __UpperCamelCase   :			Union[str, Any]=7 ,      __UpperCamelCase   :			Dict=True ,      __UpperCamelCase   :			Optional[int]=True ,      __UpperCamelCase   :			Dict=True ,      __UpperCamelCase   :			int=True ,      __UpperCamelCase   :			str=9_9 ,      __UpperCamelCase   :			Tuple=3_2 ,      __UpperCamelCase   :			int=2 ,      __UpperCamelCase   :			Dict=4 ,      __UpperCamelCase   :			int=3_7 ,      __UpperCamelCase   :			Optional[int]="gelu" ,      __UpperCamelCase   :			Union[str, Any]=0.1 ,      __UpperCamelCase   :			int=0.1 ,      __UpperCamelCase   :			Any=5_1_2 ,      __UpperCamelCase   :			List[Any]=1_6 ,      __UpperCamelCase   :			List[Any]=2 ,      __UpperCamelCase   :			Dict=0.0_2 ,      __UpperCamelCase   :			Any=False ,      __UpperCamelCase   :			Any=True ,      __UpperCamelCase   :			Any="None" ,      __UpperCamelCase   :			List[Any]=3 ,      __UpperCamelCase   :			Any=4 ,      __UpperCamelCase   :			int=None ,      )->Tuple:
							_UpperCAmelCase							=			parent
							_UpperCAmelCase							=			batch_size
							_UpperCAmelCase							=			seq_length
							_UpperCAmelCase							=			is_training
							_UpperCAmelCase							=			use_input_mask
							_UpperCAmelCase							=			use_token_type_ids
							_UpperCAmelCase							=			use_labels
							_UpperCAmelCase							=			vocab_size
							_UpperCAmelCase							=			hidden_size
							_UpperCAmelCase							=			num_hidden_layers
							_UpperCAmelCase							=			num_attention_heads
							_UpperCAmelCase							=			intermediate_size
							_UpperCAmelCase							=			hidden_act
							_UpperCAmelCase							=			hidden_dropout_prob
							_UpperCAmelCase							=			attention_probs_dropout_prob
							_UpperCAmelCase							=			max_position_embeddings
							_UpperCAmelCase							=			type_vocab_size
							_UpperCAmelCase							=			type_sequence_label_size
							_UpperCAmelCase							=			initializer_range
							_UpperCAmelCase							=			num_labels
							_UpperCAmelCase							=			num_choices
							_UpperCAmelCase							=			relative_attention
							_UpperCAmelCase							=			position_biased_input
							_UpperCAmelCase							=			pos_att_type
							_UpperCAmelCase							=			scope



			def        lowercase__  (						self   :			List[Any]      )->List[Any]:
							_UpperCAmelCase							=			ids_tensor([self.batch_size, self.seq_length] ,      self.vocab_size      )

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

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

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

							_UpperCAmelCase							=			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        lowercase__  (						self   :			Any ,      __UpperCamelCase   :			Any ,      __UpperCamelCase   :			Dict ,      __UpperCamelCase   :			Optional[Any] ,      __UpperCamelCase   :			Dict ,      __UpperCamelCase   :			List[Any] ,      __UpperCamelCase   :			Optional[int] ,      __UpperCamelCase   :			str      )->Optional[Any]:
							_UpperCAmelCase							=			TFDebertaVaModel(config=__lowerCamelCase      )
							_UpperCAmelCase							=			{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}

							_UpperCAmelCase							=			[input_ids, input_mask]
							_UpperCAmelCase							=			model(__lowerCamelCase      )

							_UpperCAmelCase							=			model(__lowerCamelCase      )

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



			def        lowercase__  (						self   :			Tuple ,      __UpperCamelCase   :			Tuple ,      __UpperCamelCase   :			Any ,      __UpperCamelCase   :			Optional[int] ,      __UpperCamelCase   :			int ,      __UpperCamelCase   :			int ,      __UpperCamelCase   :			Optional[Any] ,      __UpperCamelCase   :			Optional[int]      )->Tuple:
							_UpperCAmelCase							=			TFDebertaVaForMaskedLM(config=__lowerCamelCase      )
							_UpperCAmelCase							=			{
							    "input_ids": input_ids,
							    "attention_mask": input_mask,
							    "token_type_ids": token_type_ids,
							}
							_UpperCAmelCase							=			model(__lowerCamelCase      )
							self.parent.assertEqual(result.logits.shape ,      (self.batch_size, self.seq_length, self.vocab_size)      )



			def        lowercase__  (						self   :			Optional[int] ,      __UpperCamelCase   :			str ,      __UpperCamelCase   :			Optional[int] ,      __UpperCamelCase   :			List[str] ,      __UpperCamelCase   :			List[Any] ,      __UpperCamelCase   :			Union[str, Any] ,      __UpperCamelCase   :			int ,      __UpperCamelCase   :			Optional[Any]      )->Tuple:
							_UpperCAmelCase							=			self.num_labels
							_UpperCAmelCase							=			TFDebertaVaForSequenceClassification(config=__lowerCamelCase      )
							_UpperCAmelCase							=			{
							    "input_ids": input_ids,
							    "attention_mask": input_mask,
							    "token_type_ids": token_type_ids,
							}

							_UpperCAmelCase							=			model(__lowerCamelCase      )
							self.parent.assertEqual(result.logits.shape ,      (self.batch_size, self.num_labels)      )



			def        lowercase__  (						self   :			Dict ,      __UpperCamelCase   :			str ,      __UpperCamelCase   :			int ,      __UpperCamelCase   :			List[Any] ,      __UpperCamelCase   :			List[Any] ,      __UpperCamelCase   :			int ,      __UpperCamelCase   :			str ,      __UpperCamelCase   :			List[Any]      )->Any:
							_UpperCAmelCase							=			self.num_labels
							_UpperCAmelCase							=			TFDebertaVaForTokenClassification(config=__lowerCamelCase      )
							_UpperCAmelCase							=			{
							    "input_ids": input_ids,
							    "attention_mask": input_mask,
							    "token_type_ids": token_type_ids,
							}
							_UpperCAmelCase							=			model(__lowerCamelCase      )
							self.parent.assertEqual(result.logits.shape ,      (self.batch_size, self.seq_length, self.num_labels)      )



			def        lowercase__  (						self   :			int ,      __UpperCamelCase   :			List[str] ,      __UpperCamelCase   :			List[Any] ,      __UpperCamelCase   :			List[Any] ,      __UpperCamelCase   :			Union[str, Any] ,      __UpperCamelCase   :			str ,      __UpperCamelCase   :			Tuple ,      __UpperCamelCase   :			List[Any]      )->Tuple:
							_UpperCAmelCase							=			TFDebertaVaForQuestionAnswering(config=__lowerCamelCase      )
							_UpperCAmelCase							=			{
							    "input_ids": input_ids,
							    "attention_mask": input_mask,
							    "token_type_ids": token_type_ids,
							}

							_UpperCAmelCase							=			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   :			Dict      )->Dict:
							_UpperCAmelCase							=			self.prepare_config_and_inputs()
							(
							    _UpperCAmelCase   
							)							=			config_and_inputs
							_UpperCAmelCase							=			{"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
							return config, inputs_dict



@require_tf
class 	_a       (    lowercase__	,							lowercase__	,							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        lowercase__  (						self   :			Tuple      )->Dict:
							_UpperCAmelCase							=			TFDebertaVaModelTester(self      )
							_UpperCAmelCase							=			ConfigTester(self ,      config_class=__lowerCamelCase ,      hidden_size=3_7      )



			def        lowercase__  (						self   :			Tuple      )->Union[str, Any]:
							self.config_tester.run_common_tests()



			def        lowercase__  (						self   :			int      )->List[Any]:
							_UpperCAmelCase							=			self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_model(*__lowerCamelCase      )



			def        lowercase__  (						self   :			List[Any]      )->int:
							_UpperCAmelCase							=			self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_masked_lm(*__lowerCamelCase      )



			def        lowercase__  (						self   :			Any      )->List[str]:
							_UpperCAmelCase							=			self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_question_answering(*__lowerCamelCase      )



			def        lowercase__  (						self   :			str      )->Dict:
							_UpperCAmelCase							=			self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_sequence_classification(*__lowerCamelCase      )



			def        lowercase__  (						self   :			Union[str, Any]      )->Any:
							_UpperCAmelCase							=			self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_token_classification(*__lowerCamelCase      )



			@slow
			def        lowercase__  (						self   :			Optional[Any]      )->Optional[int]:
							_UpperCAmelCase							=			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        lowercase__  (						self   :			Dict      )->Any:
							pass



			@slow
			def        lowercase__  (						self   :			Tuple      )->Union[str, Any]:
							_UpperCAmelCase							=			TFDebertaVaModel.from_pretrained('''kamalkraj/deberta-v2-xlarge'''      )
							_UpperCAmelCase							=			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]]      )
							_UpperCAmelCase							=			tf.constant([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]      )
							_UpperCAmelCase							=			model(__lowerCamelCase ,      attention_mask=__lowerCamelCase      )[0]

							_UpperCAmelCase							=			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      )







from __future__ import annotations

from typing import Any

def       lowercase_		(		_A			:    list[Any]						):

      """simple docstring"""




      create_state_space_tree(_A    ,					[]    ,					0						)

def       lowercase_		(		_A			:    list[Any]    ,					_A			:    list[Any]    ,					_A			:    int						):

      """simple docstring"""




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

      create_state_space_tree(_A    ,					_A    ,					index + 1						)
      current_subsequence.append(sequence[index]						)
      create_state_space_tree(_A    ,					_A    ,					index + 1						)
      current_subsequence.pop()


if __name__ == "__main__":
    A      :    list[Any]		=					[3, 1, 2, 4]
    generate_all_subsequences(seq)

    seq.clear()
    seq.extend(["A", "B", "C"])
    generate_all_subsequences(seq)


