


"""simple docstring"""


import unittest

from transformers import YosoConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
		import torch

		from transformers import (
		    YosoForMaskedLM,
		    YosoForMultipleChoice,
		    YosoForQuestionAnswering,
		    YosoForSequenceClassification,
		    YosoForTokenClassification,
		    YosoModel,
		)
		from transformers.models.yoso.modeling_yoso import YOSO_PRETRAINED_MODEL_ARCHIVE_LIST
class snake_case					:







		def __init__(    self					:				Optional[Any]			,      a__					:				Union[str, Any]			,      a__					:				Optional[Any]=13			,      a__					:				Any=7			,      a__					:				str=True			,      a__					:				Tuple=True			,      a__					:				Union[str, Any]=True			,      a__					:				List[str]=True			,      a__					:				List[Any]=99			,      a__					:				int=32			,      a__					:				List[str]=5			,      a__					:				Optional[Any]=4			,      a__					:				str=37			,      a__					:				Tuple="gelu"			,      a__					:				Optional[Any]=0.1			,      a__					:				Any=0.1			,      a__					:				int=5_12			,      a__					:				Tuple=16			,      a__					:				Any=2			,      a__					:				List[Any]=0.0_2			,      a__					:				List[Any]=3			,      a__					:				List[str]=4			,      a__					:				Tuple=None			,      )				->  int:





						'''simple docstring'''







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







		def        a_       (    self					:				Optional[int]						)				->  Any:





						'''simple docstring'''







						_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         =	self.get_config()

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







		def        a_       (    self					:				str						)				->  Tuple:





						'''simple docstring'''







						return YosoConfig(
						    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			,      is_decoder=a__			,      initializer_range=self.initializer_range			,      )







		def        a_       (    self					:				List[str]						)				->  int:





						'''simple docstring'''







						_A         =	self.get_config()
						_A         =	3_00
						return config







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





						'''simple docstring'''







						(
						    (
						    _A
						)     ,						(
						    _A
						)     ,						(
						    _A
						)     ,						(
						    _A
						)     ,						(
						    _A
						)     ,						(
						    _A
						)     ,						(
						    _A
						)     ,						
						)         =	self.prepare_config_and_inputs()

						_A         =	True
						_A         =	floats_tensor([self.batch_size, self.seq_length, self.hidden_size]						)
						_A         =	ids_tensor([self.batch_size, self.seq_length]			,      vocab_size=2						)

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







		def        a_       (    self					:				Optional[int]			,      a__					:				Any			,      a__					:				Optional[Any]			,      a__					:				Optional[int]			,      a__					:				Any			,      a__					:				Tuple			,      a__					:				int			,      a__					:				Any						)				->  Dict:





						'''simple docstring'''







						_A         =	YosoModel(config=a__						)
						model.to(a__						)
						model.eval()
						_A         =	model(a__			,      attention_mask=a__			,      token_type_ids=a__						)
						_A         =	model(a__			,      token_type_ids=a__						)
						_A         =	model(a__						)
						self.parent.assertEqual(result.last_hidden_state.shape			,      (self.batch_size, self.seq_length, self.hidden_size)						)







		def        a_       (    self					:				Any			,      a__					:				int			,      a__					:				Any			,      a__					:				List[Any]			,      a__					:				Union[str, Any]			,      a__					:				Optional[int]			,      a__					:				Union[str, Any]			,      a__					:				Union[str, Any]			,      a__					:				int			,      a__					:				Optional[Any]			,      )				->  Optional[Any]:





						'''simple docstring'''







						_A         =	True
						_A         =	YosoModel(a__						)
						model.to(a__						)
						model.eval()
						_A         =	model(
						    a__			,      attention_mask=a__			,      token_type_ids=a__			,      encoder_hidden_states=a__			,      encoder_attention_mask=a__			,      )
						_A         =	model(
						    a__			,      attention_mask=a__			,      token_type_ids=a__			,      encoder_hidden_states=a__			,      )
						_A         =	model(a__			,      attention_mask=a__			,      token_type_ids=a__						)
						self.parent.assertEqual(result.last_hidden_state.shape			,      (self.batch_size, self.seq_length, self.hidden_size)						)







		def        a_       (    self					:				Dict			,      a__					:				int			,      a__					:				Tuple			,      a__					:				Tuple			,      a__					:				Tuple			,      a__					:				List[str]			,      a__					:				List[str]			,      a__					:				str						)				->  Optional[int]:





						'''simple docstring'''







						_A         =	YosoForMaskedLM(config=a__						)
						model.to(a__						)
						model.eval()
						_A         =	model(a__			,      attention_mask=a__			,      token_type_ids=a__			,      labels=a__						)
						self.parent.assertEqual(result.logits.shape			,      (self.batch_size, self.seq_length, self.vocab_size)						)







		def        a_       (    self					:				Optional[int]			,      a__					:				List[str]			,      a__					:				List[Any]			,      a__					:				Tuple			,      a__					:				int			,      a__					:				List[str]			,      a__					:				Any			,      a__					:				Dict						)				->  Optional[Any]:





						'''simple docstring'''







						_A         =	YosoForQuestionAnswering(config=a__						)
						model.to(a__						)
						model.eval()
						_A         =	model(
						    a__			,      attention_mask=a__			,      token_type_ids=a__			,      start_positions=a__			,      end_positions=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        a_       (    self					:				List[str]			,      a__					:				Dict			,      a__					:				List[str]			,      a__					:				str			,      a__					:				Optional[Any]			,      a__					:				List[str]			,      a__					:				Optional[Any]			,      a__					:				Optional[int]						)				->  Optional[Any]:





						'''simple docstring'''







						_A         =	self.num_labels
						_A         =	YosoForSequenceClassification(a__						)
						model.to(a__						)
						model.eval()
						_A         =	model(a__			,      attention_mask=a__			,      token_type_ids=a__			,      labels=a__						)
						self.parent.assertEqual(result.logits.shape			,      (self.batch_size, self.num_labels)						)







		def        a_       (    self					:				Any			,      a__					:				List[str]			,      a__					:				Any			,      a__					:				List[str]			,      a__					:				Any			,      a__					:				Dict			,      a__					:				Dict			,      a__					:				Tuple						)				->  Any:





						'''simple docstring'''







						_A         =	self.num_labels
						_A         =	YosoForTokenClassification(config=a__						)
						model.to(a__						)
						model.eval()
						_A         =	model(a__			,      attention_mask=a__			,      token_type_ids=a__			,      labels=a__						)
						self.parent.assertEqual(result.logits.shape			,      (self.batch_size, self.seq_length, self.num_labels)						)







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





						'''simple docstring'''







						_A         =	self.num_choices
						_A         =	YosoForMultipleChoice(config=a__						)
						model.to(a__						)
						model.eval()
						_A         =	input_ids.unsqueeze(1						).expand(-1			,      self.num_choices			,      -1						).contiguous()
						_A         =	token_type_ids.unsqueeze(1						).expand(-1			,      self.num_choices			,      -1						).contiguous()
						_A         =	input_mask.unsqueeze(1						).expand(-1			,      self.num_choices			,      -1						).contiguous()
						_A         =	model(
						    a__			,      attention_mask=a__			,      token_type_ids=a__			,      labels=a__			,      )
						self.parent.assertEqual(result.logits.shape			,      (self.batch_size, self.num_choices)						)







		def        a_       (    self					:				Tuple						)				->  List[str]:





						'''simple docstring'''







						_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_torch
class snake_case					(     _UpperCamelCase   , _UpperCamelCase   , unittest.TestCase):
		__UpperCamelCase							=	(
		    (
		        YosoModel,
		        YosoForMaskedLM,
		        YosoForMultipleChoice,
		        YosoForQuestionAnswering,
		        YosoForSequenceClassification,
		        YosoForTokenClassification,
		    )
		    if is_torch_available()
		    else ()
		)
		__UpperCamelCase							=	False
		__UpperCamelCase							=	False
		__UpperCamelCase							=	False

		__UpperCamelCase							=	()
		__UpperCamelCase							=	(
		    {
		        'feature-extraction': YosoModel,
		        'fill-mask': YosoForMaskedLM,
		        'question-answering': YosoForQuestionAnswering,
		        'text-classification': YosoForSequenceClassification,
		        'token-classification': YosoForTokenClassification,
		        'zero-shot': YosoForSequenceClassification,
		    }
		    if is_torch_available()
		    else {}
		)







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





						'''simple docstring'''







						_A         =	YosoModelTester(self						)
						_A         =	ConfigTester(self			,      config_class=a__			,      hidden_size=37						)







		def        a_       (    self					:				Dict						)				->  Any:





						'''simple docstring'''







						self.config_tester.run_common_tests()







		def        a_       (    self					:				Optional[int]						)				->  Any:





						'''simple docstring'''







						_A         =	self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_model(*a__						)







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





						'''simple docstring'''







						_A         =	self.model_tester.prepare_config_and_inputs()
						for type in ["absolute", "relative_key", "relative_key_query"]:
										_A         =	type
										self.model_tester.create_and_check_model(*a__						)







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





						'''simple docstring'''







						_A         =	self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_masked_lm(*a__						)







		def        a_       (    self					:				Tuple						)				->  List[str]:





						'''simple docstring'''







						_A         =	self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_multiple_choice(*a__						)







		def        a_       (    self					:				int						)				->  Tuple:





						'''simple docstring'''







						_A         =	self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_question_answering(*a__						)







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





						'''simple docstring'''







						_A         =	self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_sequence_classification(*a__						)







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





						'''simple docstring'''







						_A         =	self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_token_classification(*a__						)







		@slow
		def        a_       (    self					:				Dict						)				->  Optional[int]:





						'''simple docstring'''







						for model_name in YOSO_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
										_A         =	YosoModel.from_pretrained(a__						)
										self.assertIsNotNone(a__						)







		def        a_       (    self					:				List[Any]						)				->  Tuple:





						'''simple docstring'''







						return





@require_torch
class snake_case					(     unittest.TestCase):







		@slow
		def        a_       (    self					:				Tuple						)				->  Optional[Any]:





						'''simple docstring'''







						_A         =	YosoModel.from_pretrained("uw-madison/yoso-4096"						)
						_A         =	torch.tensor([[0, 1, 2, 3, 4, 5]]						)

						with torch.no_grad():
										_A         =	model(a__						)[0]

						_A         =	torch.Size((1, 6, 7_68)						)
						self.assertEqual(output.shape			,      a__						)

						_A         =	torch.tensor(
						    [[[-0.0_6_1_1, 0.1_2_4_2, 0.0_8_4_0], [0.0_2_8_0, -0.0_0_4_8, 0.1_1_2_5], [0.0_1_0_6, 0.0_2_2_6, 0.0_7_5_1]]]						)

						self.assertTrue(torch.allclose(output[:, :3, :3]			,      a__			,      atol=1E-4						)						)







		@slow
		def        a_       (    self					:				List[Any]						)				->  Union[str, Any]:





						'''simple docstring'''







						_A         =	YosoForMaskedLM.from_pretrained("uw-madison/yoso-4096"						)
						_A         =	torch.tensor([[0, 1, 2, 3, 4, 5]]						)

						with torch.no_grad():
										_A         =	model(a__						)[0]

						_A         =	5_02_65

						_A         =	torch.Size((1, 6, vocab_size)						)
						self.assertEqual(output.shape			,      a__						)

						_A         =	torch.tensor(
						    [[[-2.1_3_1_3, -3.7_2_8_5, -2.2_4_0_7], [-2.7_0_4_7, -3.3_3_1_4, -2.6_4_0_8], [0.0_6_2_9, -2.5_1_6_6, -0.3_3_5_6]]]						)

						self.assertTrue(torch.allclose(output[:, :3, :3]			,      a__			,      atol=1E-4						)						)







		@slow
		def        a_       (    self					:				Union[str, Any]						)				->  Optional[int]:





						'''simple docstring'''







						_A         =	YosoForMaskedLM.from_pretrained("uw-madison/yoso-4096"						)
						_A         =	torch.arange(40_96						).unsqueeze(0						)

						with torch.no_grad():
										_A         =	model(a__						)[0]

						_A         =	5_02_65

						_A         =	torch.Size((1, 40_96, vocab_size)						)
						self.assertEqual(output.shape			,      a__						)

						_A         =	torch.tensor(
						    [[[-2.3_9_1_4, -4.3_7_4_2, -5.0_9_5_6], [-4.0_9_8_8, -4.2_3_8_4, -7.0_4_0_6], [-3.1_4_2_7, -3.7_1_9_2, -6.6_8_0_0]]]						)

						self.assertTrue(torch.allclose(output[:, :3, :3]			,      a__			,      atol=1E-4						)						)






"""simple docstring"""





import math




def 		lowerCAmelCase_	(  lowercase_   :							int		):

 '''simple docstring'''






 if 1 < number < 4:
  # 2 and 3 are primes
  return True
 elif number < 2 or number % 2 == 0 or number % 3 == 0:
  # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
  return False

 # All primes number are in format of 6k +/- 1
 for i in range(5 ,      int(math.sqrt(lowercase_		) + 1		) ,      6		):
  if number % i == 0 or number % (i + 2) == 0:
   return False
 return True




def 		lowerCAmelCase_	(  lowercase_   :							int = 6008_5147_5143		):

 '''simple docstring'''






 try:
  __SCREAMING_SNAKE_CASE :			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.'''		)
 __SCREAMING_SNAKE_CASE :			List[str]												=       0
 if is_prime(lowercase_		):
  return n
 while n % 2 == 0:
  n //= 2
 if is_prime(lowercase_		):
  return n
 for i in range(3 ,      int(math.sqrt(lowercase_		)		) + 1 ,      2		):
  if n % i == 0:
   if is_prime(n // i		):
    __SCREAMING_SNAKE_CASE :			Optional[int]												=       n // i
    break
   elif is_prime(lowercase_		):
    __SCREAMING_SNAKE_CASE :			Any												=       i
 return max_number


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

