






from math import sqrt




def      __A					(     _lowercase     :   Optional[int] ):

					'''simple docstring'''







					assert isinstance(_lowercase					,			_lowercase ) and (
					    number >= 0
					), "'number' must been an int and positive"

					_A								= True

					# 0 and 1 are none primes.
					if number <= 1:
										_A								= False

					for divisor in range(2					,			int(round(sqrt(_lowercase ) ) ) + 1 ):
										# if 'number' divisible by 'divisor' then sets 'status'
										# of false and break up the loop.
										if number % divisor == 0:
															_A								= False
															break

    # precondition
					assert isinstance(_lowercase					,			_lowercase ), "'status' must been from type bool"

					return status




def      __A					(     _lowercase     :   int ):

					'''simple docstring'''







					assert isinstance(_lowercase					,			_lowercase ) and (n > 2), "'N' must been an int and > 2"

					# beginList: contains all natural numbers from 2 up to N
					_A								= list(range(2					,			n + 1 ) )

					_A								= []  # this list will be returns.

					# actual sieve of erathostenes
					for i in range(len(_lowercase ) ):
										for j in range(i + 1					,			len(_lowercase ) ):
															if (begin_list[i] != 0) and (begin_list[j] % begin_list[i] == 0):
																				_A								= 0

    # filters actual prime numbers.
					_A								= [x for x in begin_list if x != 0]

					# precondition
					assert isinstance(_lowercase					,			_lowercase ), "'ans' must been from type list"

					return ans




def      __A					(     _lowercase     :   List[str] ):

					'''simple docstring'''







					assert isinstance(_lowercase					,			_lowercase ) and (n > 2), "'N' must been an int and > 2"

					_A								= []

					# iterates over all numbers between 2 up to N+1
					# if a number is prime then appends to list 'ans'
					for number in range(2					,			n + 1 ):
										if is_prime(_lowercase ):
															ans.append(_lowercase )

    # precondition
					assert isinstance(_lowercase					,			_lowercase ), "'ans' must been from type list"

					return ans




def      __A					(     _lowercase     :   Union[str, Any] ):

					'''simple docstring'''







					assert isinstance(_lowercase					,			_lowercase ) and number >= 0, "'number' must been an int and >= 0"

					_A								= []  # this list will be returns of the function.

					# potential prime number factors.

					_A								= 2

					_A								= number

					if number == 0 or number == 1:
										ans.append(_lowercase )

					# if 'number' not prime then builds the prime factorization of 'number'
					elif not is_prime(_lowercase ):
										while quotient != 1:
															if is_prime(_lowercase ) and (quotient % factor == 0):
																				ans.append(_lowercase )
																				quotient /= factor
															else:
																				factor += 1

					else:
										ans.append(_lowercase )

					# precondition
					assert isinstance(_lowercase					,			_lowercase ), "'ans' must been from type list"

					return ans




def      __A					(     _lowercase     :   Optional[Any] ):

					'''simple docstring'''







					assert isinstance(_lowercase					,			_lowercase ) and (
					    number >= 0
					), "'number' bust been an int and >= 0"

					_A								= 0

					# prime factorization of 'number'
					_A								= prime_factorization(_lowercase )

					_A								= max(_lowercase )

					# precondition
					assert isinstance(_lowercase					,			_lowercase ), "'ans' must been from type int"

					return ans




def      __A					(     _lowercase     :   str ):

					'''simple docstring'''







					assert isinstance(_lowercase					,			_lowercase ) and (
					    number >= 0
					), "'number' bust been an int and >= 0"

					_A								= 0

					# prime factorization of 'number'
					_A								= prime_factorization(_lowercase )

					_A								= min(_lowercase )

					# precondition
					assert isinstance(_lowercase					,			_lowercase ), "'ans' must been from type int"

					return ans




def      __A					(     _lowercase     :   Union[str, Any] ):

					'''simple docstring'''







					assert isinstance(_lowercase					,			_lowercase ), "'number' must been an int"
					assert isinstance(number % 2 == 0					,			_lowercase ), "compare bust been from type bool"

					return number % 2 == 0




