


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

import unittest

from transformers import MPNetConfig, 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.models.mpnet.modeling_tf_mpnet import (
				    TFMPNetForMaskedLM,
				    TFMPNetForMultipleChoice,
				    TFMPNetForQuestionAnswering,
				    TFMPNetForSequenceClassification,
				    TFMPNetForTokenClassification,
				    TFMPNetModel,
				)





class   __A  :





							'''simple docstring'''

							def __init__(					self				:   int		,							UpperCAmelCase_				:   str		,							UpperCAmelCase_				:   List[Any]=13		,							UpperCAmelCase_				:   Any=7		,							UpperCAmelCase_				:   List[Any]=True		,							UpperCAmelCase_				:   List[str]=True		,							UpperCAmelCase_				:   int=False		,							UpperCAmelCase_				:   str=True		,							UpperCAmelCase_				:   List[Any]=99		,							UpperCAmelCase_				:   Dict=64		,							UpperCAmelCase_				:   Optional[int]=2		,							UpperCAmelCase_				:   Optional[Any]=4		,							UpperCAmelCase_				:   Tuple=64		,							UpperCAmelCase_				:   List[str]="gelu"		,							UpperCAmelCase_				:   Tuple=0.1		,							UpperCAmelCase_				:   Dict=0.1		,							UpperCAmelCase_				:   Optional[Any]=512		,							UpperCAmelCase_				:   Union[str, Any]=16		,							UpperCAmelCase_				:   Union[str, Any]=2		,							UpperCAmelCase_				:   Dict=0.02		,							UpperCAmelCase_				:   Dict=3		,							UpperCAmelCase_				:   Any=4		,							UpperCAmelCase_				:   List[Any]=None		,							)       ->Optional[int]:



														"""simple docstring"""



														snake_case_     							=		parent
														snake_case_     							=		batch_size
														snake_case_     							=		seq_length
														snake_case_     							=		is_training
														snake_case_     							=		use_input_mask
														snake_case_     							=		use_token_type_ids
														snake_case_     							=		use_labels
														snake_case_     							=		vocab_size
														snake_case_     							=		hidden_size
														snake_case_     							=		num_hidden_layers
														snake_case_     							=		num_attention_heads
														snake_case_     							=		intermediate_size
														snake_case_     							=		hidden_act
														snake_case_     							=		hidden_dropout_prob
														snake_case_     							=		attention_probs_dropout_prob
														snake_case_     							=		max_position_embeddings
														snake_case_     							=		type_vocab_size
														snake_case_     							=		type_sequence_label_size
														snake_case_     							=		initializer_range
														snake_case_     							=		num_labels
														snake_case_     							=		num_choices
														snake_case_     							=		scope



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



														"""simple docstring"""



														snake_case_     							=		ids_tensor([self.batch_size, self.seq_length]		,							self.vocab_size							)

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

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

														snake_case_     							=		MPNetConfig(
														    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		,							initializer_range=self.initializer_range		,							)
														return config, input_ids, input_mask, sequence_labels, token_labels, choice_labels



							def 		lowerCAmelCase							(					self				:   Dict		,							UpperCAmelCase_				:   str		,							UpperCAmelCase_				:   Union[str, Any]		,							UpperCAmelCase_				:   int		,							UpperCAmelCase_				:   Optional[int]		,							UpperCAmelCase_				:   Any		,							UpperCAmelCase_				:   Tuple							)       ->int:



														"""simple docstring"""



														snake_case_     							=		TFMPNetModel(config=UpperCAmelCase_							)
														snake_case_     							=		{"""input_ids""": input_ids, """attention_mask""": input_mask}
														snake_case_     							=		model(UpperCAmelCase_							)
														snake_case_     							=		[input_ids, input_mask]
														snake_case_     							=		model(UpperCAmelCase_							)
														self.parent.assertEqual(result.last_hidden_state.shape		,							(self.batch_size, self.seq_length, self.hidden_size)							)



							def 		lowerCAmelCase							(					self				:   Optional[Any]		,							UpperCAmelCase_				:   List[Any]		,							UpperCAmelCase_				:   Dict		,							UpperCAmelCase_				:   int		,							UpperCAmelCase_				:   int		,							UpperCAmelCase_				:   int		,							UpperCAmelCase_				:   Union[str, Any]							)       ->Tuple:



														"""simple docstring"""



														snake_case_     							=		TFMPNetForMaskedLM(config=UpperCAmelCase_							)
														snake_case_     							=		{"""input_ids""": input_ids, """attention_mask""": input_mask}
														snake_case_     							=		model(UpperCAmelCase_							)
														self.parent.assertEqual(result.logits.shape		,							(self.batch_size, self.seq_length, self.vocab_size)							)



							def 		lowerCAmelCase							(					self				:   Optional[Any]		,							UpperCAmelCase_				:   str		,							UpperCAmelCase_				:   List[Any]		,							UpperCAmelCase_				:   Tuple		,							UpperCAmelCase_				:   Any		,							UpperCAmelCase_				:   List[Any]		,							UpperCAmelCase_				:   Dict							)       ->List[str]:



														"""simple docstring"""



														snake_case_     							=		TFMPNetForQuestionAnswering(config=UpperCAmelCase_							)
														snake_case_     							=		{
														    """input_ids""": input_ids,
														    """attention_mask""": input_mask,
														}
														snake_case_     							=		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				:   List[str]		,							UpperCAmelCase_				:   Union[str, Any]		,							UpperCAmelCase_				:   List[str]		,							UpperCAmelCase_				:   int		,							UpperCAmelCase_				:   Optional[Any]		,							UpperCAmelCase_				:   Union[str, Any]		,							UpperCAmelCase_				:   List[Any]							)       ->str:



														"""simple docstring"""



														snake_case_     							=		self.num_labels
														snake_case_     							=		TFMPNetForSequenceClassification(UpperCAmelCase_							)
														snake_case_     							=		{"""input_ids""": input_ids, """attention_mask""": input_mask}
														snake_case_     							=		model(UpperCAmelCase_							)
														self.parent.assertEqual(result.logits.shape		,							(self.batch_size, self.num_labels)							)



							def 		lowerCAmelCase							(					self				:   Optional[Any]		,							UpperCAmelCase_				:   List[Any]		,							UpperCAmelCase_				:   Optional[Any]		,							UpperCAmelCase_				:   Optional[Any]		,							UpperCAmelCase_				:   Any		,							UpperCAmelCase_				:   Tuple		,							UpperCAmelCase_				:   Optional[int]							)       ->List[str]:



														"""simple docstring"""



														snake_case_     							=		self.num_choices
														snake_case_     							=		TFMPNetForMultipleChoice(UpperCAmelCase_							)
														snake_case_     							=		tf.tile(tf.expand_dims(UpperCAmelCase_		,							1							)		,							(1, self.num_choices, 1)							)
														snake_case_     							=		tf.tile(tf.expand_dims(UpperCAmelCase_		,							1							)		,							(1, self.num_choices, 1)							)
														snake_case_     							=		{
														    """input_ids""": multiple_choice_inputs_ids,
														    """attention_mask""": multiple_choice_input_mask,
														}
														snake_case_     							=		model(UpperCAmelCase_							)
														self.parent.assertEqual(result.logits.shape		,							(self.batch_size, self.num_choices)							)



							def 		lowerCAmelCase							(					self				:   Dict		,							UpperCAmelCase_				:   List[Any]		,							UpperCAmelCase_				:   Any		,							UpperCAmelCase_				:   Tuple		,							UpperCAmelCase_				:   Optional[Any]		,							UpperCAmelCase_				:   Union[str, Any]		,							UpperCAmelCase_				:   Dict							)       ->str:



														"""simple docstring"""



														snake_case_     							=		self.num_labels
														snake_case_     							=		TFMPNetForTokenClassification(UpperCAmelCase_							)
														snake_case_     							=		{"""input_ids""": input_ids, """attention_mask""": input_mask}
														snake_case_     							=		model(UpperCAmelCase_							)
														self.parent.assertEqual(result.logits.shape		,							(self.batch_size, self.seq_length, self.num_labels)							)



							def 		lowerCAmelCase							(					self				:   Tuple							)       ->Optional[int]:



														"""simple docstring"""



														snake_case_     							=		self.prepare_config_and_inputs()
														((snake_case_)							,    (snake_case_)							,    (snake_case_)							,    (snake_case_)							,    (snake_case_)							,    (snake_case_))     							=		config_and_inputs
														snake_case_     							=		{"""input_ids""": input_ids, """attention_mask""": input_mask}
														return config, inputs_dict





