



import argparse
import collections
import json
from pathlib import Path

import requests
import torch
import yaml
from huggingface_hub import hf_hub_download
from PIL import Image

from transformers import (
    MobileViTImageProcessor,
    MobileViTVaConfig,
    MobileViTVaForImageClassification,
    MobileViTVaForSemanticSegmentation,
)
from transformers.utils import logging


logging.set_verbosity_info()
a_								=    logging.get_logger(__name__)





def 						a__	(						_UpperCamelCase	:       Union[str, Any]							):
   print('''Loading config file...'''							)

   def flatten_yaml_as_dict(_UpperCamelCase	:       Dict       ,_UpperCamelCase	:       str=""       ,_UpperCamelCase	:       int="."							):
      __lowerCamelCase  							=			[]
      for k, v in d.items():
         __lowerCamelCase  							=			parent_key + sep + k if parent_key else k
         if isinstance(lowerCAmelCase_       ,collections.abc.MutableMapping							):
            items.extend(flatten_yaml_as_dict(lowerCAmelCase_       ,lowerCAmelCase_       ,sep=lowerCAmelCase_							).items()							)
         else:
            items.append((new_key, v)							)
      return dict(lowerCAmelCase_							)

   __lowerCamelCase  							=			argparse.Namespace()
   with open(lowerCAmelCase_       ,'''r'''							) as yaml_file:
      try:
         __lowerCamelCase  							=			yaml.load(lowerCAmelCase_       ,Loader=yaml.FullLoader							)

         __lowerCamelCase  							=			flatten_yaml_as_dict(lowerCAmelCase_							)
         for k, v in flat_cfg.items():
            setattr(lowerCAmelCase_       ,lowerCAmelCase_       ,lowerCAmelCase_							)
      except yaml.YAMLError as exc:
         logger.error('''Error while loading config file: {}. Error message: {}'''.format(lowerCAmelCase_       ,str(lowerCAmelCase_							)							)							)
   return config





def 						a__	(						_UpperCamelCase	:       List[Any]       ,_UpperCamelCase	:       Tuple							):
   __lowerCamelCase  							=			MobileViTVaConfig()

   __lowerCamelCase  							=			False

   # dataset
   if task_name.startswith('''imagenet1k_'''							):
      __lowerCamelCase  							=			10_00
      if int(task_name.strip().split('''_'''							)[-1]							) == 3_84:
         __lowerCamelCase  							=			3_84
      else:
         __lowerCamelCase  							=			2_56
      __lowerCamelCase  							=			'''imagenet-1k-id2label.json'''
   elif task_name.startswith('''imagenet21k_to_1k_'''							):
      __lowerCamelCase  							=			2_10_00
      if int(task_name.strip().split('''_'''							)[-1]							) == 3_84:
         __lowerCamelCase  							=			3_84
      else:
         __lowerCamelCase  							=			2_56
      __lowerCamelCase  							=			'''imagenet-22k-id2label.json'''
   elif task_name.startswith('''ade20k_'''							):
      __lowerCamelCase  							=			1_51
      __lowerCamelCase  							=			5_12
      __lowerCamelCase  							=			'''ade20k-id2label.json'''
      __lowerCamelCase  							=			True
   elif task_name.startswith('''voc_'''							):
      __lowerCamelCase  							=			21
      __lowerCamelCase  							=			5_12
      __lowerCamelCase  							=			'''pascal-voc-id2label.json'''
      __lowerCamelCase  							=			True

   # orig_config
   __lowerCamelCase  							=			load_orig_config_file(lowerCAmelCase_							)
   assert getattr(lowerCAmelCase_       ,'''model.classification.name'''       ,-1							) == "mobilevit_v2", "Invalid model"
   __lowerCamelCase  							=			getattr(lowerCAmelCase_       ,'''model.classification.mitv2.width_multiplier'''       ,1.0							)
   assert (
       getattr(lowerCAmelCase_       ,'''model.classification.mitv2.attn_norm_layer'''       ,-1							) == "layer_norm_2d"
   ), "Norm layers other than layer_norm_2d is not supported"
   __lowerCamelCase  							=			getattr(lowerCAmelCase_       ,'''model.classification.activation.name'''       ,'''swish'''							)
   # config.image_size == getattr(orig_config,  'sampler.bs.crop_size_width', 256)

   if is_segmentation_model:
      __lowerCamelCase  							=			getattr(lowerCAmelCase_       ,'''model.segmentation.output_stride'''       ,16							)
      if "_deeplabv3" in task_name:
         __lowerCamelCase  							=			getattr(lowerCAmelCase_       ,'''model.segmentation.deeplabv3.aspp_rates'''       ,[12, 24, 36]							)
         __lowerCamelCase  							=			getattr(lowerCAmelCase_       ,'''model.segmentation.deeplabv3.aspp_out_channels'''       ,5_12							)
         __lowerCamelCase  							=			getattr(lowerCAmelCase_       ,'''model.segmentation.deeplabv3.aspp_dropout'''       ,0.1							)

    # id2label
   __lowerCamelCase  							=			'''huggingface/label-files'''
   __lowerCamelCase  							=			json.load(open(hf_hub_download(lowerCAmelCase_       ,lowerCAmelCase_       ,repo_type='''dataset'''							)       ,'''r'''							)							)
   __lowerCamelCase  							=			{int(lowerCAmelCase_							): v for k, v in idalabel.items()}
   __lowerCamelCase  							=			idalabel
   __lowerCamelCase  							=			{v: k for k, v in idalabel.items()}

   return config





