





"""simple docstring"""
from __future__ import annotations

import unittest

from transformers import RoFormerConfig, 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 (
      TFRoFormerForCausalLM,
      TFRoFormerForMaskedLM,
      TFRoFormerForMultipleChoice,
      TFRoFormerForQuestionAnswering,
      TFRoFormerForSequenceClassification,
      TFRoFormerForTokenClassification,
      TFRoFormerModel,
  )
  from transformers.models.roformer.modeling_tf_roformer import (
      TFRoFormerSelfAttention,
      TFRoFormerSinusoidalPositionalEmbedding,
  )






class 					_SCREAMING_SNAKE_CASE:




       def __init__(						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__=13		,SCREAMING_SNAKE_CASE__=7		,SCREAMING_SNAKE_CASE__=True		,SCREAMING_SNAKE_CASE__=True		,SCREAMING_SNAKE_CASE__=True		,SCREAMING_SNAKE_CASE__=True		,SCREAMING_SNAKE_CASE__=99		,SCREAMING_SNAKE_CASE__=32		,SCREAMING_SNAKE_CASE__=2		,SCREAMING_SNAKE_CASE__=4		,SCREAMING_SNAKE_CASE__=37		,SCREAMING_SNAKE_CASE__="gelu"		,SCREAMING_SNAKE_CASE__=0.1		,SCREAMING_SNAKE_CASE__=0.1		,SCREAMING_SNAKE_CASE__=5_12		,SCREAMING_SNAKE_CASE__=16		,SCREAMING_SNAKE_CASE__=2		,SCREAMING_SNAKE_CASE__=0.0_2		,SCREAMING_SNAKE_CASE__=3		,SCREAMING_SNAKE_CASE__=4		,SCREAMING_SNAKE_CASE__=None		,)			->      Tuple:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Optional[int]						=  parent
             __SCREAMING_SNAKE_CASE   :str						=  13
             __SCREAMING_SNAKE_CASE   :int						=  7
             __SCREAMING_SNAKE_CASE   :Tuple						=  True
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  True
             __SCREAMING_SNAKE_CASE   :Any						=  True
             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  True
             __SCREAMING_SNAKE_CASE   :Tuple						=  99
             __SCREAMING_SNAKE_CASE   :List[str]						=  32
             __SCREAMING_SNAKE_CASE   :str						=  2
             __SCREAMING_SNAKE_CASE   :int						=  4
             __SCREAMING_SNAKE_CASE   :List[Any]						=  37
             __SCREAMING_SNAKE_CASE   :Any						=  '''gelu'''
             __SCREAMING_SNAKE_CASE   :str						=  0.1
             __SCREAMING_SNAKE_CASE   :Dict						=  0.1
             __SCREAMING_SNAKE_CASE   :int						=  5_12
             __SCREAMING_SNAKE_CASE   :int						=  16
             __SCREAMING_SNAKE_CASE   :Optional[int]						=  2
             __SCREAMING_SNAKE_CASE   :str						=  0.0_2
             __SCREAMING_SNAKE_CASE   :List[Any]						=  3
             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  4
             __SCREAMING_SNAKE_CASE   :List[str]						=  None




       def     _UpperCamelCase     (						self							)			->      List[str]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :List[str]						=  ids_tensor([self.batch_size, self.seq_length]		,self.vocab_size							)

             __SCREAMING_SNAKE_CASE   :List[str]						=  None
             if self.use_input_mask:
                   __SCREAMING_SNAKE_CASE   :List[str]						=  random_attention_mask([self.batch_size, self.seq_length]							)

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

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

             __SCREAMING_SNAKE_CASE   :str						=  RoFormerConfig(
                 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		,initializer_range=self.initializer_range		,return_dict=SCREAMING_SNAKE_CASE__		,)

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




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)			->      Tuple:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Any						=  TFRoFormerModel(config=SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE   :Any						=  {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}

             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  [input_ids, input_mask]
             __SCREAMING_SNAKE_CASE   :Tuple						=  model(SCREAMING_SNAKE_CASE__							)

             __SCREAMING_SNAKE_CASE   :List[Any]						=  model(SCREAMING_SNAKE_CASE__							)

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




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)			->      List[str]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Any						=  True
             __SCREAMING_SNAKE_CASE   :str						=  TFRoFormerForCausalLM(config=SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE   :int						=  {
                 '''input_ids''': input_ids,
                 '''attention_mask''': input_mask,
                 '''token_type_ids''': token_type_ids,
             }
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  model(SCREAMING_SNAKE_CASE__							)['''logits''']
             self.parent.assertListEqual(
                 list(prediction_scores.numpy().shape							)		,[self.batch_size, self.seq_length, self.vocab_size]							)




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)			->      str:





             """simple docstring"""






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




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)			->      List[str]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Optional[int]						=  self.num_labels
             __SCREAMING_SNAKE_CASE   :Any						=  TFRoFormerForSequenceClassification(config=SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE   :Tuple						=  {
                 '''input_ids''': input_ids,
                 '''attention_mask''': input_mask,
                 '''token_type_ids''': token_type_ids,
             }

             __SCREAMING_SNAKE_CASE   :List[str]						=  model(SCREAMING_SNAKE_CASE__							)
             self.parent.assertEqual(result.logits.shape		,(self.batch_size, self.num_labels)							)




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)			->      Dict:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  self.num_choices
             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  TFRoFormerForMultipleChoice(config=SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  tf.tile(tf.expand_dims(SCREAMING_SNAKE_CASE__		,1							)		,(1, self.num_choices, 1)							)
             __SCREAMING_SNAKE_CASE   :List[Any]						=  tf.tile(tf.expand_dims(SCREAMING_SNAKE_CASE__		,1							)		,(1, self.num_choices, 1)							)
             __SCREAMING_SNAKE_CASE   :List[str]						=  tf.tile(tf.expand_dims(SCREAMING_SNAKE_CASE__		,1							)		,(1, self.num_choices, 1)							)
             __SCREAMING_SNAKE_CASE   :Dict						=  {
                 '''input_ids''': multiple_choice_inputs_ids,
                 '''attention_mask''': multiple_choice_input_mask,
                 '''token_type_ids''': multiple_choice_token_type_ids,
             }
             __SCREAMING_SNAKE_CASE   :Optional[int]						=  model(SCREAMING_SNAKE_CASE__							)
             self.parent.assertEqual(result.logits.shape		,(self.batch_size, self.num_choices)							)




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)			->      Optional[Any]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Any						=  self.num_labels
             __SCREAMING_SNAKE_CASE   :List[str]						=  TFRoFormerForTokenClassification(config=SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE   :str						=  {
                 '''input_ids''': input_ids,
                 '''attention_mask''': input_mask,
                 '''token_type_ids''': token_type_ids,
             }
             __SCREAMING_SNAKE_CASE   :List[Any]						=  model(SCREAMING_SNAKE_CASE__							)
             self.parent.assertEqual(result.logits.shape		,(self.batch_size, self.seq_length, self.num_labels)							)




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)			->      Optional[int]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Tuple						=  TFRoFormerForQuestionAnswering(config=SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE   :Dict						=  {
                 '''input_ids''': input_ids,
                 '''attention_mask''': input_mask,
                 '''token_type_ids''': token_type_ids,
             }

             __SCREAMING_SNAKE_CASE   :Tuple						=  model(SCREAMING_SNAKE_CASE__							)
             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     _UpperCamelCase     (						self							)			->      Dict:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :str						=  self.prepare_config_and_inputs()
             (
                 (
                 __SCREAMING_SNAKE_CASE
             )				,(
                 __SCREAMING_SNAKE_CASE
             )				,(
                 __SCREAMING_SNAKE_CASE
             )				,(
                 __SCREAMING_SNAKE_CASE
             )				,(
                 __SCREAMING_SNAKE_CASE
             )				,(
                 __SCREAMING_SNAKE_CASE
             )				,(
                 __SCREAMING_SNAKE_CASE
             )				,
             )   :Optional[int]						=  config_and_inputs
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  {'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
             return config, inputs_dict






@require_tf
class 					_SCREAMING_SNAKE_CASE(   A    ,	A    ,	unittest.TestCase  ):
       SCREAMING_SNAKE_CASE_   :      Tuple							=  (
           (
               TFRoFormerModel,
               TFRoFormerForCausalLM,
               TFRoFormerForMaskedLM,
               TFRoFormerForQuestionAnswering,
               TFRoFormerForSequenceClassification,
               TFRoFormerForTokenClassification,
               TFRoFormerForMultipleChoice,
           )
           if is_tf_available()
           else ()
       )
       SCREAMING_SNAKE_CASE_   :      Union[str, Any]							=  (
           {
               '''feature-extraction''': TFRoFormerModel,
               '''fill-mask''': TFRoFormerForMaskedLM,
               '''question-answering''': TFRoFormerForQuestionAnswering,
               '''text-classification''': TFRoFormerForSequenceClassification,
               '''text-generation''': TFRoFormerForCausalLM,
               '''token-classification''': TFRoFormerForTokenClassification,
               '''zero-shot''': TFRoFormerForSequenceClassification,
           }
           if is_tf_available()
           else {}
       )

       SCREAMING_SNAKE_CASE_   :      List[Any]							=  False
       SCREAMING_SNAKE_CASE_   :      List[str]							=  False




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)			->      Tuple:





             """simple docstring"""






             if pipeline_test_casse_name == "TextGenerationPipelineTests":
                   return True

             return False




       def     _UpperCamelCase     (						self							)			->      int:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :List[str]						=  TFRoFormerModelTester(self							)
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  ConfigTester(self		,config_class=SCREAMING_SNAKE_CASE__		,hidden_size=37							)




       def     _UpperCamelCase     (						self							)			->      Optional[int]:





             """simple docstring"""






             self.config_tester.run_common_tests()




       def     _UpperCamelCase     (						self							)			->      Tuple:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Any						=  self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE__							)




       def     _UpperCamelCase     (						self							)			->      Dict:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Tuple						=  self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_masked_lm(*SCREAMING_SNAKE_CASE__							)




       def     _UpperCamelCase     (						self							)			->      Union[str, Any]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_lm_head(*SCREAMING_SNAKE_CASE__							)




       def     _UpperCamelCase     (						self							)			->      Optional[int]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :List[Any]						=  self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_multiple_choice(*SCREAMING_SNAKE_CASE__							)




       def     _UpperCamelCase     (						self							)			->      Dict:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_question_answering(*SCREAMING_SNAKE_CASE__							)




       def     _UpperCamelCase     (						self							)			->      Union[str, Any]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :str						=  self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_sequence_classification(*SCREAMING_SNAKE_CASE__							)




       def     _UpperCamelCase     (						self							)			->      List[str]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :int						=  self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_token_classification(*SCREAMING_SNAKE_CASE__							)




       @slow
       def     _UpperCamelCase     (						self							)			->      List[str]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :int						=  TFRoFormerModel.from_pretrained('''junnyu/roformer_chinese_base'''							)
             self.assertIsNotNone(SCREAMING_SNAKE_CASE__							)