@require_tf
class   __A  (snake_case__    ,		snake_case__    ,		unittest.TestCase):





							'''simple docstring'''

							__lowercase:		Union[str, Any]				   =     (
							    (
							        TFMPNetForMaskedLM,
							        TFMPNetForMultipleChoice,
							        TFMPNetForQuestionAnswering,
							        TFMPNetForSequenceClassification,
							        TFMPNetForTokenClassification,
							        TFMPNetModel,
							    )
							    if is_tf_available()
							    else ()
							)
							__lowercase:		str				   =     (
							    {
							        """feature-extraction""": TFMPNetModel,
							        """fill-mask""": TFMPNetForMaskedLM,
							        """question-answering""": TFMPNetForQuestionAnswering,
							        """text-classification""": TFMPNetForSequenceClassification,
							        """token-classification""": TFMPNetForTokenClassification,
							        """zero-shot""": TFMPNetForSequenceClassification,
							    }
							    if is_tf_available()
							    else {}
							)
							__lowercase:		Optional[int]				   =     False
							__lowercase:		Optional[Any]				   =     False



							def 		lowerCAmelCase							(					self				:   List[str]							)       ->Dict:



														"""simple docstring"""



														snake_case_     							=		TFMPNetModelTester(self							)
														snake_case_     							=		ConfigTester(self		,							config_class=UpperCAmelCase_		,							hidden_size=37							)



							def 		lowerCAmelCase							(					self				:   Dict							)       ->Optional[int]:



														"""simple docstring"""



														self.config_tester.run_common_tests()



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



														"""simple docstring"""



														snake_case_     							=		self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_mpnet_model(*UpperCAmelCase_							)



							def 		lowerCAmelCase							(					self				:   Optional[int]							)       ->Dict:



														"""simple docstring"""



														snake_case_     							=		self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_mpnet_for_masked_lm(*UpperCAmelCase_							)



							def 		lowerCAmelCase							(					self				:   Tuple							)       ->Dict:



														"""simple docstring"""



														snake_case_     							=		self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_mpnet_for_question_answering(*UpperCAmelCase_							)



							def 		lowerCAmelCase							(					self				:   Optional[Any]							)       ->Tuple:



														"""simple docstring"""



														snake_case_     							=		self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_mpnet_for_sequence_classification(*UpperCAmelCase_							)



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



														"""simple docstring"""



														snake_case_     							=		self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_mpnet_for_multiple_choice(*UpperCAmelCase_							)



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



														"""simple docstring"""



														snake_case_     							=		self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_mpnet_for_token_classification(*UpperCAmelCase_							)



							@slow
							def 		lowerCAmelCase							(					self				:   Tuple							)       ->Any:



														"""simple docstring"""



														for model_name in ["microsoft/mpnet-base"]:
																					snake_case_     							=		TFMPNetModel.from_pretrained(UpperCAmelCase_							)
																					self.assertIsNotNone(UpperCAmelCase_							)





