






import inspect
import math
import tempfile
import unittest

import numpy as np

from transformers import ViTMAEConfig
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

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


if is_torch_available():
				import torch
				from torch import nn

				from transformers import ViTMAEForPreTraining, ViTMAEModel
				from transformers.models.vit.modeling_vit import VIT_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
				from PIL import Image

				from transformers import ViTImageProcessor


class 							__a							:





		'''simple docstring'''



		def __init__(						self ,    UpperCamelCase__ ,    UpperCamelCase__=13 ,    UpperCamelCase__=30 ,    UpperCamelCase__=2 ,    UpperCamelCase__=3 ,    UpperCamelCase__=True ,    UpperCamelCase__=True ,    UpperCamelCase__=32 ,    UpperCamelCase__=5 ,    UpperCamelCase__=4 ,    UpperCamelCase__=37 ,    UpperCamelCase__="gelu" ,    UpperCamelCase__=0.1 ,    UpperCamelCase__=0.1 ,    UpperCamelCase__=10 ,    UpperCamelCase__=0.02 ,    UpperCamelCase__=3 ,    UpperCamelCase__=0.6 ,    UpperCamelCase__=None ,    ):
						SCREAMING_SNAKE_CASE_   :	int													=   parent
						SCREAMING_SNAKE_CASE_   :	Optional[int]													=   batch_size
						SCREAMING_SNAKE_CASE_   :	Dict													=   image_size
						SCREAMING_SNAKE_CASE_   :	Optional[int]													=   patch_size
						SCREAMING_SNAKE_CASE_   :	int													=   num_channels
						SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   is_training
						SCREAMING_SNAKE_CASE_   :	Union[str, Any]													=   use_labels
						SCREAMING_SNAKE_CASE_   :	int													=   hidden_size
						SCREAMING_SNAKE_CASE_   :	Any													=   num_hidden_layers
						SCREAMING_SNAKE_CASE_   :	Any													=   num_attention_heads
						SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   intermediate_size
						SCREAMING_SNAKE_CASE_   :	Tuple													=   hidden_act
						SCREAMING_SNAKE_CASE_   :	str													=   hidden_dropout_prob
						SCREAMING_SNAKE_CASE_   :	int													=   attention_probs_dropout_prob
						SCREAMING_SNAKE_CASE_   :	Tuple													=   type_sequence_label_size
						SCREAMING_SNAKE_CASE_   :	Optional[int]													=   initializer_range
						SCREAMING_SNAKE_CASE_   :	Dict													=   mask_ratio
						SCREAMING_SNAKE_CASE_   :	int													=   scope

						# in ViTMAE, the expected sequence length = (num_patches + 1) * (1 - config.mask_ratio), rounded above
						# (we add 1 for the [CLS] token)
						SCREAMING_SNAKE_CASE_   :	Dict													=   (image_size // patch_size) ** 2
						SCREAMING_SNAKE_CASE_   :	Tuple													=   int(math.ceil((1 - mask_ratio) * (num_patches + 1)       )       )


		def   __snake_case			(						self       ):
						SCREAMING_SNAKE_CASE_   :	List[str]													=   floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]       )

						SCREAMING_SNAKE_CASE_   :	List[Any]													=   None
						if self.use_labels:
										SCREAMING_SNAKE_CASE_   :	List[Any]													=   ids_tensor([self.batch_size] ,    self.type_sequence_label_size       )

						SCREAMING_SNAKE_CASE_   :	Any													=   self.get_config()

						return config, pixel_values, labels


		def   __snake_case			(						self       ):
						return ViTMAEConfig(
						    image_size=self.image_size ,    patch_size=self.patch_size ,    num_channels=self.num_channels ,    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 ,    is_decoder=UpperCamelCase__ ,    initializer_range=self.initializer_range ,    mask_ratio=self.mask_ratio ,    )


		def   __snake_case			(						self ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__       ):
						SCREAMING_SNAKE_CASE_   :	List[str]													=   ViTMAEModel(config=UpperCamelCase__       )
						model.to(UpperCamelCase__       )
						model.eval()
						SCREAMING_SNAKE_CASE_   :	Tuple													=   model(UpperCamelCase__       )
						self.parent.assertEqual(result.last_hidden_state.shape ,    (self.batch_size, self.seq_length, self.hidden_size)       )


		def   __snake_case			(						self ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__       ):
						SCREAMING_SNAKE_CASE_   :	Any													=   ViTMAEForPreTraining(UpperCamelCase__       )
						model.to(UpperCamelCase__       )
						model.eval()
						SCREAMING_SNAKE_CASE_   :	List[str]													=   model(UpperCamelCase__       )
						SCREAMING_SNAKE_CASE_   :	int													=   (self.image_size // self.patch_size) ** 2
						SCREAMING_SNAKE_CASE_   :	int													=   self.patch_size**2 * self.num_channels
						self.parent.assertEqual(result.logits.shape ,    (self.batch_size, num_patches, expected_num_channels)       )

						# test greyscale images
						SCREAMING_SNAKE_CASE_   :	List[Any]													=   1
						SCREAMING_SNAKE_CASE_   :	Union[str, Any]													=   ViTMAEForPreTraining(UpperCamelCase__       )
						model.to(UpperCamelCase__       )
						model.eval()
						SCREAMING_SNAKE_CASE_   :	str													=   floats_tensor([self.batch_size, 1, self.image_size, self.image_size]       )
						SCREAMING_SNAKE_CASE_   :	Dict													=   model(UpperCamelCase__       )
						SCREAMING_SNAKE_CASE_   :	str													=   self.patch_size**2
						self.parent.assertEqual(result.logits.shape ,    (self.batch_size, num_patches, expected_num_channels)       )






		def   __snake_case			(						self       ):
						SCREAMING_SNAKE_CASE_   :	Tuple													=   self.prepare_config_and_inputs()
						SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   config_and_inputs
						SCREAMING_SNAKE_CASE_   :	Union[str, Any]													=   {'pixel_values': pixel_values}
						return config, inputs_dict






@require_torch
class 							__a							(  __A ,	__A ,	unittest.TestCase						):





		'''simple docstring'''



		UpperCAmelCase__      :				Optional[Any]				    =						(ViTMAEModel, ViTMAEForPreTraining) if is_torch_available() else ()
		UpperCAmelCase__      :				Optional[Any]				    =						{"""feature-extraction""": ViTMAEModel} if is_torch_available() else {}

		UpperCAmelCase__      :				str				    =						False
		UpperCAmelCase__      :				Dict				    =						False
		UpperCAmelCase__      :				Tuple				    =						False
		UpperCAmelCase__      :				List[Any]				    =						False


		def   __snake_case			(						self       ):
						SCREAMING_SNAKE_CASE_   :	Any													=   ViTMAEModelTester(self       )
						SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   ConfigTester(self ,    config_class=UpperCamelCase__ ,    has_text_modality=UpperCamelCase__ ,    hidden_size=37       )


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


		@unittest.skip(reason='ViTMAE does not use inputs_embeds'       )
		def   __snake_case			(						self       ):
						pass


		def   __snake_case			(						self       ):
						SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_   :	int													=   self.model_tester.prepare_config_and_inputs_for_common()

						for model_class in self.all_model_classes:
										SCREAMING_SNAKE_CASE_   :	List[Any]													=   model_class(UpperCamelCase__       )
										self.assertIsInstance(model.get_input_embeddings() ,    (nn.Module)       )
										SCREAMING_SNAKE_CASE_   :	List[Any]													=   model.get_output_embeddings()
										self.assertTrue(x is None or isinstance(UpperCamelCase__ ,    nn.Linear       )       )


		def   __snake_case			(						self       ):
						SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_   :	str													=   self.model_tester.prepare_config_and_inputs_for_common()

						for model_class in self.all_model_classes:
										SCREAMING_SNAKE_CASE_   :	Tuple													=   model_class(UpperCamelCase__       )
										SCREAMING_SNAKE_CASE_   :	List[Any]													=   inspect.signature(model.forward       )
										# signature.parameters is an OrderedDict => so arg_names order is deterministic
										SCREAMING_SNAKE_CASE_   :	List[Any]													=   [*signature.parameters.keys()]

										SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   ['pixel_values']
										self.assertListEqual(arg_names[:1] ,    UpperCamelCase__       )


		def   __snake_case			(						self       ):
						SCREAMING_SNAKE_CASE_   :	List[Any]													=   self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_model(*UpperCamelCase__       )


		def   __snake_case			(						self       ):
						SCREAMING_SNAKE_CASE_   :	Any													=   self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_pretraining(*UpperCamelCase__       )


		def   __snake_case			(						self ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__       ):
						# make masks reproducible
						np.random.seed(2       )

						SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   int((pt_model.config.image_size // pt_model.config.patch_size) ** 2       )
						SCREAMING_SNAKE_CASE_   :	str													=   np.random.uniform(size=(self.model_tester.batch_size, num_patches)       )
						SCREAMING_SNAKE_CASE_   :	Optional[int]													=   torch.from_numpy(UpperCamelCase__       )

						# Add `noise` argument.
						# PT inputs will be prepared in `super().check_pt_tf_models()` with this added `noise` argument
						SCREAMING_SNAKE_CASE_   :	Optional[int]													=   pt_noise

						super().check_pt_tf_models(UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__       )


		def   __snake_case			(						self       ):
						SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_   :	Optional[int]													=   self.model_tester.prepare_config_and_inputs_for_common()

						for model_class in self.all_model_classes:
										SCREAMING_SNAKE_CASE_   :	Dict													=   model_class(UpperCamelCase__       )
										model.to(UpperCamelCase__       )
										model.eval()
										# make random mask reproducible
										torch.manual_seed(2       )
										with torch.no_grad():
														SCREAMING_SNAKE_CASE_   :	Optional[int]													=   model(**self._prepare_for_class(UpperCamelCase__ ,    UpperCamelCase__       )       )

										SCREAMING_SNAKE_CASE_   :	Any													=   outputs[0].cpu().numpy()
										SCREAMING_SNAKE_CASE_   :	Tuple													=   0

										with tempfile.TemporaryDirectory() as tmpdirname:
														model.save_pretrained(UpperCamelCase__       )
														SCREAMING_SNAKE_CASE_   :	str													=   model_class.from_pretrained(UpperCamelCase__       )
														model.to(UpperCamelCase__       )
														# make random mask reproducible
														torch.manual_seed(2       )
														with torch.no_grad():
																		SCREAMING_SNAKE_CASE_   :	int													=   model(**self._prepare_for_class(UpperCamelCase__ ,    UpperCamelCase__       )       )

														# Make sure we don't have nans
														SCREAMING_SNAKE_CASE_   :	str													=   after_outputs[0].cpu().numpy()
														SCREAMING_SNAKE_CASE_   :	Union[str, Any]													=   0
														SCREAMING_SNAKE_CASE_   :	Union[str, Any]													=   np.amax(np.abs(out_a - out_a       )       )
														self.assertLessEqual(UpperCamelCase__ ,    1E-5       )


		@unittest.skip(
		    reason='ViTMAE returns a random mask + ids_restore in each forward pass. See test_save_load\n    to get deterministic results.'       )
		def   __snake_case			(						self       ):
						pass


		@unittest.skip(
		    reason='ViTMAE returns a random mask + ids_restore in each forward pass. See test_save_load\n    to get deterministic results.'       )
		def   __snake_case			(						self       ):
						pass


		@unittest.skip(
		    reason='ViTMAE returns a random mask + ids_restore in each forward pass. See test_save_load\n    to get deterministic results.'       )
		def   __snake_case			(						self       ):
						pass


		@unittest.skip(reason='ViTMAE returns a random mask + ids_restore in each forward pass. See test_save_load'       )
		def   __snake_case			(						self       ):
						pass


		@unittest.skip('Will be fixed soon by reducing the size of the model used for common tests.'       )
		def   __snake_case			(						self       ):
						pass






		@slow
		def   __snake_case			(						self       ):
						for model_name in VIT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
										SCREAMING_SNAKE_CASE_   :	str													=   ViTMAEModel.from_pretrained(UpperCamelCase__       )
										self.assertIsNotNone(UpperCamelCase__       )






def 					_lowerCamelCase(			):





				'''simple docstring'''







				SCREAMING_SNAKE_CASE_   :	List[str]													=   Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'      )
				return image


@require_torch
@require_vision
class 							__a							(  unittest.TestCase						):





		'''simple docstring'''



		@cached_property
		def   __snake_case			(						self       ):
						return ViTImageProcessor.from_pretrained('facebook/vit-mae-base'       ) if is_vision_available() else None






		@slow
		def   __snake_case			(						self       ):
						# make random mask reproducible across the PT and TF model
						np.random.seed(2       )

						SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   ViTMAEForPreTraining.from_pretrained('facebook/vit-mae-base'       ).to(UpperCamelCase__       )

						SCREAMING_SNAKE_CASE_   :	List[str]													=   self.default_image_processor
						SCREAMING_SNAKE_CASE_   :	Dict													=   prepare_img()
						SCREAMING_SNAKE_CASE_   :	Union[str, Any]													=   image_processor(images=UpperCamelCase__ ,    return_tensors='pt'       ).to(UpperCamelCase__       )

						# prepare a noise vector that will be also used for testing the TF model
						# (this way we can ensure that the PT and TF models operate on the same inputs)
						SCREAMING_SNAKE_CASE_   :	Any													=   ViTMAEConfig()
						SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   int((vit_mae_config.image_size // vit_mae_config.patch_size) ** 2       )
						SCREAMING_SNAKE_CASE_   :	str													=   np.random.uniform(size=(1, num_patches)       )

						# forward pass
						with torch.no_grad():
										SCREAMING_SNAKE_CASE_   :	Tuple													=   model(**UpperCamelCase__ ,    noise=torch.from_numpy(UpperCamelCase__       ).to(device=UpperCamelCase__       )       )

						# verify the logits
						SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   torch.Size((1, 196, 768)       )
						self.assertEqual(outputs.logits.shape ,    UpperCamelCase__       )

						SCREAMING_SNAKE_CASE_   :	Optional[int]													=   torch.tensor(
						    [[-0.05_48, -1.70_23, -0.93_25], [0.37_21, -0.56_70, -0.22_33], [0.82_35, -1.38_78, -0.35_24]]       )

						self.assertTrue(torch.allclose(outputs.logits[0, :3, :3] ,    expected_slice.to(UpperCamelCase__       ) ,    atol=1E-4       )       )







from math import sqrt



def 					_lowerCamelCase(			lowerCAmelCase__				:		int      ):





				'''simple docstring'''







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

				SCREAMING_SNAKE_CASE_   :	Dict													=   True

				# 0 and 1 are none primes.
				if number <= 1:
								SCREAMING_SNAKE_CASE_   :	Optional[int]													=   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:
												SCREAMING_SNAKE_CASE_   :	Dict													=   False
												break

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

				return status



def 					_lowerCamelCase(			lowerCAmelCase__				:		int      ):





				'''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
				SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   list(range(2    ,    n + 1      )      )

				SCREAMING_SNAKE_CASE_   :	Any													=   []  # 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):
																SCREAMING_SNAKE_CASE_   :	str													=   0

    # filters actual prime numbers.
				SCREAMING_SNAKE_CASE_   :	int													=   [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__				:		List[str]      ):





				'''simple docstring'''







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

				SCREAMING_SNAKE_CASE_   :	int													=   []

				# 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"

				SCREAMING_SNAKE_CASE_   :	Optional[int]													=   []  # this list will be returns of the function.

				# potential prime number factors.

				SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   2

				SCREAMING_SNAKE_CASE_   :	List[Any]													=   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__				:		Any      ):





				'''simple docstring'''







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

				SCREAMING_SNAKE_CASE_   :	int													=   0

				# prime factorization of 'number'
				SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   prime_factorization(lowerCAmelCase__      )

				SCREAMING_SNAKE_CASE_   :	Dict													=   max(lowerCAmelCase__      )

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

				return ans



def 					_lowerCamelCase(			lowerCAmelCase__				:		Optional[Any]      ):





				'''simple docstring'''







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

				SCREAMING_SNAKE_CASE_   :	Optional[int]													=   0

				# prime factorization of 'number'
				SCREAMING_SNAKE_CASE_   :	Union[str, Any]													=   prime_factorization(lowerCAmelCase__      )

				SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   min(lowerCAmelCase__      )

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

				return ans



def 					_lowerCamelCase(			lowerCAmelCase__				:		Optional[int]      ):





				'''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__				:		Optional[int]      ):





				'''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__				:		Optional[Any]      ):





				'''simple docstring'''







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

				SCREAMING_SNAKE_CASE_   :	Any													=   []  # this list will returned

				# creates a list of prime numbers between 2 up to 'number'
				SCREAMING_SNAKE_CASE_   :	int													=   get_prime_numbers(lowerCAmelCase__      )
				SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   len(lowerCAmelCase__      )

				# run variable for while-loops.
				SCREAMING_SNAKE_CASE_   :	Any													=   0
				SCREAMING_SNAKE_CASE_   :	List[str]													=   None

				# exit variable. for break up the loops
				SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   True

				while i < len_pn and loop:
								SCREAMING_SNAKE_CASE_   :	Optional[int]													=   i + 1

								while j < len_pn and loop:
												if prime_numbers[i] + prime_numbers[j] == number:
																SCREAMING_SNAKE_CASE_   :	List[str]													=   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__				:		str    ,    lowerCAmelCase__				:		List[Any]      ):





				'''simple docstring'''







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

				SCREAMING_SNAKE_CASE_   :	int													=   0

				while numbera != 0:
								SCREAMING_SNAKE_CASE_   :	List[str]													=   numbera % numbera
								SCREAMING_SNAKE_CASE_   :	Optional[int]													=   numbera
								SCREAMING_SNAKE_CASE_   :	List[Any]													=   rest

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

				return numbera



def 					_lowerCamelCase(			lowerCAmelCase__				:		int    ,    lowerCAmelCase__				:		Optional[Any]      ):





				'''simple docstring'''







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

				SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   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'
								SCREAMING_SNAKE_CASE_   :	Tuple													=   prime_factorization(lowerCAmelCase__      )
								SCREAMING_SNAKE_CASE_   :	List[Any]													=   prime_factorization(lowerCAmelCase__      )

				elif numbera == 1 or numbera == 1:
								SCREAMING_SNAKE_CASE_   :	List[Any]													=   []
								SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   []
								SCREAMING_SNAKE_CASE_   :	int													=   max(lowerCAmelCase__    ,    lowerCAmelCase__      )

				SCREAMING_SNAKE_CASE_   :	Union[str, Any]													=   0
				SCREAMING_SNAKE_CASE_   :	Any													=   0

				SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   []  # 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:
																SCREAMING_SNAKE_CASE_   :	int													=   prime_fac_a.count(lowerCAmelCase__      )
																SCREAMING_SNAKE_CASE_   :	Tuple													=   prime_fac_a.count(lowerCAmelCase__      )

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

												else:
																SCREAMING_SNAKE_CASE_   :	List[Any]													=   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:
												SCREAMING_SNAKE_CASE_   :	int													=   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__				:		Any      ):





				'''simple docstring'''







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

				SCREAMING_SNAKE_CASE_   :	Optional[int]													=   0
				SCREAMING_SNAKE_CASE_   :	Optional[int]													=   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__				:		List[str]    ,    lowerCAmelCase__				:		Optional[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'"

				SCREAMING_SNAKE_CASE_   :	str													=   p_number_a + 1  # jump to the next number

				SCREAMING_SNAKE_CASE_   :	List[Any]													=   []  # 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__				:		Optional[Any]      ):





				'''simple docstring'''







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

				SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   []  # 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__				:		int      ):





				'''simple docstring'''







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

				SCREAMING_SNAKE_CASE_   :	int													=   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__				:		Dict    ,    lowerCAmelCase__				:		str      ):





				'''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.
				SCREAMING_SNAKE_CASE_   :	str													=   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__				:		Tuple      ):





				'''simple docstring'''







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

				SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   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"

				SCREAMING_SNAKE_CASE_   :	List[Any]													=   0
				SCREAMING_SNAKE_CASE_   :	Union[str, Any]													=   1
				SCREAMING_SNAKE_CASE_   :	int													=   1  # this will be return

				for _ in range(n - 1      ):
								SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   ans
								ans += fiba
								SCREAMING_SNAKE_CASE_   :	List[str]													=   tmp

				return ans