






'''simple docstring'''







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




							def __init__(				self:							Tuple     ,				UpperCamelCase__:							Union[str, Any]     ,				UpperCamelCase__:							List[str]=13     ,				UpperCamelCase__:							Union[str, Any]=7     ,				UpperCamelCase__:							List[Any]=True     ,				UpperCamelCase__:							Optional[int]=True     ,				UpperCamelCase__:							Union[str, Any]=True     ,				UpperCamelCase__:							Dict=True     ,				UpperCamelCase__:							Any=99     ,				UpperCamelCase__:							int=32     ,				UpperCamelCase__:							Optional[int]=2     ,				UpperCamelCase__:							Tuple=4     ,				UpperCamelCase__:							Union[str, Any]=37     ,				UpperCamelCase__:							Optional[Any]="gelu"     ,				UpperCamelCase__:							Union[str, Any]=0.1     ,				UpperCamelCase__:							Union[str, Any]=0.1     ,				UpperCamelCase__:							Union[str, Any]=512     ,				UpperCamelCase__:							List[str]=16     ,				UpperCamelCase__:							List[str]=2     ,				UpperCamelCase__:							Optional[int]=0.02     ,				UpperCamelCase__:							int=3     ,				UpperCamelCase__:							Optional[int]=4     ,				UpperCamelCase__:							Tuple=None     ,				):
														lowerCamelCase__   :      Any			    =			parent
														lowerCamelCase__   :      int			    =			13
														lowerCamelCase__   :      List[str]			    =			7
														lowerCamelCase__   :      Any			    =			True
														lowerCamelCase__   :      Any			    =			True
														lowerCamelCase__   :      List[Any]			    =			True
														lowerCamelCase__   :      Union[str, Any]			    =			True
														lowerCamelCase__   :      Dict			    =			99
														lowerCamelCase__   :      int			    =			32
														lowerCamelCase__   :      List[str]			    =			2
														lowerCamelCase__   :      Any			    =			4
														lowerCamelCase__   :      Optional[Any]			    =			37
														lowerCamelCase__   :      List[Any]			    =			"""gelu"""
														lowerCamelCase__   :      List[str]			    =			0.1
														lowerCamelCase__   :      Any			    =			0.1
														lowerCamelCase__   :      Tuple			    =			512
														lowerCamelCase__   :      List[Any]			    =			16
														lowerCamelCase__   :      str			    =			False
														lowerCamelCase__   :      Optional[int]			    =			-1
														lowerCamelCase__   :      Tuple			    =			True
														lowerCamelCase__   :      str			    =			2
														lowerCamelCase__   :      str			    =			0.02
														lowerCamelCase__   :      Tuple			    =			3
														lowerCamelCase__   :      List[Any]			    =			4
														lowerCamelCase__   :      Dict			    =			None




							def 						lowerCamelCase_							(				self:							Tuple	):
														lowerCamelCase__   :      List[str]			    =			ids_tensor([self.batch_size, self.seq_length]     ,				self.vocab_size	)

														lowerCamelCase__   :      Optional[int]			    =			None
														if self.use_input_mask:
																					lowerCamelCase__   :      Tuple			    =			random_attention_mask([self.batch_size, self.seq_length]	)

														lowerCamelCase__   :      Optional[int]			    =			None
														if self.use_token_type_ids:
																					lowerCamelCase__   :      str			    =			ids_tensor([self.batch_size, self.seq_length]     ,				self.type_vocab_size	)

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

														lowerCamelCase__   :      Union[str, Any]			    =			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=UpperCamelCase__     ,				)

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




							def 						lowerCamelCase_							(				self:							int     ,				UpperCamelCase__:							List[str]     ,				UpperCamelCase__:							Union[str, Any]     ,				UpperCamelCase__:							Optional[Any]     ,				UpperCamelCase__:							int     ,				UpperCamelCase__:							int     ,				UpperCamelCase__:							Dict     ,				UpperCamelCase__:							List[Any]	):
														lowerCamelCase__   :      Any			    =			TFDebertaModel(config=UpperCamelCase__	)
														lowerCamelCase__   :      Optional[Any]			    =			{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}

														lowerCamelCase__   :      int			    =			[input_ids, input_mask]
														lowerCamelCase__   :      Optional[int]			    =			model(UpperCamelCase__	)

														lowerCamelCase__   :      Dict			    =			model(UpperCamelCase__	)

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




							def 						lowerCamelCase_							(				self:							Tuple     ,				UpperCamelCase__:							str     ,				UpperCamelCase__:							Any     ,				UpperCamelCase__:							Optional[int]     ,				UpperCamelCase__:							Tuple     ,				UpperCamelCase__:							str     ,				UpperCamelCase__:							str     ,				UpperCamelCase__:							Optional[Any]	):
														lowerCamelCase__   :      Optional[int]			    =			TFDebertaForMaskedLM(config=UpperCamelCase__	)
														lowerCamelCase__   :      int			    =			{
														    """input_ids""": input_ids,
														    """attention_mask""": input_mask,
														    """token_type_ids""": token_type_ids,
														}
														lowerCamelCase__   :      Any			    =			model(UpperCamelCase__	)
														self.parent.assertEqual(result.logits.shape     ,				(self.batch_size, self.seq_length, self.vocab_size)	)




							def 						lowerCamelCase_							(				self:							int     ,				UpperCamelCase__:							Union[str, Any]     ,				UpperCamelCase__:							Optional[int]     ,				UpperCamelCase__:							int     ,				UpperCamelCase__:							Optional[int]     ,				UpperCamelCase__:							List[str]     ,				UpperCamelCase__:							int     ,				UpperCamelCase__:							Optional[Any]	):
														lowerCamelCase__   :      Optional[int]			    =			self.num_labels
														lowerCamelCase__   :      Any			    =			TFDebertaForSequenceClassification(config=UpperCamelCase__	)
														lowerCamelCase__   :      Union[str, Any]			    =			{
														    """input_ids""": input_ids,
														    """attention_mask""": input_mask,
														    """token_type_ids""": token_type_ids,
														}

														lowerCamelCase__   :      List[Any]			    =			model(UpperCamelCase__	)
														self.parent.assertEqual(result.logits.shape     ,				(self.batch_size, self.num_labels)	)




							def 						lowerCamelCase_							(				self:							Optional[int]     ,				UpperCamelCase__:							str     ,				UpperCamelCase__:							int     ,				UpperCamelCase__:							List[Any]     ,				UpperCamelCase__:							int     ,				UpperCamelCase__:							Dict     ,				UpperCamelCase__:							Optional[int]     ,				UpperCamelCase__:							Tuple	):
														lowerCamelCase__   :      List[str]			    =			self.num_labels
														lowerCamelCase__   :      Tuple			    =			TFDebertaForTokenClassification(config=UpperCamelCase__	)
														lowerCamelCase__   :      Optional[Any]			    =			{
														    """input_ids""": input_ids,
														    """attention_mask""": input_mask,
														    """token_type_ids""": token_type_ids,
														}
														lowerCamelCase__   :      List[Any]			    =			model(UpperCamelCase__	)
														self.parent.assertEqual(result.logits.shape     ,				(self.batch_size, self.seq_length, self.num_labels)	)




							def 						lowerCamelCase_							(				self:							Any     ,				UpperCamelCase__:							List[Any]     ,				UpperCamelCase__:							int     ,				UpperCamelCase__:							Any     ,				UpperCamelCase__:							str     ,				UpperCamelCase__:							Tuple     ,				UpperCamelCase__:							Tuple     ,				UpperCamelCase__:							Any	):
														lowerCamelCase__   :      Tuple			    =			TFDebertaForQuestionAnswering(config=UpperCamelCase__	)
														lowerCamelCase__   :      Union[str, Any]			    =			{
														    """input_ids""": input_ids,
														    """attention_mask""": input_mask,
														    """token_type_ids""": token_type_ids,
														}

														lowerCamelCase__   :      Dict			    =			model(UpperCamelCase__	)
														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 						lowerCamelCase_							(				self:							str	):
														lowerCamelCase__   :      List[str]			    =			self.prepare_config_and_inputs()
														(
														    (
														    lowerCamelCase__    
														)    ,						(
														    lowerCamelCase__    
														)    ,						(
														    lowerCamelCase__    
														)    ,						(
														    lowerCamelCase__    
														)    ,						(
														    lowerCamelCase__    
														)    ,						(
														    lowerCamelCase__    
														)    ,						(
														    lowerCamelCase__    
														)    ,						    
														)   :      str			    =			config_and_inputs
														lowerCamelCase__   :      str			    =			{"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
														return config, inputs_dict



@require_tf
class _lowercase      (							lowerCamelCase_							, lowerCamelCase_							, unittest.TestCase						):
							a							 =			(
							    (
							        TFDebertaModel,
							        TFDebertaForMaskedLM,
							        TFDebertaForQuestionAnswering,
							        TFDebertaForSequenceClassification,
							        TFDebertaForTokenClassification,
							    )
							    if is_tf_available()
							    else ()
							)
							a							 =			(
							    {
							        """feature-extraction""": TFDebertaModel,
							        """fill-mask""": TFDebertaForMaskedLM,
							        """question-answering""": TFDebertaForQuestionAnswering,
							        """text-classification""": TFDebertaForSequenceClassification,
							        """token-classification""": TFDebertaForTokenClassification,
							        """zero-shot""": TFDebertaForSequenceClassification,
							    }
							    if is_tf_available()
							    else {}
							)

							a							 =			False
							a							 =			False




							def 						lowerCamelCase_							(				self:							Any	):
														lowerCamelCase__   :      Union[str, Any]			    =			TFDebertaModelTester(self	)
														lowerCamelCase__   :      Dict			    =			ConfigTester(self     ,				config_class=UpperCamelCase__     ,				hidden_size=37	)




							def 						lowerCamelCase_							(				self:							Any	):
														self.config_tester.run_common_tests()




							def 						lowerCamelCase_							(				self:							Optional[int]	):
														lowerCamelCase__   :      str			    =			self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_model(*UpperCamelCase__	)




							def 						lowerCamelCase_							(				self:							Union[str, Any]	):
														lowerCamelCase__   :      Optional[Any]			    =			self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_for_masked_lm(*UpperCamelCase__	)




							def 						lowerCamelCase_							(				self:							Dict	):
														lowerCamelCase__   :      Optional[Any]			    =			self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_for_question_answering(*UpperCamelCase__	)




							def 						lowerCamelCase_							(				self:							Optional[int]	):
														lowerCamelCase__   :      List[str]			    =			self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_for_sequence_classification(*UpperCamelCase__	)




							def 						lowerCamelCase_							(				self:							Any	):
														lowerCamelCase__   :      int			    =			self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_for_token_classification(*UpperCamelCase__	)




							@slow
							def 						lowerCamelCase_							(				self:							Tuple	):
														lowerCamelCase__   :      Optional[int]			    =			TFDebertaModel.from_pretrained("""kamalkraj/deberta-base"""	)
														self.assertIsNotNone(UpperCamelCase__	)



@require_tf
class _lowercase      (							unittest.TestCase						):




							@unittest.skip(reason="""Model not available yet"""	)
							def 						lowerCamelCase_							(				self:							Dict	):
														pass




							@slow
							def 						lowerCamelCase_							(				self:							Any	):
														lowerCamelCase__   :      int			    =			TFDebertaModel.from_pretrained("""kamalkraj/deberta-base"""	)
														lowerCamelCase__   :      Union[str, Any]			    =			tf.constant([[0, 31_414, 232, 328, 740, 1_140, 12_695, 69, 46_078, 1_588, 2]]	)
														lowerCamelCase__   :      List[str]			    =			tf.constant([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]	)
														lowerCamelCase__   :      str			    =			model(UpperCamelCase__     ,				attention_mask=UpperCamelCase__	)[0]

														lowerCamelCase__   :      str			    =			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]     ,				UpperCamelCase__     ,				atol=1e-4	)




import numpy as np







def      snake_case__							(  lowerCAmelCase_     ):





     """simple docstring"""







     SCREAMING_SNAKE_CASE 		=np.exp(lowerCAmelCase_     )

     # Add up the all the exponentials
     SCREAMING_SNAKE_CASE 		=np.sum(lowerCAmelCase_     )

     # Divide every exponent by the sum of all exponents
     SCREAMING_SNAKE_CASE 		=exponent_vector / sum_of_exponents

     return softmax_vector


if __name__ == "__main__":
 print(softmax((0,)))

