


"""simple docstring"""


from __future__ import annotations

import unittest

from transformers import FunnelConfig, is_tf_available
from transformers.testing_utils import require_tf

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 (
	    TFFunnelBaseModel,
	    TFFunnelForMaskedLM,
	    TFFunnelForMultipleChoice,
	    TFFunnelForPreTraining,
	    TFFunnelForQuestionAnswering,
	    TFFunnelForSequenceClassification,
	    TFFunnelForTokenClassification,
	    TFFunnelModel,
	)
class   _UpperCamelCase  :
							'''simple docstring'''







							def __init__(     self    ,   __a    ,   __a=13    ,   __a=7    ,   __a=True    ,   __a=True    ,   __a=True    ,   __a=True    ,   __a=99    ,   __a=[1, 1, 2]    ,   __a=1    ,   __a=32    ,   __a=4    ,   __a=8    ,   __a=37    ,   __a="gelu_new"    ,   __a=0.1    ,   __a=0.1    ,   __a=0.0    ,   __a=5_12    ,   __a=3    ,   __a=0.0_2    ,   __a=3    ,   __a=4    ,   __a=None    ,   __a=False    ,   ):
										__lowerCAmelCase				    =			parent
										__lowerCAmelCase				    =			batch_size
										__lowerCAmelCase				    =			seq_length
										__lowerCAmelCase				    =			is_training
										__lowerCAmelCase				    =			use_input_mask
										__lowerCAmelCase				    =			use_token_type_ids
										__lowerCAmelCase				    =			use_labels
										__lowerCAmelCase				    =			vocab_size
										__lowerCAmelCase				    =			block_sizes
										__lowerCAmelCase				    =			num_decoder_layers
										__lowerCAmelCase				    =			d_model
										__lowerCAmelCase				    =			n_head
										__lowerCAmelCase				    =			d_head
										__lowerCAmelCase				    =			d_inner
										__lowerCAmelCase				    =			hidden_act
										__lowerCAmelCase				    =			hidden_dropout
										__lowerCAmelCase				    =			attention_dropout
										__lowerCAmelCase				    =			activation_dropout
										__lowerCAmelCase				    =			max_position_embeddings
										__lowerCAmelCase				    =			type_vocab_size
										__lowerCAmelCase				    =			2
										__lowerCAmelCase				    =			num_labels
										__lowerCAmelCase				    =			num_choices
										__lowerCAmelCase				    =			scope
										__lowerCAmelCase				    =			initializer_std

										# Used in the tests to check the size of the first attention layer
										__lowerCAmelCase				    =			n_head
										# Used in the tests to check the size of the first hidden state
										__lowerCAmelCase				    =			self.d_model
										# Used in the tests to check the number of output hidden states/attentions
										__lowerCAmelCase				    =			sum(self.block_sizes	) + (0 if base else self.num_decoder_layers)
										# FunnelModel adds two hidden layers: input embeddings and the sum of the upsampled encoder hidden state with
										# the last hidden state of the first block (which is the first hidden state of the decoder).
										if not base:
													__lowerCAmelCase				    =			self.num_hidden_layers + 2

							def 			snake_case				(     self	):
										__lowerCAmelCase				    =			ids_tensor([self.batch_size, self.seq_length]    ,   self.vocab_size	)

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

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

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

										__lowerCAmelCase				    =			FunnelConfig(
										    vocab_size=self.vocab_size    ,   block_sizes=self.block_sizes    ,   num_decoder_layers=self.num_decoder_layers    ,   d_model=self.d_model    ,   n_head=self.n_head    ,   d_head=self.d_head    ,   d_inner=self.d_inner    ,   hidden_act=self.hidden_act    ,   hidden_dropout=self.hidden_dropout    ,   attention_dropout=self.attention_dropout    ,   activation_dropout=self.activation_dropout    ,   max_position_embeddings=self.max_position_embeddings    ,   type_vocab_size=self.type_vocab_size    ,   initializer_std=self.initializer_std    ,   )

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

							def 			snake_case				(     self    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   ):
										__lowerCAmelCase				    =			TFFunnelModel(config=__a	)
										__lowerCAmelCase				    =			{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
										__lowerCAmelCase				    =			model(__a	)

										__lowerCAmelCase				    =			[input_ids, input_mask]
										__lowerCAmelCase				    =			model(__a	)

										__lowerCAmelCase				    =			model(__a	)
										self.parent.assertEqual(result.last_hidden_state.shape    ,   (self.batch_size, self.seq_length, self.d_model)	)

										__lowerCAmelCase				    =			False
										__lowerCAmelCase				    =			TFFunnelModel(config=__a	)
										__lowerCAmelCase				    =			model(__a	)
										self.parent.assertEqual(result.last_hidden_state.shape    ,   (self.batch_size, self.seq_length, self.d_model)	)

										__lowerCAmelCase				    =			False
										__lowerCAmelCase				    =			TFFunnelModel(config=__a	)
										__lowerCAmelCase				    =			model(__a	)
										self.parent.assertEqual(result.last_hidden_state.shape    ,   (self.batch_size, self.seq_length, self.d_model)	)

							def 			snake_case				(     self    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   ):
										__lowerCAmelCase				    =			TFFunnelBaseModel(config=__a	)
										__lowerCAmelCase				    =			{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
										__lowerCAmelCase				    =			model(__a	)

										__lowerCAmelCase				    =			[input_ids, input_mask]
										__lowerCAmelCase				    =			model(__a	)

										__lowerCAmelCase				    =			model(__a	)
										self.parent.assertEqual(result.last_hidden_state.shape    ,   (self.batch_size, 2, self.d_model)	)

										__lowerCAmelCase				    =			False
										__lowerCAmelCase				    =			TFFunnelBaseModel(config=__a	)
										__lowerCAmelCase				    =			model(__a	)
										self.parent.assertEqual(result.last_hidden_state.shape    ,   (self.batch_size, 3, self.d_model)	)

										__lowerCAmelCase				    =			False
										__lowerCAmelCase				    =			TFFunnelBaseModel(config=__a	)
										__lowerCAmelCase				    =			model(__a	)
										self.parent.assertEqual(result.last_hidden_state.shape    ,   (self.batch_size, 2, self.d_model)	)

							def 			snake_case				(     self    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   ):
										__lowerCAmelCase				    =			TFFunnelForPreTraining(config=__a	)
										__lowerCAmelCase				    =			{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
										__lowerCAmelCase				    =			model(__a	)
										self.parent.assertEqual(result.logits.shape    ,   (self.batch_size, self.seq_length)	)

							def 			snake_case				(     self    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   ):
										__lowerCAmelCase				    =			TFFunnelForMaskedLM(config=__a	)
										__lowerCAmelCase				    =			{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
										__lowerCAmelCase				    =			model(__a	)
										self.parent.assertEqual(result.logits.shape    ,   (self.batch_size, self.seq_length, self.vocab_size)	)

							def 			snake_case				(     self    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   ):
										__lowerCAmelCase				    =			self.num_labels
										__lowerCAmelCase				    =			TFFunnelForSequenceClassification(config=__a	)
										__lowerCAmelCase				    =			{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
										__lowerCAmelCase				    =			model(__a	)
										self.parent.assertEqual(result.logits.shape    ,   (self.batch_size, self.num_labels)	)

							def 			snake_case				(     self    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   ):
										__lowerCAmelCase				    =			self.num_choices
										__lowerCAmelCase				    =			TFFunnelForMultipleChoice(config=__a	)
										__lowerCAmelCase				    =			tf.tile(tf.expand_dims(__a    ,   1	)    ,   (1, self.num_choices, 1)	)
										__lowerCAmelCase				    =			tf.tile(tf.expand_dims(__a    ,   1	)    ,   (1, self.num_choices, 1)	)
										__lowerCAmelCase				    =			tf.tile(tf.expand_dims(__a    ,   1	)    ,   (1, self.num_choices, 1)	)
										__lowerCAmelCase				    =			{
										    "input_ids": multiple_choice_inputs_ids,
										    "attention_mask": multiple_choice_input_mask,
										    "token_type_ids": multiple_choice_token_type_ids,
										}
										__lowerCAmelCase				    =			model(__a	)
										self.parent.assertEqual(result.logits.shape    ,   (self.batch_size, self.num_choices)	)

							def 			snake_case				(     self    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   ):
										__lowerCAmelCase				    =			self.num_labels
										__lowerCAmelCase				    =			TFFunnelForTokenClassification(config=__a	)
										__lowerCAmelCase				    =			{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
										__lowerCAmelCase				    =			model(__a	)
										self.parent.assertEqual(result.logits.shape    ,   (self.batch_size, self.seq_length, self.num_labels)	)

							def 			snake_case				(     self    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   __a    ,   ):
										__lowerCAmelCase				    =			TFFunnelForQuestionAnswering(config=__a	)
										__lowerCAmelCase				    =			{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
										__lowerCAmelCase				    =			model(__a	)
										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	):
										__lowerCAmelCase				    =			self.prepare_config_and_inputs()
										(
										    (
										    __lowerCAmelCase
										)    ,	(
										    __lowerCAmelCase
										)    ,	(
										    __lowerCAmelCase
										)    ,	(
										    __lowerCAmelCase
										)    ,	(
										    __lowerCAmelCase
										)    ,	(
										    __lowerCAmelCase
										)    ,	(
										    __lowerCAmelCase
										)    ,	
										)				    =			config_and_inputs
										__lowerCAmelCase				    =			{"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
										return config, inputs_dict
@require_tf
class   _UpperCamelCase  (   lowerCAmelCase__       ,lowerCAmelCase__       ,unittest.TestCase		):
							'''simple docstring'''







							__UpperCAmelCase						:    str				      =(
							    (
							        TFFunnelModel,
							        TFFunnelForMaskedLM,
							        TFFunnelForPreTraining,
							        TFFunnelForQuestionAnswering,
							        TFFunnelForTokenClassification,
							    )
							    if is_tf_available()
							    else ()
							)
							__UpperCAmelCase						:    Tuple				      =(
							    {
							        """feature-extraction""": (TFFunnelBaseModel, TFFunnelModel),
							        """fill-mask""": TFFunnelForMaskedLM,
							        """question-answering""": TFFunnelForQuestionAnswering,
							        """text-classification""": TFFunnelForSequenceClassification,
							        """token-classification""": TFFunnelForTokenClassification,
							        """zero-shot""": TFFunnelForSequenceClassification,
							    }
							    if is_tf_available()
							    else {}
							)
							__UpperCAmelCase						:    Optional[Any]				      =False
							__UpperCAmelCase						:    List[str]				      =False

							def 			snake_case				(     self	):
										__lowerCAmelCase				    =			TFFunnelModelTester(self	)
										__lowerCAmelCase				    =			ConfigTester(self    ,   config_class=__a	)

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

							def 			snake_case				(     self	):
										__lowerCAmelCase				    =			self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_model(*__a	)

							def 			snake_case				(     self	):
										__lowerCAmelCase				    =			self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_pretraining(*__a	)

							def 			snake_case				(     self	):
										__lowerCAmelCase				    =			self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_masked_lm(*__a	)

							def 			snake_case				(     self	):
										__lowerCAmelCase				    =			self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_token_classification(*__a	)



							def 			snake_case				(     self	):
										__lowerCAmelCase				    =			self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_question_answering(*__a	)
@require_tf
class   _UpperCamelCase  (   lowerCAmelCase__       ,unittest.TestCase		):
							'''simple docstring'''







							__UpperCAmelCase						:    List[str]				      =(
							    (TFFunnelBaseModel, TFFunnelForMultipleChoice, TFFunnelForSequenceClassification) if is_tf_available() else ()
							)
							__UpperCAmelCase						:    Tuple				      =False
							__UpperCAmelCase						:    Any				      =False

							def 			snake_case				(     self	):
										__lowerCAmelCase				    =			TFFunnelModelTester(self    ,   base=__a	)
										__lowerCAmelCase				    =			ConfigTester(self    ,   config_class=__a	)

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

							def 			snake_case				(     self	):
										__lowerCAmelCase				    =			self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_base_model(*__a	)

							def 			snake_case				(     self	):
										__lowerCAmelCase				    =			self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_sequence_classification(*__a	)



							def 			snake_case				(     self	):
										__lowerCAmelCase				    =			self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_multiple_choice(*__a	)








"""simple docstring"""


def _lowerCamelCase	(		_UpperCamelCase = 6008_5147_5143      ):

			'''simple docstring'''




			try:
						__lowerCAmelCase				    =			int(_UpperCamelCase      )
			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."      )
			__lowerCAmelCase				    =			2
			__lowerCAmelCase				    =			0
			if n == 2:
						return 2
			while n > 2:
						while n % i != 0:
									i += 1
						__lowerCAmelCase				    =			i
						while n % i == 0:
									__lowerCAmelCase				    =			n // i
						i += 1
			return int(_UpperCamelCase      )


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