def      __A					(     _lowercase     :   Dict ):

					'''simple docstring'''







					assert isinstance(_lowercase					,			_lowercase ), "'number' must been an int"
					assert isinstance(number % 2 != 0					,			_lowercase ), "compare bust been from type bool"

					return number % 2 != 0




def      __A					(     _lowercase     :   Tuple ):

					'''simple docstring'''







					assert (
					    isinstance(_lowercase					,			_lowercase ) and (number > 2) and is_even(_lowercase )
					), "'number' must been an int, even and > 2"

					_A								= []  # this list will returned

					# creates a list of prime numbers between 2 up to 'number'
					_A								= get_prime_numbers(_lowercase )
					_A								= len(_lowercase )

					# run variable for while-loops.
					_A								= 0
					_A								= None

					# exit variable. for break up the loops
					_A								= True

					while i < len_pn and loop:
										_A								= i + 1

										while j < len_pn and loop:
															if prime_numbers[i] + prime_numbers[j] == number:
																				_A								= False
																				ans.append(prime_numbers[i] )
																				ans.append(prime_numbers[j] )

															j += 1

										i += 1

					# precondition
					assert (
					    isinstance(_lowercase					,			_lowercase )
					    and (len(_lowercase ) == 2)
					    and (ans[0] + ans[1] == number)
					    and is_prime(ans[0] )
					    and is_prime(ans[1] )
					), "'ans' must contains two primes. And sum of elements must been eq 'number'"

					return ans




def      __A					(     _lowercase     :   Dict					,			_lowercase     :   Dict ):

					'''simple docstring'''







					assert (
					    isinstance(_lowercase					,			_lowercase )
					    and isinstance(_lowercase					,			_lowercase )
					    and (numbera >= 0)
					    and (numbera >= 0)
					), "'number1' and 'number2' must been positive integer."

					_A								= 0

					while numbera != 0:
										_A								= numbera % numbera
										_A								= numbera
										_A								= rest

					# precondition
					assert isinstance(_lowercase					,			_lowercase ) and (
					    numbera >= 0
					), "'number' must been from type int and positive"

					return numbera




def      __A					(     _lowercase     :   Tuple					,			_lowercase     :   Dict ):

					'''simple docstring'''







					assert (
					    isinstance(_lowercase					,			_lowercase )
					    and isinstance(_lowercase					,			_lowercase )
					    and (numbera >= 1)
					    and (numbera >= 1)
					), "'number1' and 'number2' must been positive integer."

					_A								= 1  # actual answer that will be return.

					# for kgV (x,1)
					if numbera > 1 and numbera > 1:
										# builds the prime factorization of 'number1' and 'number2'
										_A								= prime_factorization(_lowercase )
										_A								= prime_factorization(_lowercase )

					elif numbera == 1 or numbera == 1:
										_A								= []
										_A								= []
										_A								= max(_lowercase					,			_lowercase )

					_A								= 0
					_A								= 0

					_A								= []  # captured numbers int both 'primeFac1' and 'primeFac2'

					# iterates through primeFac1
					for n in prime_fac_a:
										if n not in done:
															if n in prime_fac_a:
																				_A								= prime_fac_a.count(_lowercase )
																				_A								= prime_fac_a.count(_lowercase )

																				for _ in range(max(_lowercase					,			_lowercase ) ):
																									ans *= n

															else:
																				_A								= prime_fac_a.count(_lowercase )

																				for _ in range(_lowercase ):
																									ans *= n

															done.append(_lowercase )

    # iterates through primeFac2
					for n in prime_fac_a:
										if n not in done:
															_A								= prime_fac_a.count(_lowercase )

															for _ in range(_lowercase ):
																				ans *= n

															done.append(_lowercase )

    # precondition
					assert isinstance(_lowercase					,			_lowercase ) and (
					    ans >= 0
					), "'ans' must been from type int and positive"

					return ans