@require_tf
class 					_SCREAMING_SNAKE_CASE(   unittest.TestCase  ):




       @slow
       def     _UpperCamelCase     (						self							)			->      List[Any]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  TFRoFormerForMaskedLM.from_pretrained('''junnyu/roformer_chinese_base'''							)
             __SCREAMING_SNAKE_CASE   :List[str]						=  tf.constant([[0, 1, 2, 3, 4, 5]]							)
             __SCREAMING_SNAKE_CASE   :int						=  model(SCREAMING_SNAKE_CASE__							)[0]

             # TODO Replace vocab size
             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  5_00_00

             __SCREAMING_SNAKE_CASE   :Optional[int]						=  [1, 6, vocab_size]
             self.assertEqual(output.shape		,SCREAMING_SNAKE_CASE__							)

             print(output[:, :3, :3]							)

             # TODO Replace values below with what was printed above.
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  tf.constant(
                 [
                     [
                         [-0.1_2_0_5_3_3_4_1, -1.0_2_6_4_9_0_1, 0.2_9_2_2_1_9_4_6],
                         [-1.5_1_3_3_7_8_3, 0.1_9_7_4_3_3, 0.1_5_1_9_0_6_0_7],
                         [-5.0_1_3_5_4_0_3, -3.9_0_0_2_5_6, -0.8_4_0_3_8_7_6_4],
                     ]
                 ]							)
             tf.debugging.assert_near(output[:, :3, :3]		,SCREAMING_SNAKE_CASE__		,atol=1E-4							)






