


'''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  a     :
 def __init__( self      ,				__magic_name__      ,				__magic_name__=13      ,				__magic_name__=7      ,				__magic_name__=True      ,				__magic_name__=True      ,				__magic_name__=True      ,				__magic_name__=True      ,				__magic_name__=99      ,				__magic_name__=32      ,				__magic_name__=2      ,				__magic_name__=4      ,				__magic_name__=37      ,				__magic_name__="gelu"      ,				__magic_name__=0.1      ,				__magic_name__=0.1      ,				__magic_name__=5_12      ,				__magic_name__=16      ,				__magic_name__=2      ,				__magic_name__=0.0_2      ,				__magic_name__=3      ,				__magic_name__=4      ,				__magic_name__=None      ,				)					->							int:
      _a			      =							parent
      _a			      =							13
      _a			      =							7
      _a			      =							True
      _a			      =							True
      _a			      =							True
      _a			      =							True
      _a			      =							99
      _a			      =							32
      _a			      =							2
      _a			      =							4
      _a			      =							37
      _a			      =							'gelu'
      _a			      =							0.1
      _a			      =							0.1
      _a			      =							5_12
      _a			      =							16
      _a			      =							2
      _a			      =							0.0_2
      _a			      =							3
      _a			      =							4
      _a			      =							None
 def 							__UpperCAmelCase		( self						)					->							List[str]:
      _a			      =							ids_tensor([self.batch_size, self.seq_length]      ,				self.vocab_size						)

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

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

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

      _a			      =							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=__magic_name__      ,				)

      return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels
 def 							__UpperCAmelCase		( self      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__						)					->							Any:
      _a			      =							TFRoFormerModel(config=__magic_name__						)
      _a			      =							{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}

      _a			      =							[input_ids, input_mask]
      _a			      =							model(__magic_name__						)

      _a			      =							model(__magic_name__						)

      self.parent.assertEqual(result.last_hidden_state.shape      ,				(self.batch_size, self.seq_length, self.hidden_size)						)
 def 							__UpperCAmelCase		( self      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__						)					->							Tuple:
      _a			      =							True
      _a			      =							TFRoFormerForCausalLM(config=__magic_name__						)
      _a			      =							{
          'input_ids': input_ids,
          'attention_mask': input_mask,
          'token_type_ids': token_type_ids,
      }
      _a			      =							model(__magic_name__						)['logits']
      self.parent.assertListEqual(
          list(prediction_scores.numpy().shape						)      ,				[self.batch_size, self.seq_length, self.vocab_size]						)
 def 							__UpperCAmelCase		( self      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__						)					->							Union[str, Any]:
      _a			      =							TFRoFormerForMaskedLM(config=__magic_name__						)
      _a			      =							{
          'input_ids': input_ids,
          'attention_mask': input_mask,
          'token_type_ids': token_type_ids,
      }
      _a			      =							model(__magic_name__						)
      self.parent.assertEqual(result.logits.shape      ,				(self.batch_size, self.seq_length, self.vocab_size)						)
 def 							__UpperCAmelCase		( self      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__						)					->							List[str]:
      _a			      =							self.num_labels
      _a			      =							TFRoFormerForSequenceClassification(config=__magic_name__						)
      _a			      =							{
          'input_ids': input_ids,
          'attention_mask': input_mask,
          'token_type_ids': token_type_ids,
      }

      _a			      =							model(__magic_name__						)
      self.parent.assertEqual(result.logits.shape      ,				(self.batch_size, self.num_labels)						)
 def 							__UpperCAmelCase		( self      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__						)					->							Dict:
      _a			      =							self.num_choices
      _a			      =							TFRoFormerForMultipleChoice(config=__magic_name__						)
      _a			      =							tf.tile(tf.expand_dims(__magic_name__      ,				1						)      ,				(1, self.num_choices, 1)						)
      _a			      =							tf.tile(tf.expand_dims(__magic_name__      ,				1						)      ,				(1, self.num_choices, 1)						)
      _a			      =							tf.tile(tf.expand_dims(__magic_name__      ,				1						)      ,				(1, self.num_choices, 1)						)
      _a			      =							{
          'input_ids': multiple_choice_inputs_ids,
          'attention_mask': multiple_choice_input_mask,
          'token_type_ids': multiple_choice_token_type_ids,
      }
      _a			      =							model(__magic_name__						)
      self.parent.assertEqual(result.logits.shape      ,				(self.batch_size, self.num_choices)						)
 def 							__UpperCAmelCase		( self      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__						)					->							Any:
      _a			      =							self.num_labels
      _a			      =							TFRoFormerForTokenClassification(config=__magic_name__						)
      _a			      =							{
          'input_ids': input_ids,
          'attention_mask': input_mask,
          'token_type_ids': token_type_ids,
      }
      _a			      =							model(__magic_name__						)
      self.parent.assertEqual(result.logits.shape      ,				(self.batch_size, self.seq_length, self.num_labels)						)
 def 							__UpperCAmelCase		( self      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__						)					->							int:
      _a			      =							TFRoFormerForQuestionAnswering(config=__magic_name__						)
      _a			      =							{
          'input_ids': input_ids,
          'attention_mask': input_mask,
          'token_type_ids': token_type_ids,
      }

      _a			      =							model(__magic_name__						)
      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						)					->							Optional[int]:
      _a			      =							self.prepare_config_and_inputs()
      (
          (
          _a
      )      ,   (
          _a
      )      ,   (
          _a
      )      ,   (
          _a
      )      ,   (
          _a
      )      ,   (
          _a
      )      ,   (
          _a
      )      ,   
      )			      =							config_and_inputs
      _a			      =							{'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
      return config, inputs_dict





@require_tf
class  a     (     _SCREAMING_SNAKE_CASE  ,				_SCREAMING_SNAKE_CASE  ,				unittest.TestCase       ):
 _lowerCAmelCase 					=	(
     (
         TFRoFormerModel,
         TFRoFormerForCausalLM,
         TFRoFormerForMaskedLM,
         TFRoFormerForQuestionAnswering,
         TFRoFormerForSequenceClassification,
         TFRoFormerForTokenClassification,
         TFRoFormerForMultipleChoice,
     )
     if is_tf_available()
     else ()
 )
 _lowerCAmelCase 					=	(
     {
         """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 {}
 )

 _lowerCAmelCase 					=	False
 _lowerCAmelCase 					=	False
 def 							__UpperCAmelCase		( self      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__						)					->							Optional[Any]:
      if pipeline_test_casse_name == "TextGenerationPipelineTests":
           return True

      return False
 def 							__UpperCAmelCase		( self						)					->							str:
      _a			      =							TFRoFormerModelTester(self						)
      _a			      =							ConfigTester(self      ,				config_class=__magic_name__      ,				hidden_size=37						)
 def 							__UpperCAmelCase		( self						)					->							Union[str, Any]:
      self.config_tester.run_common_tests()
 def 							__UpperCAmelCase		( self						)					->							Optional[int]:
      _a			      =							self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_model(*__magic_name__						)
 def 							__UpperCAmelCase		( self						)					->							str:
      _a			      =							self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_masked_lm(*__magic_name__						)
 def 							__UpperCAmelCase		( self						)					->							Optional[int]:
      _a			      =							self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_lm_head(*__magic_name__						)
 def 							__UpperCAmelCase		( self						)					->							Optional[int]:
      _a			      =							self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_multiple_choice(*__magic_name__						)
 def 							__UpperCAmelCase		( self						)					->							Optional[Any]:
      _a			      =							self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_question_answering(*__magic_name__						)
 def 							__UpperCAmelCase		( self						)					->							List[Any]:
      _a			      =							self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_sequence_classification(*__magic_name__						)
 def 							__UpperCAmelCase		( self						)					->							str:
      _a			      =							self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_token_classification(*__magic_name__						)




 @slow
 def 							__UpperCAmelCase		( self						)					->							Optional[Any]:
      _a			      =							TFRoFormerModel.from_pretrained('junnyu/roformer_chinese_base'						)
      self.assertIsNotNone(__magic_name__						)





@require_tf
class  a     (     unittest.TestCase       ):
 @slow
 def 							__UpperCAmelCase		( self						)					->							List[str]:
      _a			      =							TFRoFormerForMaskedLM.from_pretrained('junnyu/roformer_chinese_base'						)
      _a			      =							tf.constant([[0, 1, 2, 3, 4, 5]]						)
      _a			      =							model(__magic_name__						)[0]

      # TODO Replace vocab size
      _a			      =							5_00_00

      _a			      =							[1, 6, vocab_size]
      self.assertEqual(output.shape      ,				__magic_name__						)

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

      # TODO Replace values below with what was printed above.
      _a			      =							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]      ,				__magic_name__      ,				atol=1e-4						)





@require_tf
class  a     (     unittest.TestCase       ):
 _lowerCAmelCase 					=	1E-4
 def 							__UpperCAmelCase		( self						)					->							List[Any]:
      _a			      =							tf.constant([[4, 10]]						)
      _a			      =							TFRoFormerSinusoidalPositionalEmbedding(num_positions=6      ,				embedding_dim=6						)

      _a			      =							emba(input_ids.shape						)
      _a			      =							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(__magic_name__      ,				__magic_name__      ,				atol=self.tolerance						)




 def 							__UpperCAmelCase		( self						)					->							int:
      _a			      =							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],
          ]						)
      _a			      =							TFRoFormerSinusoidalPositionalEmbedding(num_positions=5_12      ,				embedding_dim=5_12						)
      emba([2, 16, 5_12]						)
      _a			      =							emba.weight[:3, :5]

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





@require_tf
class  a     (     unittest.TestCase       ):
 _lowerCAmelCase 					=	1E-4
 def 							__UpperCAmelCase		( self						)					->							int:
      # 2,12,16,64
      _a			      =							tf.reshape(tf.range(2 * 12 * 16 * 64      ,				dtype=tf.floataa						)      ,				shape=(2, 12, 16, 64)						) / 1_00

      _a			      =							-tf.reshape(tf.range(2 * 12 * 16 * 64      ,				dtype=tf.floataa						)      ,				shape=(2, 12, 16, 64)						) / 1_00

      _a			      =							TFRoFormerSinusoidalPositionalEmbedding(num_positions=32      ,				embedding_dim=64						)
      _a			      =							embed_positions([2, 16, 7_68]						)[None, None, :, :]

      _a      ,   _a			      =							TFRoFormerSelfAttention.apply_rotary_position_embeddings(
          __magic_name__      ,				__magic_name__      ,				__magic_name__						)

      _a			      =							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],
          ]						)
      _a			      =							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]      ,				__magic_name__      ,				atol=self.tolerance						)
      tf.debugging.assert_near(key_layer[0, 0, :6, :8]      ,				__magic_name__      ,				atol=self.tolerance						)





'''simple docstring'''






from functools import reduce

a_					:    Any          =    (
    "73167176531330624919225119674426574742355349194934"
    "96983520312774506326239578318016984801869478851843"
    "85861560789112949495459501737958331952853208805511"
    "12540698747158523863050715693290963295227443043557"
    "66896648950445244523161731856403098711121722383113"
    "62229893423380308135336276614282806444486645238749"
    "30358907296290491560440772390713810515859307960866"
    "70172427121883998797908792274921901699720888093776"
    "65727333001053367881220235421809751254540594752243"
    "52584907711670556013604839586446706324415722155397"
    "53697817977846174064955149290862569321978468622482"
    "83972241375657056057490261407972968652414535100474"
    "82166370484403199890008895243450658541227588666881"
    "16427171479924442928230863465674813919123162824586"
    "17866458359124566529476545682848912883142607690042"
    "24219022671055626321111109370544217506941658960408"
    "07198403850962455444362981230987879927244284909188"
    "84580156166097919133875499200524063689912560717606"
    "05886116467109405077541002256983155200055935729725"
    "71636269561882670428252483600823257530420752963450"
)






def 	_A				(lowerCAmelCase__  :str = N		)   ->  int:




     '''simple docstring'''



     return max(
         # mypy cannot properly interpret reduce
         int(reduce(lambda lowerCAmelCase__				,						lowerCAmelCase__		: str(int(lowerCAmelCase__		) * int(lowerCAmelCase__		)		)				,						n[i : i + 13]		)		)
         for i in range(len(lowerCAmelCase__		) - 12		)		)


if __name__ == "__main__":
 print(f'''{solution() = }''')

