
'''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  SCREAMING_SNAKE_CASE__       :
	def __init__(				self  ,    __UpperCamelCase  ,    __UpperCamelCase=13  ,    __UpperCamelCase=7  ,    __UpperCamelCase=True  ,    __UpperCamelCase=True  ,    __UpperCamelCase=False  ,    __UpperCamelCase=True  ,    __UpperCamelCase=99  ,    __UpperCamelCase=64  ,    __UpperCamelCase=2  ,    __UpperCamelCase=4  ,    __UpperCamelCase=64  ,    __UpperCamelCase="gelu"  ,    __UpperCamelCase=0.1  ,    __UpperCamelCase=0.1  ,    __UpperCamelCase=512  ,    __UpperCamelCase=16  ,    __UpperCamelCase=2  ,    __UpperCamelCase=0.0_2  ,    __UpperCamelCase=3  ,    __UpperCamelCase=4  ,    __UpperCamelCase=None  ,    ):



					'''simple docstring'''






					__a       :     Optional[int]								=	parent
					__a       :     Optional[int]								=	batch_size
					__a       :     Dict								=	seq_length
					__a       :     Tuple								=	is_training
					__a       :     Union[str, Any]								=	use_input_mask
					__a       :     str								=	use_token_type_ids
					__a       :     Any								=	use_labels
					__a       :     Optional[Any]								=	vocab_size
					__a       :     Dict								=	hidden_size
					__a       :     List[Any]								=	num_hidden_layers
					__a       :     Optional[Any]								=	num_attention_heads
					__a       :     Optional[Any]								=	intermediate_size
					__a       :     Tuple								=	hidden_act
					__a       :     List[str]								=	hidden_dropout_prob
					__a       :     Dict								=	attention_probs_dropout_prob
					__a       :     Any								=	max_position_embeddings
					__a       :     Dict								=	type_vocab_size
					__a       :     Optional[Any]								=	type_sequence_label_size
					__a       :     Union[str, Any]								=	initializer_range
					__a       :     Optional[Any]								=	num_labels
					__a       :     Optional[int]								=	num_choices
					__a       :     Union[str, Any]								=	scope
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     Dict								=	ids_tensor([self.batch_size, self.seq_length]  ,    self.vocab_size			)

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

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

					__a       :     Any								=	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  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase			):



					'''simple docstring'''






					__a       :     List[str]								=	TFMPNetModel(config=__UpperCamelCase			)
					__a       :     Dict								=	{"""input_ids""": input_ids, """attention_mask""": input_mask}
					__a       :     Dict								=	model(__UpperCamelCase			)
					__a       :     List[Any]								=	[input_ids, input_mask]
					__a       :     List[str]								=	model(__UpperCamelCase			)
					self.parent.assertEqual(result.last_hidden_state.shape  ,    (self.batch_size, self.seq_length, self.hidden_size)			)
	def __lowerCamelCase    (				self  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase			):



					'''simple docstring'''






					__a       :     List[str]								=	TFMPNetForMaskedLM(config=__UpperCamelCase			)
					__a       :     Tuple								=	{"""input_ids""": input_ids, """attention_mask""": input_mask}
					__a       :     Tuple								=	model(__UpperCamelCase			)
					self.parent.assertEqual(result.logits.shape  ,    (self.batch_size, self.seq_length, self.vocab_size)			)
	def __lowerCamelCase    (				self  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase			):



					'''simple docstring'''






					__a       :     Optional[Any]								=	TFMPNetForQuestionAnswering(config=__UpperCamelCase			)
					__a       :     Dict								=	{
					    """input_ids""": input_ids,
					    """attention_mask""": input_mask,
					}
					__a       :     str								=	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  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase			):



					'''simple docstring'''






					__a       :     Optional[Any]								=	self.num_labels
					__a       :     str								=	TFMPNetForSequenceClassification(__UpperCamelCase			)
					__a       :     str								=	{"""input_ids""": input_ids, """attention_mask""": input_mask}
					__a       :     Optional[int]								=	model(__UpperCamelCase			)
					self.parent.assertEqual(result.logits.shape  ,    (self.batch_size, self.num_labels)			)
	def __lowerCamelCase    (				self  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase			):



					'''simple docstring'''






					__a       :     Union[str, Any]								=	self.num_choices
					__a       :     List[Any]								=	TFMPNetForMultipleChoice(__UpperCamelCase			)
					__a       :     Tuple								=	tf.tile(tf.expand_dims(__UpperCamelCase  ,    1			)  ,    (1, self.num_choices, 1)			)
					__a       :     Any								=	tf.tile(tf.expand_dims(__UpperCamelCase  ,    1			)  ,    (1, self.num_choices, 1)			)
					__a       :     Dict								=	{
					    """input_ids""": multiple_choice_inputs_ids,
					    """attention_mask""": multiple_choice_input_mask,
					}
					__a       :     Any								=	model(__UpperCamelCase			)
					self.parent.assertEqual(result.logits.shape  ,    (self.batch_size, self.num_choices)			)
	def __lowerCamelCase    (				self  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase			):



					'''simple docstring'''






					__a       :     List[str]								=	self.num_labels
					__a       :     List[str]								=	TFMPNetForTokenClassification(__UpperCamelCase			)
					__a       :     Dict								=	{"""input_ids""": input_ids, """attention_mask""": input_mask}
					__a       :     Any								=	model(__UpperCamelCase			)
					self.parent.assertEqual(result.logits.shape  ,    (self.batch_size, self.seq_length, self.num_labels)			)

	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     List[Any]								=	self.prepare_config_and_inputs()
					((__a)							,	(__a)							,	(__a)							,	(__a)							,	(__a)							,	(__a))       :     List[str]								=	config_and_inputs
					__a       :     int								=	{"""input_ids""": input_ids, """attention_mask""": input_mask}
					return config, inputs_dict







@require_tf
class  SCREAMING_SNAKE_CASE__       (  __UpperCamelCase			,					__UpperCamelCase			,					unittest.TestCase   ):
	lowercase__	    =							(
	    (
	        TFMPNetForMaskedLM,
	        TFMPNetForMultipleChoice,
	        TFMPNetForQuestionAnswering,
	        TFMPNetForSequenceClassification,
	        TFMPNetForTokenClassification,
	        TFMPNetModel,
	    )
	    if is_tf_available()
	    else ()
	)
	lowercase__	    =							(
	    {
	        "feature-extraction": TFMPNetModel,
	        "fill-mask": TFMPNetForMaskedLM,
	        "question-answering": TFMPNetForQuestionAnswering,
	        "text-classification": TFMPNetForSequenceClassification,
	        "token-classification": TFMPNetForTokenClassification,
	        "zero-shot": TFMPNetForSequenceClassification,
	    }
	    if is_tf_available()
	    else {}
	)
	lowercase__	    =							False
	lowercase__	    =							False
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     List[Any]								=	TFMPNetModelTester(self			)
					__a       :     Union[str, Any]								=	ConfigTester(self  ,    config_class=__UpperCamelCase  ,    hidden_size=37			)
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					self.config_tester.run_common_tests()
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     Any								=	self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_mpnet_model(*__UpperCamelCase			)
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     Dict								=	self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_mpnet_for_masked_lm(*__UpperCamelCase			)
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     Dict								=	self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_mpnet_for_question_answering(*__UpperCamelCase			)
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     Optional[Any]								=	self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_mpnet_for_sequence_classification(*__UpperCamelCase			)
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     Union[str, Any]								=	self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_mpnet_for_multiple_choice(*__UpperCamelCase			)
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     str								=	self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_mpnet_for_token_classification(*__UpperCamelCase			)

	@slow
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					for model_name in ["microsoft/mpnet-base"]:
									__a       :     Union[str, Any]								=	TFMPNetModel.from_pretrained(__UpperCamelCase			)
									self.assertIsNotNone(__UpperCamelCase			)







@require_tf
class  SCREAMING_SNAKE_CASE__       (  unittest.TestCase   ):
	@slow
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     Tuple								=	TFMPNetModel.from_pretrained("""microsoft/mpnet-base"""			)
					__a       :     str								=	tf.constant([[0, 1, 2, 3, 4, 5]]			)
					__a       :     List[Any]								=	model(__UpperCamelCase			)[0]

					__a       :     str								=	[1, 6, 768]
					self.assertEqual(output.shape  ,    __UpperCamelCase			)

					__a       :     Union[str, Any]								=	tf.constant(
					    [
					        [
					            [-0.1_0_6_7_1_7_2, 0.0_8_2_1_6_4_7_3, 0.0_0_2_4_5_4_3],
					            [-0.0_3_4_6_5_8_7_9, 0.8_3_5_4_1_1_8, -0.0_3_2_5_2_2_8_8],
					            [-0.0_6_5_6_9_4_7_6, -0.1_2_4_2_4_1_1_1, -0.0_4_9_4_4_3_6],
					        ]
					    ]			)
					tf.debugging.assert_near(output[:, :3, :3]  ,    __UpperCamelCase  ,    atol=1E-4			)

'''simple docstring'''







def 				_snake_case (		lowercase = 2_0						)       ->       int:

				try:
								__a       :     Optional[Any]								=	int(lowercase						)
				except (TypeError, ValueError):
								raise TypeError("""Parameter n must be int or castable to int."""						)
				if n <= 0:
								raise ValueError("""Parameter n must be greater than or equal to one."""						)
				__a       :     List[Any]								=	0
				while 1:
								i += n * (n - 1)
								__a       :     Union[str, Any]								=	0
								for j in range(2			,    lowercase						):
												if i % j != 0:
																__a       :     Any								=	1
																break
								if nfound == 0:
												if i == 0:
																__a       :     List[str]								=	1
												return i
				return None


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