"""simple docstring"""


from __future__ import annotations

import collections
import tempfile
import unittest

import numpy as np

from transformers.testing_utils import require_tf, require_vision, slow
from transformers.utils import is_tf_available, is_vision_available

from ...test_modeling_tf_common import floats_tensor, ids_tensor, random_attention_mask
from ..bert.test_modeling_tf_bert import TFBertModelTester
from ..clip.test_modeling_tf_clip import TFCLIPVisionModelTester
from ..deit.test_modeling_tf_deit import TFDeiTModelTester
from ..roberta.test_modeling_tf_roberta import TFRobertaModelTester
from ..vit.test_modeling_tf_vit import TFViTModelTester


if is_tf_available():
	from transformers import (
	    TFBertModel,
	    TFCLIPVisionModel,
	    TFDeiTModel,
	    TFRobertaModel,
	    TFVisionTextDualEncoderModel,
	    TFViTModel,
	    VisionTextDualEncoderConfig,
	)

if is_vision_available():
	from PIL import Image

	from transformers import VisionTextDualEncoderProcessor





def      lowerCamelCase_					(   __lowerCAmelCase							)				->   Tuple:




						'''simple docstring'''



						if isinstance(__lowerCAmelCase  ,       collections.abc.Iterable							):
												return x
						return (x, x)