def 						a__	(						_UpperCamelCase	:       Dict       ,_UpperCamelCase	:       Dict       ,_UpperCamelCase	:       int							):
   __lowerCamelCase  							=			dct.pop(lowerCAmelCase_							)
   __lowerCamelCase  							=			val





def 						a__	(						_UpperCamelCase	:       Union[str, Any]       ,_UpperCamelCase	:       Tuple=False							):
   if base_model:
      __lowerCamelCase  							=			''''''
   else:
      __lowerCamelCase  							=			'''mobilevitv2.'''

   __lowerCamelCase  							=			[]
   for k in state_dict.keys():
      if k[:8] == "encoder.":
         __lowerCamelCase  							=			k[8:]
      else:
         __lowerCamelCase  							=			k

      if ".block." in k:
         __lowerCamelCase  							=			k_new.replace('''.block.'''       ,'''.'''							)
      if ".conv." in k:
         __lowerCamelCase  							=			k_new.replace('''.conv.'''       ,'''.convolution.'''							)
      if ".norm." in k:
         __lowerCamelCase  							=			k_new.replace('''.norm.'''       ,'''.normalization.'''							)

      if "conv_1." in k:
         __lowerCamelCase  							=			k_new.replace('''conv_1.'''       ,F"""{model_prefix}conv_stem."""							)
      for i in [1, 2]:
         if F"""layer_{i}.""" in k:
            __lowerCamelCase  							=			k_new.replace(F"""layer_{i}."""       ,F"""{model_prefix}encoder.layer.{i-1}.layer."""							)
      if ".exp_1x1." in k:
         __lowerCamelCase  							=			k_new.replace('''.exp_1x1.'''       ,'''.expand_1x1.'''							)
      if ".red_1x1." in k:
         __lowerCamelCase  							=			k_new.replace('''.red_1x1.'''       ,'''.reduce_1x1.'''							)

      for i in [3, 4, 5]:
         if F"""layer_{i}.0.""" in k:
            __lowerCamelCase  							=			k_new.replace(F"""layer_{i}.0."""       ,F"""{model_prefix}encoder.layer.{i-1}.downsampling_layer."""							)
         if F"""layer_{i}.1.local_rep.0.""" in k:
            __lowerCamelCase  							=			k_new.replace(F"""layer_{i}.1.local_rep.0."""       ,F"""{model_prefix}encoder.layer.{i-1}.conv_kxk."""							)
         if F"""layer_{i}.1.local_rep.1.""" in k:
            __lowerCamelCase  							=			k_new.replace(F"""layer_{i}.1.local_rep.1."""       ,F"""{model_prefix}encoder.layer.{i-1}.conv_1x1."""							)

      for i in [3, 4, 5]:
         if i == 3:
            __lowerCamelCase  							=			[0, 1]
         elif i == 4:
            __lowerCamelCase  							=			[0, 1, 2, 3]
         elif i == 5:
            __lowerCamelCase  							=			[0, 1, 2]

         for j in j_in:
            if F"""layer_{i}.1.global_rep.{j}.""" in k:
               __lowerCamelCase  							=			k_new.replace(
                   F"""layer_{i}.1.global_rep.{j}."""       ,F"""{model_prefix}encoder.layer.{i-1}.transformer.layer.{j}."""							)
         if F"""layer_{i}.1.global_rep.{j+1}.""" in k:
            __lowerCamelCase  							=			k_new.replace(
                F"""layer_{i}.1.global_rep.{j+1}."""       ,F"""{model_prefix}encoder.layer.{i-1}.layernorm."""							)

         if F"""layer_{i}.1.conv_proj.""" in k:
            __lowerCamelCase  							=			k_new.replace(F"""layer_{i}.1.conv_proj."""       ,F"""{model_prefix}encoder.layer.{i-1}.conv_projection."""							)

      if "pre_norm_attn.0." in k:
         __lowerCamelCase  							=			k_new.replace('''pre_norm_attn.0.'''       ,'''layernorm_before.'''							)
      if "pre_norm_attn.1." in k:
         __lowerCamelCase  							=			k_new.replace('''pre_norm_attn.1.'''       ,'''attention.'''							)
      if "pre_norm_ffn.0." in k:
         __lowerCamelCase  							=			k_new.replace('''pre_norm_ffn.0.'''       ,'''layernorm_after.'''							)
      if "pre_norm_ffn.1." in k:
         __lowerCamelCase  							=			k_new.replace('''pre_norm_ffn.1.'''       ,'''ffn.conv1.'''							)
      if "pre_norm_ffn.3." in k:
         __lowerCamelCase  							=			k_new.replace('''pre_norm_ffn.3.'''       ,'''ffn.conv2.'''							)

      if "classifier.1." in k:
         __lowerCamelCase  							=			k_new.replace('''classifier.1.'''       ,'''classifier.'''							)

      if "seg_head." in k:
         __lowerCamelCase  							=			k_new.replace('''seg_head.'''       ,'''segmentation_head.'''							)
      if ".aspp_layer." in k:
         __lowerCamelCase  							=			k_new.replace('''.aspp_layer.'''       ,'''.'''							)
      if ".aspp_pool." in k:
         __lowerCamelCase  							=			k_new.replace('''.aspp_pool.'''       ,'''.'''							)

      rename_keys.append((k, k_new)							)
   return rename_keys