def      __A					(     _lowercase     :   Optional[int] ):

					'''simple docstring'''







					assert isinstance(_lowercase					,			_lowercase ) and (n >= 0), "'number' must been a positive int"

					_A								= 0
					_A								= 2  # this variable holds the answer

					while index < n:
										index += 1

										ans += 1  # counts to the next number

										# if ans not prime then
										# runs to the next prime number.
										while not is_prime(_lowercase ):
															ans += 1

    # precondition
					assert isinstance(_lowercase					,			_lowercase ) and is_prime(
					    _lowercase ), "'ans' must been a prime number and from type int"

					return ans




def      __A					(     _lowercase     :   Union[str, Any]					,			_lowercase     :   Union[str, Any] ):

					'''simple docstring'''







					assert (
					    is_prime(_lowercase ) and is_prime(_lowercase ) and (p_number_a < p_number_a)
					), "The arguments must been prime numbers and 'pNumber1' < 'pNumber2'"

					_A								= p_number_a + 1  # jump to the next number

					_A								= []  # this list will be returns.

					# if number is not prime then
					# fetch the next prime number.
					while not is_prime(_lowercase ):
										number += 1

					while number < p_number_a:
										ans.append(_lowercase )

										number += 1

										# fetch the next prime number.
										while not is_prime(_lowercase ):
															number += 1

    # precondition
					assert (
					    isinstance(_lowercase					,			_lowercase )
					    and ans[0] != p_number_a
					    and ans[len(_lowercase ) - 1] != p_number_a
					), "'ans' must been a list without the arguments"

					# 'ans' contains not 'pNumber1' and 'pNumber2' !
					return ans




def      __A					(     _lowercase     :   int ):

					'''simple docstring'''







					assert isinstance(_lowercase					,			_lowercase ) and (n >= 1), "'n' must been int and >= 1"

					_A								= []  # will be returned.

					for divisor in range(1					,			n + 1 ):
										if n % divisor == 0:
															ans.append(_lowercase )

    # precondition
					assert ans[0] == 1 and ans[len(_lowercase ) - 1] == n, "Error in function getDivisiors(...)"

					return ans




def      __A					(     _lowercase     :   List[Any] ):

					'''simple docstring'''







					assert isinstance(_lowercase					,			_lowercase ) and (
					    number > 1
					), "'number' must been an int and >= 1"

					_A								= get_divisors(_lowercase )

					# precondition
					assert (
					    isinstance(_lowercase					,			_lowercase )
					    and (divisors[0] == 1)
					    and (divisors[len(_lowercase ) - 1] == number)
					), "Error in help-function getDivisiors(...)"

					# summed all divisors up to 'number' (exclusive), hence [:-1]
					return sum(divisors[:-1] ) == number