@require_tf
class   __UpperCAmelCase		:

				def 						_a      ( self      ,					_lowerCamelCase      ,					_lowerCamelCase ):
										pass

				def 						_a      ( self ):
										pass

				def 						_a      ( self ):
										pass

				def 						_a      ( self      ,					_lowerCamelCase      ,					_lowerCamelCase      ,					_lowerCamelCase      ,					_lowerCamelCase      ,					_lowerCamelCase=None      ,					**_lowerCamelCase ):
										lowerCamelCase__   =VisionTextDualEncoderConfig.from_vision_text_configs(_lowerCamelCase      ,					_lowerCamelCase )

										lowerCamelCase__   =TFVisionTextDualEncoderModel(_lowerCamelCase )

										lowerCamelCase__   =model(input_ids=_lowerCamelCase      ,					pixel_values=_lowerCamelCase      ,					attention_mask=_lowerCamelCase )

										self.assertEqual(output["text_embeds"].shape      ,					(input_ids.shape[0], config.projection_dim) )
										self.assertEqual(output["image_embeds"].shape      ,					(pixel_values.shape[0], config.projection_dim) )

				def 						_a      ( self      ,					_lowerCamelCase      ,					_lowerCamelCase      ,					_lowerCamelCase      ,					_lowerCamelCase      ,					_lowerCamelCase=None      ,					**_lowerCamelCase ):
										lowerCamelCase__   , lowerCamelCase__   =self.get_vision_text_model(_lowerCamelCase      ,					_lowerCamelCase )
										lowerCamelCase__   =TFVisionTextDualEncoderModel(vision_model=_lowerCamelCase      ,					text_model=_lowerCamelCase )

										lowerCamelCase__   =model(input_ids=_lowerCamelCase      ,					pixel_values=_lowerCamelCase      ,					attention_mask=_lowerCamelCase )

										self.assertEqual(output["text_embeds"].shape      ,					(input_ids.shape[0], model.config.projection_dim) )
										self.assertEqual(output["image_embeds"].shape      ,					(pixel_values.shape[0], model.config.projection_dim) )

				def 						_a      ( self      ,					_lowerCamelCase      ,					_lowerCamelCase      ,					_lowerCamelCase      ,					_lowerCamelCase      ,					_lowerCamelCase=None      ,					**_lowerCamelCase ):
										lowerCamelCase__   , lowerCamelCase__   =self.get_vision_text_model(_lowerCamelCase      ,					_lowerCamelCase )
										lowerCamelCase__   ={"vision_model": vision_model, "text_model": text_model}
										lowerCamelCase__   =TFVisionTextDualEncoderModel.from_vision_text_pretrained(**_lowerCamelCase )

										lowerCamelCase__   =model(input_ids=_lowerCamelCase      ,					pixel_values=_lowerCamelCase      ,					attention_mask=_lowerCamelCase )

										self.assertEqual(output["text_embeds"].shape      ,					(input_ids.shape[0], model.config.projection_dim) )
										self.assertEqual(output["image_embeds"].shape      ,					(pixel_values.shape[0], model.config.projection_dim) )

				def 						_a      ( self      ,					_lowerCamelCase      ,					_lowerCamelCase      ,					_lowerCamelCase      ,					_lowerCamelCase      ,					_lowerCamelCase=None      ,					**_lowerCamelCase ):
										lowerCamelCase__   , lowerCamelCase__   =self.get_vision_text_model(_lowerCamelCase      ,					_lowerCamelCase )
										lowerCamelCase__   =TFVisionTextDualEncoderModel(vision_model=_lowerCamelCase      ,					text_model=_lowerCamelCase )

										lowerCamelCase__   =model(input_ids=_lowerCamelCase      ,					pixel_values=_lowerCamelCase      ,					attention_mask=_lowerCamelCase )
										lowerCamelCase__   =output[0].numpy()

										with tempfile.TemporaryDirectory() as tmpdirname:
																model.save_pretrained(_lowerCamelCase )
																lowerCamelCase__   =TFVisionTextDualEncoderModel.from_pretrained(_lowerCamelCase )

																lowerCamelCase__   =model(input_ids=_lowerCamelCase      ,					pixel_values=_lowerCamelCase      ,					attention_mask=_lowerCamelCase )
																lowerCamelCase__   =after_output[0].numpy()
																lowerCamelCase__   =np.amax(np.abs(out_a - out_a ) )
																self.assertLessEqual(_lowerCamelCase      ,					1E-5 )

				def 						_a      ( self      ,					_lowerCamelCase      ,					_lowerCamelCase      ,					_lowerCamelCase      ,					_lowerCamelCase      ,					_lowerCamelCase=None      ,					**_lowerCamelCase ):
										lowerCamelCase__   , lowerCamelCase__   =self.get_vision_text_model(_lowerCamelCase      ,					_lowerCamelCase )
										lowerCamelCase__   =TFVisionTextDualEncoderModel(vision_model=_lowerCamelCase      ,					text_model=_lowerCamelCase )

										lowerCamelCase__   =model(
										    input_ids=_lowerCamelCase      ,					pixel_values=_lowerCamelCase      ,					attention_mask=_lowerCamelCase      ,					output_attentions=_lowerCamelCase )

										lowerCamelCase__   =output.vision_model_output.attentions
										self.assertEqual(len(_lowerCamelCase )      ,					vision_config.num_hidden_layers )

										# in ViT, the seq_len equals the number of patches + 1 (we add 1 for the [CLS] token)
										lowerCamelCase__   =to_atuple(vision_model.config.image_size )
										lowerCamelCase__   =to_atuple(vision_model.config.patch_size )
										lowerCamelCase__   =(image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])
										lowerCamelCase__   =num_patches + 1
										self.assertEqual(vision_attentions[0].shape[-3:]      ,					(vision_config.num_attention_heads, seq_len, seq_len) )

										lowerCamelCase__   =output.text_model_output.attentions
										self.assertEqual(len(_lowerCamelCase )      ,					text_config.num_hidden_layers )

										self.assertEqual(
										    text_attentions[0].shape[-3:]      ,					(text_config.num_attention_heads, input_ids.shape[-1], input_ids.shape[-1])      ,					)

				def 						_a      ( self      ,					_lowerCamelCase      ,					_lowerCamelCase      ,					_lowerCamelCase ):
										lowerCamelCase__   =np.abs((a - b) ).max()
										self.assertLessEqual(_lowerCamelCase      ,					_lowerCamelCase      ,					F'''Difference between torch and flax is {diff} (>= {tol}).''' )

				def 						_a      ( self ):
										lowerCamelCase__   =self.prepare_config_and_inputs()
										self.check_vision_text_dual_encoder_model(**_lowerCamelCase )

				def 						_a      ( self ):
										lowerCamelCase__   =self.prepare_config_and_inputs()
										self.check_model_from_pretrained_configs(**_lowerCamelCase )

				def 						_a      ( self ):
										lowerCamelCase__   =self.prepare_config_and_inputs()
										self.check_vision_text_dual_encoder_from_pretrained(**_lowerCamelCase )

				def 						_a      ( self ):
										lowerCamelCase__   =self.prepare_config_and_inputs()
										self.check_save_load(**_lowerCamelCase )

				def 						_a      ( self ):
										lowerCamelCase__   =self.prepare_config_and_inputs()
										self.check_vision_text_output_attention(**_lowerCamelCase )






				@slow
				def 						_a      ( self ):
										lowerCamelCase__   , lowerCamelCase__   =self.get_pretrained_model_and_inputs()

										lowerCamelCase__   =model_a(**_lowerCamelCase )
										lowerCamelCase__   =outputs[0].numpy()

										with tempfile.TemporaryDirectory() as tmp_dirname:
																model_a.save_pretrained(_lowerCamelCase )
																lowerCamelCase__   =TFVisionTextDualEncoderModel.from_pretrained(_lowerCamelCase )

																lowerCamelCase__   =model_a(**_lowerCamelCase )
																lowerCamelCase__   =after_outputs[0].numpy()
																lowerCamelCase__   =np.amax(np.abs(out_a - out_a ) )
																self.assertLessEqual(_lowerCamelCase      ,					1E-5 )