def 						a__	(						_UpperCamelCase	:       List[str]							):
   __lowerCamelCase  							=			[]
   for k in state_dict.keys():
      if k.startswith('''seg_head.aux_head.'''							):
         keys_to_ignore.append(lowerCAmelCase_							)
   for k in keys_to_ignore:
      state_dict.pop(lowerCAmelCase_       ,lowerCAmelCase_							)





def 						a__	(						):
   __lowerCamelCase  							=			'''http://images.cocodataset.org/val2017/000000039769.jpg'''
   # url = "https://cdn.britannica.com/86/141086-050-9D7C75EE/Gulfstream-G450-business-jet-passengers.jpg"
   __lowerCamelCase  							=			Image.open(requests.get(lowerCAmelCase_       ,stream=lowerCAmelCase_							).raw							)
   return im





@torch.no_grad()
def 						a__	(						_UpperCamelCase	:       str       ,_UpperCamelCase	:       str       ,_UpperCamelCase	:       Tuple       ,_UpperCamelCase	:       Any							):
   __lowerCamelCase  							=			get_mobilevitva_config(lowerCAmelCase_       ,lowerCAmelCase_							)

   # load original state_dict
   __lowerCamelCase  							=			torch.load(lowerCAmelCase_       ,map_location='''cpu'''							)

   # load huggingface model
   if task_name.startswith('''ade20k_'''							) or task_name.startswith('''voc_'''							):
      __lowerCamelCase  							=			MobileViTVaForSemanticSegmentation(lowerCAmelCase_							).eval()
      __lowerCamelCase  							=			False
   else:
      __lowerCamelCase  							=			MobileViTVaForImageClassification(lowerCAmelCase_							).eval()
      __lowerCamelCase  							=			False

   # remove and rename some keys of load the original model
   __lowerCamelCase  							=			checkpoint
   remove_unused_keys(lowerCAmelCase_							)
   __lowerCamelCase  							=			create_rename_keys(lowerCAmelCase_       ,base_model=lowerCAmelCase_							)
   for rename_key_src, rename_key_dest in rename_keys:
      rename_key(lowerCAmelCase_       ,lowerCAmelCase_       ,lowerCAmelCase_							)

   # load modified state_dict
   model.load_state_dict(lowerCAmelCase_							)

   # Check outputs on an image, prepared by MobileViTImageProcessor
   __lowerCamelCase  							=			MobileViTImageProcessor(crop_size=config.image_size       ,size=config.image_size + 32							)
   __lowerCamelCase  							=			image_processor(images=prepare_img()       ,return_tensors='''pt'''							)
   __lowerCamelCase  							=			model(**lowerCAmelCase_							)

   # verify classification model
   if task_name.startswith('''imagenet'''							):
      __lowerCamelCase  							=			outputs.logits
      __lowerCamelCase  							=			logits.argmax(-1							).item()
      print('''Predicted class:'''       ,model.config.idalabel[predicted_class_idx]							)
      if task_name.startswith('''imagenet1k_256'''							) and config.width_multiplier == 1.0:
         # expected_logits for base variant
         __lowerCamelCase  							=			torch.tensor([-1.6336e00, -7.3204e-02, -5.1883e-01]							)
         assert torch.allclose(logits[0, :3]       ,lowerCAmelCase_       ,atol=1e-4							)

   Path(lowerCAmelCase_							).mkdir(exist_ok=lowerCAmelCase_							)
   print(F"""Saving model {task_name} to {pytorch_dump_folder_path}"""							)
   model.save_pretrained(lowerCAmelCase_							)
   print(F"""Saving image processor to {pytorch_dump_folder_path}"""							)
   image_processor.save_pretrained(lowerCAmelCase_							)