def      __A					(     _lowercase     :   Any					,			_lowercase     :   Union[str, Any] ):

					'''simple docstring'''







					assert (
					    isinstance(_lowercase					,			_lowercase )
					    and isinstance(_lowercase					,			_lowercase )
					    and (denominator != 0)
					), "The arguments must been from type int and 'denominator' != 0"

					# build the greatest common divisor of numerator and denominator.
					_A								= gcd(abs(_lowercase )					,			abs(_lowercase ) )

					# precondition
					assert (
					    isinstance(_lowercase					,			_lowercase )
					    and (numerator % gcd_of_fraction == 0)
					    and (denominator % gcd_of_fraction == 0)
					), "Error in function gcd(...,...)"

					return (numerator // gcd_of_fraction, denominator // gcd_of_fraction)




def      __A					(     _lowercase     :   Optional[Any] ):

					'''simple docstring'''







					assert isinstance(_lowercase					,			_lowercase ) and (n >= 0), "'n' must been a int and >= 0"

					_A								= 1  # this will be return.

					for factor in range(1					,			n + 1 ):
										ans *= factor

					return ans




def      __A					(     _lowercase     :   Tuple ):

					'''simple docstring'''







					assert isinstance(_lowercase					,			_lowercase ) and (n >= 0), "'n' must been an int and >= 0"

					_A								= 0
					_A								= 1
					_A								= 1  # this will be return

					for _ in range(n - 1 ):
										_A								= ans
										ans += fiba
										_A								= tmp

					return ans











import gc
import unittest

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

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
				import torch

				from transformers import (
				    CTRL_PRETRAINED_MODEL_ARCHIVE_LIST,
				    CTRLForSequenceClassification,
				    CTRLLMHeadModel,
				    CTRLModel,
				)





class 						SCREAMING_SNAKE_CASE				:





							"""simple docstring"""

							def __init__(  self:   Tuple		,     __A:   Any		,     __A:   List[Any]=14		,     __A:   Dict=7		,     __A:   List[str]=True		,     __A:   Tuple=True		,     __A:   Union[str, Any]=True		,     __A:   List[Any]=True		,     __A:   Optional[int]=True		,     __A:   Tuple=99		,     __A:   Optional[Any]=32		,     __A:   List[str]=5		,     __A:   Dict=4		,     __A:   str=37		,     __A:   Dict="gelu"		,     __A:   List[str]=0.1		,     __A:   str=0.1		,     __A:   Any=5_12		,     __A:   Union[str, Any]=16		,     __A:   List[Any]=2		,     __A:   Tuple=0.02		,     __A:   Tuple=3		,     __A:   Union[str, Any]=4		,     __A:   Any=None		,     )    ->				Optional[Any]:
												_A								= parent
												_A								= batch_size
												_A								= seq_length
												_A								= is_training
												_A								= use_token_type_ids
												_A								= use_input_mask
												_A								= use_labels
												_A								= use_mc_token_ids
												_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
												_A								= self.vocab_size - 1

							def       __A (  self:   Optional[int]   )    ->				Union[str, Any]:
												_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
												if self.use_mc_token_ids:
																	_A								= ids_tensor([self.batch_size, self.num_choices]		,     self.seq_length   )

												_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()

												_A								= ids_tensor([self.num_hidden_layers, self.num_attention_heads]		,     2   )

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

							def       __A (  self:   Optional[int]   )    ->				List[Any]:
												return CTRLConfig(
												    vocab_size=self.vocab_size		,     n_embd=self.hidden_size		,     n_layer=self.num_hidden_layers		,     n_head=self.num_attention_heads		,     n_positions=self.max_position_embeddings		,     pad_token_id=self.pad_token_id		,     )

							def       __A (  self:   Union[str, Any]		,     __A:   Union[str, Any]		,     __A:   Dict		,     __A:   Optional[int]		,     __A:   List[str]		,     __A:   List[str]		,     *__A:   Optional[int]   )    ->				Optional[Any]:
												_A								= CTRLModel(config=__A   )
												model.to(__A   )
												model.eval()

												model(__A		,     token_type_ids=__A		,     head_mask=__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)   )
												self.parent.assertEqual(len(result.past_key_values   )		,     config.n_layer   )

							def       __A (  self:   Optional[Any]		,     __A:   List[str]		,     __A:   Dict		,     __A:   List[Any]		,     __A:   List[Any]		,     __A:   Any		,     *__A:   Any   )    ->				str:
												_A								= CTRLLMHeadModel(__A   )
												model.to(__A   )
												model.eval()

												_A								= model(__A		,     token_type_ids=__A		,     labels=__A   )
												self.parent.assertEqual(result.loss.shape		,     ()   )
												self.parent.assertEqual(result.logits.shape		,     (self.batch_size, self.seq_length, self.vocab_size)   )

							def       __A (  self:   Optional[int]   )    ->				Dict:
												_A								= self.prepare_config_and_inputs()

												(
												    (
												    _A
												)							,(
												    _A
												)							,(
												    _A
												)							,(
												    _A
												)							,(
												    _A
												)							,(
												    _A
												)							,(
												    _A
												)							,(
												    _A
												)							,(
												    _A
												)							,
												)								= config_and_inputs

												_A								= {'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''head_mask''': head_mask}

												return config, inputs_dict



							def       __A (  self:   List[str]		,     __A:   Dict		,     __A:   Dict		,     __A:   Tuple		,     __A:   List[Any]		,     *__A:   Optional[int]   )    ->				Any:
												_A								= self.num_labels
												_A								= CTRLForSequenceClassification(__A   )
												model.to(__A   )
												model.eval()
												_A								= ids_tensor([self.batch_size]		,     self.type_sequence_label_size   )
												_A								= model(__A		,     token_type_ids=__A		,     labels=__A   )
												self.parent.assertEqual(result.logits.shape		,     (self.batch_size, self.num_labels)   )