@require_tf
class   __UpperCAmelCase		(      __lowerCAmelCase , unittest.TestCase      ):

				def 						_a      ( self ):
										lowerCamelCase__   =TFVisionTextDualEncoderModel.from_vision_text_pretrained(
										    "hf-internal-testing/tiny-random-vit"      ,					"hf-internal-testing/tiny-random-bert" )
										lowerCamelCase__   =13
										lowerCamelCase__   =floats_tensor(
										    [
										        batch_size,
										        model.vision_model.config.num_channels,
										        model.vision_model.config.image_size,
										        model.vision_model.config.image_size,
										    ] )
										lowerCamelCase__   =ids_tensor([batch_size, 4]      ,					model.text_model.config.vocab_size )
										lowerCamelCase__   =random_attention_mask([batch_size, 4] )
										lowerCamelCase__   ={"pixel_values": pixel_values, "input_ids": input_ids, "attention_mask": attention_mask}

										return model, inputs

				def 						_a      ( self      ,					_lowerCamelCase      ,					_lowerCamelCase ):
										lowerCamelCase__   =TFViTModel(_lowerCamelCase      ,					name="vision_model" )
										lowerCamelCase__   =TFBertModel(_lowerCamelCase      ,					name="text_model" )
										return vision_model, text_model






				def 						_a      ( self ):
										lowerCamelCase__   =TFViTModelTester(self )
										lowerCamelCase__   =TFBertModelTester(self )
										lowerCamelCase__   =vit_model_tester.prepare_config_and_inputs()
										lowerCamelCase__   =bert_model_tester.prepare_config_and_inputs()

										lowerCamelCase__   , lowerCamelCase__   , lowerCamelCase__   =vision_config_and_inputs

										(
										    (
										    lowerCamelCase__
										)   , (
										    lowerCamelCase__
										)   , (
										    lowerCamelCase__
										)   , (
										    lowerCamelCase__
										)   , (
										    lowerCamelCase__
										)   , (
										    lowerCamelCase__
										)   , (
										    lowerCamelCase__
										)   , 
										)   =text_config_and_inputs

										return {
										    "text_config": text_config,
										    "vision_config": vision_config,
										    "pixel_values": pixel_values,
										    "attention_mask": input_mask,
										    "input_ids": input_ids,
										    "text_token_type_ids": token_type_ids,
										    "text_sequence_labels": sequence_labels,
										    "text_token_labels": token_labels,
										    "text_choice_labels": choice_labels,
										}