if __name__ == "__main__":
  a_								=    argparse.ArgumentParser()
  # Required parameters
  parser.add_argument(
      """--task""",
      default="""imagenet1k_256""",
      type=str,
      help=(
          """Name of the task for which the MobileViTV2 model you'd like to convert is trained on . """
          """
                Classification (ImageNet-1k)
                    - MobileViTV2 (256x256) : imagenet1k_256
                    - MobileViTV2 (Trained on 256x256 and Finetuned on 384x384) : imagenet1k_384
                    - MobileViTV2 (Trained on ImageNet-21k and Finetuned on ImageNet-1k 256x256) :
                      imagenet21k_to_1k_256
                    - MobileViTV2 (Trained on ImageNet-21k, Finetuned on ImageNet-1k 256x256, and Finetuned on
                      ImageNet-1k 384x384) : imagenet21k_to_1k_384
                Segmentation
                    - ADE20K Dataset : ade20k_deeplabv3
                    - Pascal VOC 2012 Dataset: voc_deeplabv3
            """
      ),
      choices=[
          """imagenet1k_256""",
          """imagenet1k_384""",
          """imagenet21k_to_1k_256""",
          """imagenet21k_to_1k_384""",
          """ade20k_deeplabv3""",
          """voc_deeplabv3""",
      ],
  )

  parser.add_argument(
      """--orig_checkpoint_path""", required=True, type=str, help="""Path to the original state dict (.pt file)."""
  )
  parser.add_argument("""--orig_config_path""", required=True, type=str, help="""Path to the original config file.""")
  parser.add_argument(
      """--pytorch_dump_folder_path""", required=True, type=str, help="""Path to the output PyTorch model directory."""
  )

  a_								=    parser.parse_args()
  convert_mobilevitva_checkpoint(
      args.task, args.orig_checkpoint_path, args.orig_config_path, args.pytorch_dump_folder_path
  )










