



"""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 			__SCREAMING_SNAKE_CASE      :


					'''simple docstring'''





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



					def 						snake_case			(			self				:    Optional[Any]	)->   Union[str, Any]:
								lowerCamelCase__						:						Any						      =ids_tensor([self.batch_size, self.seq_length],    self.vocab_size	)

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

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

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

								lowerCamelCase__						:						List[str]						      =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 						snake_case			(			self				:    Any,    lowerCamelCase				:    Dict,    lowerCamelCase				:    Any,    lowerCamelCase				:    List[str],    lowerCamelCase				:    List[str],    lowerCamelCase				:    str,    lowerCamelCase				:    Union[str, Any],    lowerCamelCase				:    Dict	)->   Optional[Any]:
								lowerCamelCase__						:						Optional[int]						      =TFDebertaModel(config=lowerCamelCase	)
								lowerCamelCase__						:						Any						      ={'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}

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

								lowerCamelCase__						:						str						      =model(lowerCamelCase	)

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



					def 						snake_case			(			self				:    Tuple,    lowerCamelCase				:    Union[str, Any],    lowerCamelCase				:    List[str],    lowerCamelCase				:    Union[str, Any],    lowerCamelCase				:    str,    lowerCamelCase				:    List[str],    lowerCamelCase				:    List[Any],    lowerCamelCase				:    str	)->   str:
								lowerCamelCase__						:						str						      =TFDebertaForMaskedLM(config=lowerCamelCase	)
								lowerCamelCase__						:						Any						      ={
								    '''input_ids''': input_ids,
								    '''attention_mask''': input_mask,
								    '''token_type_ids''': token_type_ids,
								}
								lowerCamelCase__						:						List[Any]						      =model(lowerCamelCase	)
								self.parent.assertEqual(result.logits.shape,    (self.batch_size, self.seq_length, self.vocab_size)	)



					def 						snake_case			(			self				:    Optional[Any],    lowerCamelCase				:    str,    lowerCamelCase				:    Optional[Any],    lowerCamelCase				:    Optional[Any],    lowerCamelCase				:    List[str],    lowerCamelCase				:    Optional[int],    lowerCamelCase				:    Any,    lowerCamelCase				:    List[str]	)->   Optional[int]:
								lowerCamelCase__						:						Union[str, Any]						      =self.num_labels
								lowerCamelCase__						:						Tuple						      =TFDebertaForSequenceClassification(config=lowerCamelCase	)
								lowerCamelCase__						:						Tuple						      ={
								    '''input_ids''': input_ids,
								    '''attention_mask''': input_mask,
								    '''token_type_ids''': token_type_ids,
								}

								lowerCamelCase__						:						str						      =model(lowerCamelCase	)
								self.parent.assertEqual(result.logits.shape,    (self.batch_size, self.num_labels)	)



					def 						snake_case			(			self				:    Union[str, Any],    lowerCamelCase				:    List[str],    lowerCamelCase				:    Optional[Any],    lowerCamelCase				:    Dict,    lowerCamelCase				:    int,    lowerCamelCase				:    Tuple,    lowerCamelCase				:    Optional[int],    lowerCamelCase				:    Optional[int]	)->   Tuple:
								lowerCamelCase__						:						Optional[int]						      =self.num_labels
								lowerCamelCase__						:						int						      =TFDebertaForTokenClassification(config=lowerCamelCase	)
								lowerCamelCase__						:						List[str]						      ={
								    '''input_ids''': input_ids,
								    '''attention_mask''': input_mask,
								    '''token_type_ids''': token_type_ids,
								}
								lowerCamelCase__						:						int						      =model(lowerCamelCase	)
								self.parent.assertEqual(result.logits.shape,    (self.batch_size, self.seq_length, self.num_labels)	)



					def 						snake_case			(			self				:    Any,    lowerCamelCase				:    Tuple,    lowerCamelCase				:    List[Any],    lowerCamelCase				:    str,    lowerCamelCase				:    List[Any],    lowerCamelCase				:    Tuple,    lowerCamelCase				:    List[Any],    lowerCamelCase				:    Tuple	)->   int:
								lowerCamelCase__						:						Optional[Any]						      =TFDebertaForQuestionAnswering(config=lowerCamelCase	)
								lowerCamelCase__						:						int						      ={
								    '''input_ids''': input_ids,
								    '''attention_mask''': input_mask,
								    '''token_type_ids''': token_type_ids,
								}

								lowerCamelCase__						:						str						      =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 						snake_case			(			self				:    Optional[Any]	)->   str:
								lowerCamelCase__						:						List[str]						      =self.prepare_config_and_inputs()
								(
								    (
								    lowerCamelCase__
								)      ,  (
								    lowerCamelCase__
								)      ,  (
								    lowerCamelCase__
								)      ,  (
								    lowerCamelCase__
								)      ,  (
								    lowerCamelCase__
								)      ,  (
								    lowerCamelCase__
								)      ,  (
								    lowerCamelCase__
								)      ,  
								)						:						List[str]						      =config_and_inputs
								lowerCamelCase__						:						int						      ={'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
								return config, inputs_dict





@require_tf
class 			__SCREAMING_SNAKE_CASE      ( lowerCAmelCase_						,  lowerCAmelCase_						,  unittest.TestCase  ):


					'''simple docstring'''





					_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 						snake_case			(			self				:    Union[str, Any]	)->   Any:
								lowerCamelCase__						:						str						      =TFDebertaModelTester(self	)
								lowerCamelCase__						:						int						      =ConfigTester(self,    config_class=lowerCamelCase,    hidden_size=37	)



					def 						snake_case			(			self				:    Tuple	)->   Dict:
								self.config_tester.run_common_tests()



					def 						snake_case			(			self				:    str	)->   Union[str, Any]:
								lowerCamelCase__						:						Optional[Any]						      =self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_model(*lowerCamelCase	)



					def 						snake_case			(			self				:    Optional[Any]	)->   Dict:
								lowerCamelCase__						:						List[Any]						      =self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_masked_lm(*lowerCamelCase	)



					def 						snake_case			(			self				:    Union[str, Any]	)->   List[Any]:
								lowerCamelCase__						:						Optional[Any]						      =self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_question_answering(*lowerCamelCase	)



					def 						snake_case			(			self				:    Tuple	)->   Union[str, Any]:
								lowerCamelCase__						:						Dict						      =self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_sequence_classification(*lowerCamelCase	)



					def 						snake_case			(			self				:    Optional[Any]	)->   str:
								lowerCamelCase__						:						List[Any]						      =self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_token_classification(*lowerCamelCase	)




					@slow
					def 						snake_case			(			self				:    Any	)->   List[Any]:
								lowerCamelCase__						:						List[str]						      =TFDebertaModel.from_pretrained('''kamalkraj/deberta-base'''	)
								self.assertIsNotNone(lowerCamelCase	)





@require_tf
class 			__SCREAMING_SNAKE_CASE      ( unittest.TestCase  ):


					'''simple docstring'''





					@unittest.skip(reason='''Model not available yet'''	)
					def 						snake_case			(			self				:    Optional[Any]	)->   Tuple:
								pass




					@slow
					def 						snake_case			(			self				:    Dict	)->   Optional[Any]:
								lowerCamelCase__						:						List[Any]						      =TFDebertaModel.from_pretrained('''kamalkraj/deberta-base'''	)
								lowerCamelCase__						:						str						      =tf.constant([[0, 3_1414, 232, 328, 740, 1140, 1_2695, 69, 4_6078, 1588, 2]]	)
								lowerCamelCase__						:						int						      =tf.constant([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]	)
								lowerCamelCase__						:						List[str]						      =model(lowerCamelCase,    attention_mask=lowerCamelCase	)[0]

								lowerCamelCase__						:						List[Any]						      =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	)









"""simple docstring"""






def 	snake_case__  (						__lowerCamelCase							:       str				,						__lowerCamelCase							:       int = 13      ):
			"""simple docstring"""
			lowerCamelCase__						:						List[str]						      =''''''
			for c in s:
						if "A" <= c <= "Z":
									out += chr(ord('''A'''      ) + (ord(__lowerCamelCase      ) - ord('''A'''      ) + n) % 26      )
						elif "a" <= c <= "z":
									out += chr(ord('''a'''      ) + (ord(__lowerCamelCase      ) - ord('''a'''      ) + n) % 26      )
						else:
									out += c
			return out






def 	snake_case__  (						):
			"""simple docstring"""
			lowerCamelCase__						:						List[str]						      =input('''Enter message: '''      )

			lowerCamelCase__						:						str						      =dencrypt(__lowerCamelCase				,						13      )
			print('''Encryption:'''				,						__lowerCamelCase      )

			lowerCamelCase__						:						Any						      =dencrypt(__lowerCamelCase				,						13      )
			print('''Decryption: '''				,						__lowerCamelCase      )


if __name__ == "__main__":
		import doctest

		doctest.testmod()
		main()