@require_tf
class   __UpperCAmelCase		(      __lowerCAmelCase , unittest.TestCase      ):

				def 						_a      ( self ):
										# DeiT repo doesn't have TF weights, but we don't actually use the weights at all so let's
										# just reinitialize it.
										lowerCamelCase__   =TFVisionTextDualEncoderModel.from_vision_text_pretrained(
										    "Rocketknight1/tiny-random-deit-tf"      ,					"hf-internal-testing/tiny-random-roberta" )
										lowerCamelCase__   =13
										lowerCamelCase__   =floats_tensor(
										    [
										        batch_size,
										        model.vision_model.config.num_channels,
										        model.vision_model.config.image_size,
										        model.vision_model.config.image_size,
										    ] )
										lowerCamelCase__   =ids_tensor([batch_size, 4]      ,					model.text_model.config.vocab_size )
										lowerCamelCase__   =random_attention_mask([batch_size, 4] )
										lowerCamelCase__   ={"pixel_values": pixel_values, "input_ids": input_ids, "attention_mask": attention_mask}

										return model, inputs

				def 						_a      ( self      ,					_lowerCamelCase      ,					_lowerCamelCase      ,					_lowerCamelCase      ,					_lowerCamelCase      ,					_lowerCamelCase=None      ,					**_lowerCamelCase ):
										lowerCamelCase__   , lowerCamelCase__   =self.get_vision_text_model(_lowerCamelCase      ,					_lowerCamelCase )
										lowerCamelCase__   =TFVisionTextDualEncoderModel(vision_model=_lowerCamelCase      ,					text_model=_lowerCamelCase )

										lowerCamelCase__   =model(
										    input_ids=_lowerCamelCase      ,					pixel_values=_lowerCamelCase      ,					attention_mask=_lowerCamelCase      ,					output_attentions=_lowerCamelCase )

										lowerCamelCase__   =output.vision_model_output.attentions
										self.assertEqual(len(_lowerCamelCase )      ,					vision_config.num_hidden_layers )

										# in DEiT, the seq_len equals the number of patches + 2 (we add 2 for the [CLS] and distillation tokens)
										lowerCamelCase__   =to_atuple(vision_model.config.image_size )
										lowerCamelCase__   =to_atuple(vision_model.config.patch_size )
										lowerCamelCase__   =(image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])
										lowerCamelCase__   =num_patches + 2
										self.assertEqual(vision_attentions[0].shape[-3:]      ,					(vision_config.num_attention_heads, seq_len, seq_len) )

										lowerCamelCase__   =output.text_model_output.attentions
										self.assertEqual(len(_lowerCamelCase )      ,					text_config.num_hidden_layers )

										self.assertEqual(
										    text_attentions[0].shape[-3:]      ,					(text_config.num_attention_heads, input_ids.shape[-1], input_ids.shape[-1])      ,					)

				def 						_a      ( self      ,					_lowerCamelCase      ,					_lowerCamelCase ):
										lowerCamelCase__   =TFDeiTModel(_lowerCamelCase      ,					name="vision_model" )
										lowerCamelCase__   =TFRobertaModel(_lowerCamelCase      ,					name="text_model" )
										return vision_model, text_model






				def 						_a      ( self ):
										lowerCamelCase__   =TFDeiTModelTester(self )
										lowerCamelCase__   =TFRobertaModelTester(self )
										lowerCamelCase__   =vit_model_tester.prepare_config_and_inputs()
										lowerCamelCase__   =bert_model_tester.prepare_config_and_inputs()

										lowerCamelCase__   , lowerCamelCase__   , lowerCamelCase__   =vision_config_and_inputs

										(
										    (
										    lowerCamelCase__
										)   , (
										    lowerCamelCase__
										)   , (
										    lowerCamelCase__
										)   , (
										    lowerCamelCase__
										)   , (
										    lowerCamelCase__
										)   , (
										    lowerCamelCase__
										)   , (
										    lowerCamelCase__
										)   , 
										)   =text_config_and_inputs

										return {
										    "text_config": text_config,
										    "vision_config": vision_config,
										    "pixel_values": pixel_values,
										    "attention_mask": input_mask,
										    "input_ids": input_ids,
										    "text_token_type_ids": token_type_ids,
										    "text_sequence_labels": sequence_labels,
										    "text_token_labels": token_labels,
										    "text_choice_labels": choice_labels,
										}