@require_tf
class   __A  (unittest.TestCase):





							'''simple docstring'''

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



														"""simple docstring"""



														snake_case_     							=		TFMPNetModel.from_pretrained("""microsoft/mpnet-base"""							)
														snake_case_     							=		tf.constant([[0, 1, 2, 3, 4, 5]]							)
														snake_case_     							=		model(UpperCAmelCase_							)[0]

														snake_case_     							=		[1, 6, 768]
														self.assertEqual(output.shape		,							UpperCAmelCase_							)

														snake_case_     							=		tf.constant(
														    [
														        [
														            [-0.1_067_172, 0.08_216_473, 0.0_024_543],
														            [-0.03_465_879, 0.8_354_118, -0.03_252_288],
														            [-0.06_569_476, -0.12_424_111, -0.0_494_436],
														        ]
														    ]							)
														tf.debugging.assert_near(output[:, :3, :3]		,							UpperCAmelCase_		,							atol=1E-4							)







"""simple docstring"""
import math







def     _a					(   _SCREAMING_SNAKE_CASE					)     ->					list[int]:
							if not isinstance(_SCREAMING_SNAKE_CASE					,			_SCREAMING_SNAKE_CASE					):
														snake_case_     							=		f"""Input value of [number={number}] must be an integer"""
														raise TypeError(_SCREAMING_SNAKE_CASE					)
							if number < 1:
														snake_case_     							=		f"""Input value of [number={number}] must be a positive integer"""
														raise ValueError(_SCREAMING_SNAKE_CASE					)
							snake_case_     							=		[number]
							while number != 1:
														if number % 2 == 0:
																					snake_case_     							=		math.floor(math.sqrt(_SCREAMING_SNAKE_CASE					)					)
														else:
																					snake_case_     							=		math.floor(
																					    math.sqrt(_SCREAMING_SNAKE_CASE					) * math.sqrt(_SCREAMING_SNAKE_CASE					) * math.sqrt(_SCREAMING_SNAKE_CASE					)					)
														sequence.append(_SCREAMING_SNAKE_CASE					)
							return sequence


if __name__ == "__main__":
				import doctest

				doctest.testmod()