from math import sqrt



def 	lowerCAmelCase       (						lowerCAmelCase_       )->       bool:
				assert isinstance(lowerCAmelCase_       ,      lowerCAmelCase_       ) and (
				    number >= 0
				), "'number' must been an int and positive"

				lowerCAmelCase_       :					List[Any]			 = True

				# 0 and 1 are none primes.
				if number <= 1:
								lowerCAmelCase_       :					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:
												lowerCAmelCase_       :					Tuple			 = False
												break

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

				return status



def 	lowerCAmelCase       (						lowerCAmelCase_       )->       Tuple:
				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_       :					Tuple			 = list(range(2       ,      n + 1       )       )

				lowerCAmelCase_       :					Optional[int]			 = []  # 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_       :					str			 = 0

    # filters actual prime numbers.
				lowerCAmelCase_       :					Optional[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_       )->       Optional[Any]:
				assert isinstance(lowerCAmelCase_       ,      lowerCAmelCase_       ) and (n > 2), "'N' must been an int and > 2"

				lowerCAmelCase_       :					List[Any]			 = []

				# 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_       )->       List[Any]:
				assert isinstance(lowerCAmelCase_       ,      lowerCAmelCase_       ) and number >= 0, "'number' must been an int and >= 0"

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

				# potential prime number factors.

				lowerCAmelCase_       :					List[Any]			 = 2

				lowerCAmelCase_       :					Optional[int]			 = 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]:
				assert isinstance(lowerCAmelCase_       ,      lowerCAmelCase_       ) and (
				    number >= 0
				), "'number' bust been an int and >= 0"

				lowerCAmelCase_       :					Dict			 = 0

				# prime factorization of 'number'
				lowerCAmelCase_       :					Any			 = prime_factorization(lowerCAmelCase_       )

				lowerCAmelCase_       :					Tuple			 = max(lowerCAmelCase_       )

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

				return ans



def 	lowerCAmelCase       (						lowerCAmelCase_       )->       int:
				assert isinstance(lowerCAmelCase_       ,      lowerCAmelCase_       ) and (
				    number >= 0
				), "'number' bust been an int and >= 0"

				lowerCAmelCase_       :					List[Any]			 = 0

				# prime factorization of 'number'
				lowerCAmelCase_       :					Dict			 = prime_factorization(lowerCAmelCase_       )

				lowerCAmelCase_       :					int			 = min(lowerCAmelCase_       )

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

				return ans