@require_tf
class   __UpperCAmelCase		(      __lowerCAmelCase , unittest.TestCase      ):

				def 						_a      ( self ):
										lowerCamelCase__   =TFVisionTextDualEncoderModel.from_vision_text_pretrained(
										    "Rocketknight1/tiny-random-clip-tf"      ,					"hf-internal-testing/tiny-random-bert" )
										lowerCamelCase__   =13
										lowerCamelCase__   =floats_tensor(
										    [
										        batch_size,
										        model.vision_model.config.num_channels,
										        model.vision_model.config.image_size,
										        model.vision_model.config.image_size,
										    ] )
										lowerCamelCase__   =ids_tensor([batch_size, 4]      ,					model.text_model.config.vocab_size )
										lowerCamelCase__   =random_attention_mask([batch_size, 4] )
										lowerCamelCase__   ={"pixel_values": pixel_values, "input_ids": input_ids, "attention_mask": attention_mask}

										return model, inputs

				def 						_a      ( self      ,					_lowerCamelCase      ,					_lowerCamelCase ):
										lowerCamelCase__   =TFCLIPVisionModel(_lowerCamelCase      ,					name="vision_model" )
										lowerCamelCase__   =TFBertModel(_lowerCamelCase      ,					name="text_model" )
										return vision_model, text_model






				def 						_a      ( self ):
										lowerCamelCase__   =TFCLIPVisionModelTester(self )
										lowerCamelCase__   =TFBertModelTester(self )
										lowerCamelCase__   =clip_model_tester.prepare_config_and_inputs()
										lowerCamelCase__   =bert_model_tester.prepare_config_and_inputs()

										lowerCamelCase__   , lowerCamelCase__   =vision_config_and_inputs

										(
										    (
										    lowerCamelCase__
										)   , (
										    lowerCamelCase__
										)   , (
										    lowerCamelCase__
										)   , (
										    lowerCamelCase__
										)   , (
										    lowerCamelCase__
										)   , (
										    lowerCamelCase__
										)   , (
										    lowerCamelCase__
										)   , 
										)   =text_config_and_inputs

										return {
										    "text_config": text_config,
										    "vision_config": vision_config,
										    "pixel_values": pixel_values,
										    "attention_mask": input_mask,
										    "input_ids": input_ids,
										    "text_token_type_ids": token_type_ids,
										    "text_sequence_labels": sequence_labels,
										    "text_token_labels": token_labels,
										    "text_choice_labels": choice_labels,
										}






@require_vision
@require_tf
class   __UpperCAmelCase		(      unittest.TestCase      ):

				@slow
				def 						_a      ( self ):
										lowerCamelCase__   =TFVisionTextDualEncoderModel.from_pretrained(
										    "clip-italian/clip-italian"      ,					logit_scale_init_value=1.0      ,					from_pt=_lowerCamelCase )
										lowerCamelCase__   =VisionTextDualEncoderProcessor.from_pretrained("clip-italian/clip-italian" )

										lowerCamelCase__   =Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png" )
										lowerCamelCase__   =processor(
										    text=["una foto di un gatto", "una foto di un cane"]      ,					images=_lowerCamelCase      ,					padding=_lowerCamelCase      ,					return_tensors="np" )

										lowerCamelCase__   =model(**_lowerCamelCase )

										# verify the logits
										self.assertEqual(outputs.logits_per_image.shape      ,					(inputs.pixel_values.shape[0], inputs.input_ids.shape[0]) )
										self.assertEqual(
										    outputs.logits_per_text.shape      ,					(inputs.input_ids.shape[0], inputs.pixel_values.shape[0])      ,					)

										lowerCamelCase__   =np.array([[1.2_2_8_4_7_2_7, 0.3_1_0_4_1_2_2]] )

										self.assertTrue(np.allclose(outputs.logits_per_image.numpy()      ,					_lowerCamelCase      ,					atol=1E-3 ) )



"""simple docstring"""


from math import sqrt





def      lowerCamelCase_					(   __lowerCAmelCase							)				->   bool:




						'''simple docstring'''



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

						lowerCamelCase__   =True

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

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

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

						return status





def      lowerCamelCase_					(   __lowerCAmelCase							)				->   List[str]:




						'''simple docstring'''



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

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

						lowerCamelCase__   =[]  # this list will be returns.

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

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

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

						return ans





def      lowerCamelCase_					(   __lowerCAmelCase							)				->   Optional[int]:




						'''simple docstring'''



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

						lowerCamelCase__   =[]

						# 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(__lowerCAmelCase							):
																		ans.append(__lowerCAmelCase							)

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

						return ans





def      lowerCamelCase_					(   __lowerCAmelCase							)				->   Union[str, Any]:




						'''simple docstring'''



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

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

						# potential prime number factors.

						lowerCamelCase__   =2

						lowerCamelCase__   =number

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

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

						else:
												ans.append(__lowerCAmelCase							)

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

						return ans