@require_tf
class 					_SCREAMING_SNAKE_CASE(   unittest.TestCase  ):
       SCREAMING_SNAKE_CASE_   :      Dict							=  1E-4




       def     _UpperCamelCase     (						self							)			->      List[Any]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :List[str]						=  tf.constant([[4, 10]]							)
             __SCREAMING_SNAKE_CASE   :Any						=  TFRoFormerSinusoidalPositionalEmbedding(num_positions=6		,embedding_dim=6							)

             __SCREAMING_SNAKE_CASE   :Optional[int]						=  emba(input_ids.shape							)
             __SCREAMING_SNAKE_CASE   :int						=  tf.constant(
                 [[0.0_0_0_0, 0.0_0_0_0, 0.0_0_0_0, 1.0_0_0_0, 1.0_0_0_0, 1.0_0_0_0], [0.8_4_1_5, 0.0_4_6_4, 0.0_0_2_2, 0.5_4_0_3, 0.9_9_8_9, 1.0_0_0_0]]							)

             tf.debugging.assert_near(SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,atol=self.tolerance							)




       def     _UpperCamelCase     (						self							)			->      Any:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :List[str]						=  tf.constant(
                 [
                     [0.0_0_0_0, 0.0_0_0_0, 0.0_0_0_0, 0.0_0_0_0, 0.0_0_0_0],
                     [0.8_4_1_5, 0.8_2_1_9, 0.8_0_2_0, 0.7_8_1_9, 0.7_6_1_7],
                     [0.9_0_9_3, 0.9_3_6_4, 0.9_5_8_1, 0.9_7_4_9, 0.9_8_7_0],
                 ]							)
             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  TFRoFormerSinusoidalPositionalEmbedding(num_positions=5_12		,embedding_dim=5_12							)
             emba([2, 16, 5_12]							)
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  emba.weight[:3, :5]

             tf.debugging.assert_near(SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,atol=self.tolerance							)