def 	lowerCAmelCase       (						lowerCAmelCase_       )->       Optional[Any]:
				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]:
				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[str]:
				assert (
				    isinstance(lowerCAmelCase_       ,      lowerCAmelCase_       ) and (number > 2) and is_even(lowerCAmelCase_       )
				), "'number' must been an int, even and > 2"

				lowerCAmelCase_       :					str			 = []  # this list will returned

				# creates a list of prime numbers between 2 up to 'number'
				lowerCAmelCase_       :					int			 = get_prime_numbers(lowerCAmelCase_       )
				lowerCAmelCase_       :					List[str]			 = len(lowerCAmelCase_       )

				# run variable for while-loops.
				lowerCAmelCase_       :					Union[str, Any]			 = 0
				lowerCAmelCase_       :					Tuple			 = None

				# exit variable. for break up the loops
				lowerCAmelCase_       :					int			 = True

				while i < len_pn and loop:
								lowerCAmelCase_       :					int			 = i + 1

								while j < len_pn and loop:
												if prime_numbers[i] + prime_numbers[j] == number:
																lowerCAmelCase_       :					Tuple			 = 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_       )->       Dict:
				assert (
				    isinstance(lowerCAmelCase_       ,      lowerCAmelCase_       )
				    and isinstance(lowerCAmelCase_       ,      lowerCAmelCase_       )
				    and (numbera >= 0)
				    and (numbera >= 0)
				), "'number1' and 'number2' must been positive integer."

				lowerCAmelCase_       :					int			 = 0

				while numbera != 0:
								lowerCAmelCase_       :					str			 = numbera % numbera
								lowerCAmelCase_       :					List[Any]			 = numbera
								lowerCAmelCase_       :					Any			 = rest

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

				return numbera



def 	lowerCAmelCase       (						lowerCAmelCase_       ,      lowerCAmelCase_       )->       Optional[int]:
				assert (
				    isinstance(lowerCAmelCase_       ,      lowerCAmelCase_       )
				    and isinstance(lowerCAmelCase_       ,      lowerCAmelCase_       )
				    and (numbera >= 1)
				    and (numbera >= 1)
				), "'number1' and 'number2' must been positive integer."

				lowerCAmelCase_       :					List[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'
								lowerCAmelCase_       :					int			 = prime_factorization(lowerCAmelCase_       )
								lowerCAmelCase_       :					int			 = prime_factorization(lowerCAmelCase_       )

				elif numbera == 1 or numbera == 1:
								lowerCAmelCase_       :					Union[str, Any]			 = []
								lowerCAmelCase_       :					List[str]			 = []
								lowerCAmelCase_       :					Union[str, Any]			 = max(lowerCAmelCase_       ,      lowerCAmelCase_       )

				lowerCAmelCase_       :					Optional[int]			 = 0
				lowerCAmelCase_       :					Dict			 = 0

				lowerCAmelCase_       :					Union[str, 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:
																lowerCAmelCase_       :					Optional[Any]			 = prime_fac_a.count(lowerCAmelCase_       )
																lowerCAmelCase_       :					Tuple			 = prime_fac_a.count(lowerCAmelCase_       )

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

												else:
																lowerCAmelCase_       :					List[str]			 = 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_       :					Optional[Any]			 = 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_       )->       int:
				assert isinstance(lowerCAmelCase_       ,      lowerCAmelCase_       ) and (n >= 0), "'number' must been a positive int"

				lowerCAmelCase_       :					List[Any]			 = 0
				lowerCAmelCase_       :					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_       ,      lowerCAmelCase_       )->       List[Any]:
				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_       :					Union[str, Any]			 = p_number_a + 1  # jump to the next number

				lowerCAmelCase_       :					Optional[int]			 = []  # 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_       )->       Tuple:
				assert isinstance(lowerCAmelCase_       ,      lowerCAmelCase_       ) and (n >= 1), "'n' must been int and >= 1"

				lowerCAmelCase_       :					List[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_       )->       List[Any]:
				assert isinstance(lowerCAmelCase_       ,      lowerCAmelCase_       ) and (
				    number > 1
				), "'number' must been an int and >= 1"

				lowerCAmelCase_       :					Union[str, Any]			 = 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_       )->       Union[str, Any]:
				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_       :					Optional[Any]			 = 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:
				assert isinstance(lowerCAmelCase_       ,      lowerCAmelCase_       ) and (n >= 0), "'n' must been a int and >= 0"

				lowerCAmelCase_       :					Any			 = 1  # this will be return.

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

				return ans




def 	lowerCAmelCase       (						lowerCAmelCase_       )->       int:
				assert isinstance(lowerCAmelCase_       ,      lowerCAmelCase_       ) and (n >= 0), "'n' must been an int and >= 0"

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

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

				return ans