def      lowerCamelCase_					(   __lowerCAmelCase							)				->   Optional[int]:




						'''simple docstring'''



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

						lowerCamelCase__   =0

						# prime factorization of 'number'
						lowerCamelCase__   =prime_factorization(__lowerCAmelCase							)

						lowerCamelCase__   =max(__lowerCAmelCase							)

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

						return ans





def      lowerCamelCase_					(   __lowerCAmelCase							)				->   List[Any]:




						'''simple docstring'''



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

						lowerCamelCase__   =0

						# prime factorization of 'number'
						lowerCamelCase__   =prime_factorization(__lowerCAmelCase							)

						lowerCamelCase__   =min(__lowerCAmelCase							)

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

						return ans





def      lowerCamelCase_					(   __lowerCAmelCase							)				->   Union[str, Any]:




						'''simple docstring'''



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

						return number % 2 == 0





def      lowerCamelCase_					(   __lowerCAmelCase							)				->   List[Any]:




						'''simple docstring'''



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

						return number % 2 != 0





def      lowerCamelCase_					(   __lowerCAmelCase							)				->   int:




						'''simple docstring'''



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

						lowerCamelCase__   =[]  # this list will returned

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

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

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

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

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

																		j += 1

												i += 1

						# precondition
						assert (
						    isinstance(__lowerCAmelCase  ,       __lowerCAmelCase							)
						    and (len(__lowerCAmelCase							) == 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      lowerCamelCase_					(   __lowerCAmelCase  ,       __lowerCAmelCase							)				->   Tuple:




						'''simple docstring'''



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

						lowerCamelCase__   =0

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

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

						return numbera





def      lowerCamelCase_					(   __lowerCAmelCase  ,       __lowerCAmelCase							)				->   Union[str, Any]:




						'''simple docstring'''



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

						lowerCamelCase__   =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'
												lowerCamelCase__   =prime_factorization(__lowerCAmelCase							)
												lowerCamelCase__   =prime_factorization(__lowerCAmelCase							)

						elif numbera == 1 or numbera == 1:
												lowerCamelCase__   =[]
												lowerCamelCase__   =[]
												lowerCamelCase__   =max(__lowerCAmelCase  ,       __lowerCAmelCase							)

						lowerCamelCase__   =0
						lowerCamelCase__   =0

						lowerCamelCase__   =[]  # 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:
																								lowerCamelCase__   =prime_fac_a.count(__lowerCAmelCase							)
																								lowerCamelCase__   =prime_fac_a.count(__lowerCAmelCase							)

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

																		else:
																								lowerCamelCase__   =prime_fac_a.count(__lowerCAmelCase							)

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

																		done.append(__lowerCAmelCase							)

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

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

																		done.append(__lowerCAmelCase							)

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

						return ans





def      lowerCamelCase_					(   __lowerCAmelCase							)				->   Optional[Any]:




						'''simple docstring'''



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

						lowerCamelCase__   =0
						lowerCamelCase__   =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(__lowerCAmelCase							):
																		ans += 1

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

						return ans





def      lowerCamelCase_					(   __lowerCAmelCase  ,       __lowerCAmelCase							)				->   int:




						'''simple docstring'''



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

						lowerCamelCase__   =p_number_a + 1  # jump to the next number

						lowerCamelCase__   =[]  # this list will be returns.

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

						while number < p_number_a:
												ans.append(__lowerCAmelCase							)

												number += 1

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

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

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





def      lowerCamelCase_					(   __lowerCAmelCase							)				->   int:




						'''simple docstring'''



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

						lowerCamelCase__   =[]  # will be returned.

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

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

						return ans





def      lowerCamelCase_					(   __lowerCAmelCase							)				->   Union[str, Any]:




						'''simple docstring'''



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

						lowerCamelCase__   =get_divisors(__lowerCAmelCase							)

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

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





def      lowerCamelCase_					(   __lowerCAmelCase  ,       __lowerCAmelCase							)				->   Dict:




						'''simple docstring'''



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

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

						# precondition
						assert (
						    isinstance(__lowerCAmelCase  ,       __lowerCAmelCase							)
						    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      lowerCamelCase_					(   __lowerCAmelCase							)				->   List[Any]:




						'''simple docstring'''



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

						lowerCamelCase__   =1  # this will be return.

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

						return ans





def      lowerCamelCase_					(   __lowerCAmelCase							)				->   Tuple:




						'''simple docstring'''



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

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

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

						return ans