@require_tf
class 					_SCREAMING_SNAKE_CASE(   unittest.TestCase  ):
       SCREAMING_SNAKE_CASE_   :      Optional[Any]							=  1E-4




       def     _UpperCamelCase     (						self							)			->      Optional[Any]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Optional[int]						=  tf.reshape(tf.range(2 * 12 * 16 * 64		,dtype=tf.floataa							)		,shape=(2, 12, 16, 64)							) / 1_00

             __SCREAMING_SNAKE_CASE   :List[Any]						=  -tf.reshape(tf.range(2 * 12 * 16 * 64		,dtype=tf.floataa							)		,shape=(2, 12, 16, 64)							) / 1_00

             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  TFRoFormerSinusoidalPositionalEmbedding(num_positions=32		,embedding_dim=64							)
             __SCREAMING_SNAKE_CASE   :int						=  embed_positions([2, 16, 7_68]							)[None, None, :, :]

             __SCREAMING_SNAKE_CASE				,__SCREAMING_SNAKE_CASE   :Optional[Any]						=  TFRoFormerSelfAttention.apply_rotary_position_embeddings(
                 SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)

             __SCREAMING_SNAKE_CASE   :str						=  tf.constant(
                 [
                     [0.0_0_0_0, 0.0_1_0_0, 0.0_2_0_0, 0.0_3_0_0, 0.0_4_0_0, 0.0_5_0_0, 0.0_6_0_0, 0.0_7_0_0],
                     [-0.2_0_1_2, 0.8_8_9_7, 0.0_2_6_3, 0.9_4_0_1, 0.2_0_7_4, 0.9_4_6_3, 0.3_4_8_1, 0.9_3_4_3],
                     [-1.7_0_5_7, 0.6_2_7_1, -1.2_1_4_5, 1.3_8_9_7, -0.6_3_0_3, 1.7_6_4_7, -0.1_1_7_3, 1.8_9_8_5],
                     [-2.1_7_3_1, -1.6_3_9_7, -2.7_3_5_8, 0.2_8_5_4, -2.1_8_4_0, 1.7_1_8_3, -1.3_0_1_8, 2.4_8_7_1],
                     [0.2_7_1_7, -3.6_1_7_3, -2.9_2_0_6, -2.1_9_8_8, -3.6_6_3_8, 0.3_8_5_8, -2.9_1_5_5, 2.2_9_8_0],
                     [3.9_8_5_9, -2.1_5_8_0, -0.7_9_8_4, -4.4_9_0_4, -4.1_1_8_1, -2.0_2_5_2, -4.4_7_8_2, 1.1_2_5_3],
                 ]							)
             __SCREAMING_SNAKE_CASE   :int						=  tf.constant(
                 [
                     [0.0_0_0_0, -0.0_1_0_0, -0.0_2_0_0, -0.0_3_0_0, -0.0_4_0_0, -0.0_5_0_0, -0.0_6_0_0, -0.0_7_0_0],
                     [0.2_0_1_2, -0.8_8_9_7, -0.0_2_6_3, -0.9_4_0_1, -0.2_0_7_4, -0.9_4_6_3, -0.3_4_8_1, -0.9_3_4_3],
                     [1.7_0_5_7, -0.6_2_7_1, 1.2_1_4_5, -1.3_8_9_7, 0.6_3_0_3, -1.7_6_4_7, 0.1_1_7_3, -1.8_9_8_5],
                     [2.1_7_3_1, 1.6_3_9_7, 2.7_3_5_8, -0.2_8_5_4, 2.1_8_4_0, -1.7_1_8_3, 1.3_0_1_8, -2.4_8_7_1],
                     [-0.2_7_1_7, 3.6_1_7_3, 2.9_2_0_6, 2.1_9_8_8, 3.6_6_3_8, -0.3_8_5_8, 2.9_1_5_5, -2.2_9_8_0],
                     [-3.9_8_5_9, 2.1_5_8_0, 0.7_9_8_4, 4.4_9_0_4, 4.1_1_8_1, 2.0_2_5_2, 4.4_7_8_2, -1.1_2_5_3],
                 ]							)

             tf.debugging.assert_near(query_layer[0, 0, :6, :8]		,SCREAMING_SNAKE_CASE__		,atol=self.tolerance							)
             tf.debugging.assert_near(key_layer[0, 0, :6, :8]		,SCREAMING_SNAKE_CASE__		,atol=self.tolerance							)






"""simple docstring"""
from typing import Any



def      __lowerCamelCase   (							a_     :		list							)			->      list[Any]:
      if not input_list:
            return []
      __SCREAMING_SNAKE_CASE   :int						=  [input_list.count(a_							) for value in input_list]
      __SCREAMING_SNAKE_CASE   :str						=  max(a_							)  # Gets the maximum count in the input list.
      # Gets values of modes
      return sorted({input_list[i] for i, value in enumerate(a_							) if value == y}							)


if __name__ == "__main__":
  import doctest

  doctest.testmod()