@require_torch
class 						SCREAMING_SNAKE_CASE				( snake_case  ,	snake_case  ,	snake_case  ,	unittest.TestCase					):





							"""simple docstring"""

							A_						  =					(CTRLModel, CTRLLMHeadModel, CTRLForSequenceClassification) if is_torch_available() else ()
							A_						  =					(CTRLLMHeadModel,) if is_torch_available() else ()
							A_						  =					(
							    {
							        "feature-extraction": CTRLModel,
							        "text-classification": CTRLForSequenceClassification,
							        "text-generation": CTRLLMHeadModel,
							        "zero-shot": CTRLForSequenceClassification,
							    }
							    if is_torch_available()
							    else {}
							)
							A_						  =					True
							A_						  =					False
							A_						  =					False

							def       __A (  self:   Any		,     __A:   List[Any]		,     __A:   int		,     __A:   Optional[Any]		,     __A:   Optional[int]		,     __A:   List[Any]   )    ->				List[str]:
												if pipeline_test_casse_name == "ZeroShotClassificationPipelineTests":
																	# Get `tokenizer does not have a padding token` error for both fast/slow tokenizers.
																	# `CTRLConfig` was never used in pipeline tests, either because of a missing checkpoint or because a tiny
																	# config could not be created.
																	return True

												return False

							def       __A (  self:   Any   )    ->				Union[str, Any]:
												_A								= CTRLModelTester(self   )
												_A								= ConfigTester(self		,     config_class=__A		,     n_embd=37   )

							def       __A (  self:   Optional[int]   )    ->				List[Any]:
												super().tearDown()
												# clean-up as much as possible GPU memory occupied by PyTorch
												gc.collect()
												torch.cuda.empty_cache()

							def       __A (  self:   Dict   )    ->				Any:
												self.config_tester.run_common_tests()

							def       __A (  self:   str   )    ->				Optional[Any]:
												_A								= self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_ctrl_model(*__A   )

							def       __A (  self:   List[str]   )    ->				Any:
												_A								= self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_lm_head_model(*__A   )

							@unittest.skip('''Will be fixed soon by reducing the size of the model used for common tests.'''   )
							def       __A (  self:   Optional[Any]   )    ->				int:
												pass

							@slow
							def       __A (  self:   Tuple   )    ->				Dict:
												for model_name in CTRL_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																	_A								= CTRLModel.from_pretrained(__A   )
																	self.assertIsNotNone(__A   )



							@unittest.skip('''The model doesn\'t support left padding'''   )  # and it's not used enough to be worth fixing :)
							def       __A (  self:   Any   )    ->				Union[str, Any]:
												pass





@require_torch
class 						SCREAMING_SNAKE_CASE				( unittest.TestCase					):





							"""simple docstring"""

							def       __A (  self:   int   )    ->				Union[str, Any]:
												super().tearDown()
												# clean-up as much as possible GPU memory occupied by PyTorch
												gc.collect()
												torch.cuda.empty_cache()



							@slow
							def       __A (  self:   Any   )    ->				Any:
												_A								= CTRLLMHeadModel.from_pretrained('''ctrl'''   )
												model.to(__A   )
												_A								= torch.tensor(
												    [[1_18_59, 0, 16_11, 8]]		,     dtype=torch.long		,     device=__A   )  # Legal the president is
												_A								= [
												    1_18_59,
												    0,
												    16_11,
												    8,
												    5,
												    1_50,
												    2_64_49,
												    2,
												    19,
												    3_48,
												    4_69,
												    3,
												    25_95,
												    48,
												    2_07_40,
												    24_65_33,
												    24_65_33,
												    19,
												    30,
												    5,
												]  # Legal the president is a good guy and I don't want to lose my job. \n \n I have a

												_A								= model.generate(__A		,     do_sample=__A   )
												self.assertListEqual(output_ids[0].tolist()		,     __A   )



