





import gc
import unittest

import numpy as np
import torch
import torch.nn.functional as F
from transformers import (
    ClapTextConfig,
    ClapTextModelWithProjection,
    RobertaTokenizer,
    SpeechTaHifiGan,
    SpeechTaHifiGanConfig,
)

from diffusers import (
    AudioLDMPipeline,
    AutoencoderKL,
    DDIMScheduler,
    LMSDiscreteScheduler,
    PNDMScheduler,
    UNetaDConditionModel,
)
from diffusers.utils import is_xformers_available, slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism

from ..pipeline_params import TEXT_TO_AUDIO_BATCH_PARAMS, TEXT_TO_AUDIO_PARAMS
from ..test_pipelines_common import PipelineTesterMixin


enable_full_determinism()



class 					A__   (       __snake_case       ,   unittest.TestCase			):
      _UpperCAmelCase	:Union[str, Any]						    =   AudioLDMPipeline
      _UpperCAmelCase	:Any						    =   TEXT_TO_AUDIO_PARAMS
      _UpperCAmelCase	:Union[str, Any]						    =   TEXT_TO_AUDIO_BATCH_PARAMS
      _UpperCAmelCase	:List[str]						    =   frozenset(
          [
              'num_inference_steps',
              'num_waveforms_per_prompt',
              'generator',
              'latents',
              'output_type',
              'return_dict',
              'callback',
              'callback_steps',
          ]			)





      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       torch.manual_seed(0   )
       UpperCamelCase	:					Any       	=   UNetaDConditionModel(
           block_out_channels=(32, 64)       ,							layers_per_block=2       ,							sample_size=32       ,							in_channels=4       ,							out_channels=4       ,							down_block_types=("DownBlock2D", "CrossAttnDownBlock2D")       ,							up_block_types=("CrossAttnUpBlock2D", "UpBlock2D")       ,							cross_attention_dim=(32, 64)       ,							class_embed_type="simple_projection"       ,							projection_class_embeddings_input_dim=32       ,							class_embeddings_concat=A_       ,							)
       UpperCamelCase	:					int       	=   DDIMScheduler(
           beta_start=0.0_00_85       ,							beta_end=0.0_12       ,							beta_schedule="scaled_linear"       ,							clip_sample=A_       ,							set_alpha_to_one=A_       ,							)
       torch.manual_seed(0   )
       UpperCamelCase	:					List[str]       	=   AutoencoderKL(
           block_out_channels=[32, 64]       ,							in_channels=1       ,							out_channels=1       ,							down_block_types=["DownEncoderBlock2D", "DownEncoderBlock2D"]       ,							up_block_types=["UpDecoderBlock2D", "UpDecoderBlock2D"]       ,							latent_channels=4       ,							)
       torch.manual_seed(0   )
       UpperCamelCase	:					List[Any]       	=   ClapTextConfig(
           bos_token_id=0       ,							eos_token_id=2       ,							hidden_size=32       ,							intermediate_size=37       ,							layer_norm_eps=1e-05       ,							num_attention_heads=4       ,							num_hidden_layers=5       ,							pad_token_id=1       ,							vocab_size=1000       ,							projection_dim=32       ,							)
       UpperCamelCase	:					Union[str, Any]       	=   ClapTextModelWithProjection(A_   )
       UpperCamelCase	:					int       	=   RobertaTokenizer.from_pretrained("hf-internal-testing/tiny-random-roberta"       ,							model_max_length=77   )

       UpperCamelCase	:					Dict       	=   SpeechTaHifiGanConfig(
           model_in_dim=8       ,							sampling_rate=1_6000       ,							upsample_initial_channel=16       ,							upsample_rates=[2, 2]       ,							upsample_kernel_sizes=[4, 4]       ,							resblock_kernel_sizes=[3, 7]       ,							resblock_dilation_sizes=[[1, 3, 5], [1, 3, 5]]       ,							normalize_before=A_       ,							)

       UpperCamelCase	:					Optional[int]       	=   SpeechTaHifiGan(A_   )

       UpperCamelCase	:					str       	=   {
           "unet": unet,
           "scheduler": scheduler,
           "vae": vae,
           "text_encoder": text_encoder,
           "tokenizer": tokenizer,
           "vocoder": vocoder,
       }
       return components





      def        __UpperCamelCase( self       ,							A_       ,							A_=0   ):
       '''simple docstring'''




       if str(A_   ).startswith("mps"   ):
        UpperCamelCase	:					int       	=   torch.manual_seed(A_   )
       else:
        UpperCamelCase	:					List[Any]       	=   torch.Generator(device=A_   ).manual_seed(A_   )
       UpperCamelCase	:					List[str]       	=   {
           "prompt": "A hammer hitting a wooden surface",
           "generator": generator,
           "num_inference_steps": 2,
           "guidance_scale": 6.0,
       }
       return inputs





      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       UpperCamelCase	:					Optional[int]       	=   "cpu"  # ensure determinism for the device-dependent torch.Generator

       UpperCamelCase	:					Optional[Any]       	=   self.get_dummy_components()
       UpperCamelCase	:					Any       	=   AudioLDMPipeline(**A_   )
       UpperCamelCase	:					Tuple       	=   audioldm_pipe.to(A_   )
       audioldm_pipe.set_progress_bar_config(disable=A_   )

       UpperCamelCase	:					Union[str, Any]       	=   self.get_dummy_inputs(A_   )
       UpperCamelCase	:					List[str]       	=   audioldm_pipe(**A_   )
       UpperCamelCase	:					str       	=   output.audios[0]

       assert audio.ndim == 1
       assert len(A_   ) == 256

       UpperCamelCase	:					str       	=   audio[:10]
       UpperCamelCase	:					Dict       	=   np.array(
           [-0.00_50, 0.00_50, -0.00_60, 0.00_33, -0.00_26, 0.00_33, -0.00_27, 0.00_33, -0.00_28, 0.00_33]   )

       assert np.abs(audio_slice - expected_slice   ).max() < 1e-2





      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       UpperCamelCase	:					Optional[Any]       	=   self.get_dummy_components()
       UpperCamelCase	:					Tuple       	=   AudioLDMPipeline(**A_   )
       UpperCamelCase	:					Dict       	=   audioldm_pipe.to(A_   )
       UpperCamelCase	:					Tuple       	=   audioldm_pipe.to(A_   )
       audioldm_pipe.set_progress_bar_config(disable=A_   )

       UpperCamelCase	:					List[str]       	=   self.get_dummy_inputs(A_   )
       UpperCamelCase	:					List[Any]       	=   3 * [inputs["prompt"]]

       # forward
       UpperCamelCase	:					Any       	=   audioldm_pipe(**A_   )
       UpperCamelCase	:					List[str]       	=   output.audios[0]

       UpperCamelCase	:					str       	=   self.get_dummy_inputs(A_   )
       UpperCamelCase	:					Any       	=   3 * [inputs.pop("prompt"   )]

       UpperCamelCase	:					Any       	=   audioldm_pipe.tokenizer(
           A_       ,							padding="max_length"       ,							max_length=audioldm_pipe.tokenizer.model_max_length       ,							truncation=A_       ,							return_tensors="pt"       ,							)
       UpperCamelCase	:					Dict       	=   text_inputs["input_ids"].to(A_   )

       UpperCamelCase	:					Union[str, Any]       	=   audioldm_pipe.text_encoder(
           A_       ,							)
       UpperCamelCase	:					int       	=   prompt_embeds.text_embeds
       # additional L_2 normalization over each hidden-state
       UpperCamelCase	:					List[str]       	=   F.normalize(A_       ,							dim=-1   )

       UpperCamelCase	:					Any       	=   prompt_embeds

       # forward
       UpperCamelCase	:					List[Any]       	=   audioldm_pipe(**A_   )
       UpperCamelCase	:					Tuple       	=   output.audios[0]

       assert np.abs(audio_a - audio_a   ).max() < 1e-2





      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       UpperCamelCase	:					Any       	=   self.get_dummy_components()
       UpperCamelCase	:					int       	=   AudioLDMPipeline(**A_   )
       UpperCamelCase	:					Union[str, Any]       	=   audioldm_pipe.to(A_   )
       UpperCamelCase	:					Dict       	=   audioldm_pipe.to(A_   )
       audioldm_pipe.set_progress_bar_config(disable=A_   )

       UpperCamelCase	:					List[Any]       	=   self.get_dummy_inputs(A_   )
       UpperCamelCase	:					int       	=   3 * ["this is a negative prompt"]
       UpperCamelCase	:					Optional[int]       	=   negative_prompt
       UpperCamelCase	:					List[Any]       	=   3 * [inputs["prompt"]]

       # forward
       UpperCamelCase	:					Optional[Any]       	=   audioldm_pipe(**A_   )
       UpperCamelCase	:					Dict       	=   output.audios[0]

       UpperCamelCase	:					Union[str, Any]       	=   self.get_dummy_inputs(A_   )
       UpperCamelCase	:					Optional[int]       	=   3 * [inputs.pop("prompt"   )]

       UpperCamelCase	:					Any       	=   []
       for p in [prompt, negative_prompt]:
        UpperCamelCase	:					Optional[Any]       	=   audioldm_pipe.tokenizer(
            A_       ,							padding="max_length"       ,							max_length=audioldm_pipe.tokenizer.model_max_length       ,							truncation=A_       ,							return_tensors="pt"       ,							)
        UpperCamelCase	:					List[Any]       	=   text_inputs["input_ids"].to(A_   )

        UpperCamelCase	:					Optional[int]       	=   audioldm_pipe.text_encoder(
            A_       ,							)
        UpperCamelCase	:					str       	=   text_embeds.text_embeds
        # additional L_2 normalization over each hidden-state
        UpperCamelCase	:					Any       	=   F.normalize(A_       ,							dim=-1   )

        embeds.append(A_   )

       UpperCamelCase	,    UpperCamelCase	:					Any       	=   embeds

       # forward
       UpperCamelCase	:					Tuple       	=   audioldm_pipe(**A_   )
       UpperCamelCase	:					Dict       	=   output.audios[0]

       assert np.abs(audio_a - audio_a   ).max() < 1e-2





      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       UpperCamelCase	:					List[Any]       	=   "cpu"  # ensure determinism for the device-dependent torch.Generator
       UpperCamelCase	:					Tuple       	=   self.get_dummy_components()
       UpperCamelCase	:					Dict       	=   PNDMScheduler(skip_prk_steps=A_   )
       UpperCamelCase	:					List[str]       	=   AudioLDMPipeline(**A_   )
       UpperCamelCase	:					List[Any]       	=   audioldm_pipe.to(A_   )
       audioldm_pipe.set_progress_bar_config(disable=A_   )

       UpperCamelCase	:					List[Any]       	=   self.get_dummy_inputs(A_   )
       UpperCamelCase	:					int       	=   "egg cracking"
       UpperCamelCase	:					List[Any]       	=   audioldm_pipe(**A_       ,							negative_prompt=A_   )
       UpperCamelCase	:					Any       	=   output.audios[0]

       assert audio.ndim == 1
       assert len(A_   ) == 256

       UpperCamelCase	:					List[str]       	=   audio[:10]
       UpperCamelCase	:					Dict       	=   np.array(
           [-0.00_51, 0.00_50, -0.00_60, 0.00_34, -0.00_26, 0.00_33, -0.00_27, 0.00_33, -0.00_28, 0.00_32]   )

       assert np.abs(audio_slice - expected_slice   ).max() < 1e-2





      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       UpperCamelCase	:					List[Any]       	=   "cpu"  # ensure determinism for the device-dependent torch.Generator
       UpperCamelCase	:					Tuple       	=   self.get_dummy_components()
       UpperCamelCase	:					Union[str, Any]       	=   PNDMScheduler(skip_prk_steps=A_   )
       UpperCamelCase	:					Union[str, Any]       	=   AudioLDMPipeline(**A_   )
       UpperCamelCase	:					int       	=   audioldm_pipe.to(A_   )
       audioldm_pipe.set_progress_bar_config(disable=A_   )

       UpperCamelCase	:					Optional[int]       	=   "A hammer hitting a wooden surface"

       # test num_waveforms_per_prompt=1 (default)
       UpperCamelCase	:					Optional[Any]       	=   audioldm_pipe(A_       ,							num_inference_steps=2   ).audios

       assert audios.shape == (1, 256)

       # test num_waveforms_per_prompt=1 (default) for batch of prompts
       UpperCamelCase	:					int       	=   2
       UpperCamelCase	:					List[Any]       	=   audioldm_pipe([prompt] * batch_size       ,							num_inference_steps=2   ).audios

       assert audios.shape == (batch_size, 256)

       # test num_waveforms_per_prompt for single prompt
       UpperCamelCase	:					Any       	=   2
       UpperCamelCase	:					List[Any]       	=   audioldm_pipe(A_       ,							num_inference_steps=2       ,							num_waveforms_per_prompt=A_   ).audios

       assert audios.shape == (num_waveforms_per_prompt, 256)

       # test num_waveforms_per_prompt for batch of prompts
       UpperCamelCase	:					Any       	=   2
       UpperCamelCase	:					Dict       	=   audioldm_pipe(
           [prompt] * batch_size       ,							num_inference_steps=2       ,							num_waveforms_per_prompt=A_   ).audios

       assert audios.shape == (batch_size * num_waveforms_per_prompt, 256)





      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       UpperCamelCase	:					Optional[int]       	=   "cpu"  # ensure determinism for the device-dependent torch.Generator
       UpperCamelCase	:					Dict       	=   self.get_dummy_components()
       UpperCamelCase	:					List[Any]       	=   AudioLDMPipeline(**A_   )
       UpperCamelCase	:					Optional[int]       	=   audioldm_pipe.to(A_   )
       audioldm_pipe.set_progress_bar_config(disable=A_   )
       UpperCamelCase	:					Tuple       	=   audioldm_pipe.vocoder.config.sampling_rate

       UpperCamelCase	:					Union[str, Any]       	=   self.get_dummy_inputs(A_   )
       UpperCamelCase	:					List[Any]       	=   audioldm_pipe(audio_length_in_s=0.0_16       ,							**A_   )
       UpperCamelCase	:					List[str]       	=   output.audios[0]

       assert audio.ndim == 1
       assert len(A_   ) / vocoder_sampling_rate == 0.0_16

       UpperCamelCase	:					List[Any]       	=   audioldm_pipe(audio_length_in_s=0.0_32       ,							**A_   )
       UpperCamelCase	:					Tuple       	=   output.audios[0]

       assert audio.ndim == 1
       assert len(A_   ) / vocoder_sampling_rate == 0.0_32





      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       UpperCamelCase	:					Union[str, Any]       	=   self.get_dummy_components()
       UpperCamelCase	:					int       	=   AudioLDMPipeline(**A_   )
       UpperCamelCase	:					List[str]       	=   audioldm_pipe.to(A_   )
       audioldm_pipe.set_progress_bar_config(disable=A_   )

       UpperCamelCase	:					int       	=   ["hey"]

       UpperCamelCase	:					str       	=   audioldm_pipe(A_       ,							num_inference_steps=1   )
       UpperCamelCase	:					Optional[int]       	=   output.audios.shape
       assert audio_shape == (1, 256)

       UpperCamelCase	:					Optional[Any]       	=   audioldm_pipe.vocoder.config
       config.model_in_dim *= 2
       UpperCamelCase	:					Tuple       	=   SpeechTaHifiGan(A_   ).to(A_   )
       UpperCamelCase	:					List[Any]       	=   audioldm_pipe(A_       ,							num_inference_steps=1   )
       UpperCamelCase	:					int       	=   output.audios.shape
       # waveform shape is unchanged, we just have 2x the number of mel channels in the spectrogram
       assert audio_shape == (1, 256)





      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       self._test_attention_slicing_forward_pass(test_mean_pixel_difference=A_   )





      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       self._test_inference_batch_single_identical(test_mean_pixel_difference=A_   )





      @unittest.skipIf(
          torch_device != "cuda" or not is_xformers_available()       ,							reason="XFormers attention is only available with CUDA and `xformers` installed"       ,							)
      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       self._test_xformers_attention_forwardGenerator_pass(test_mean_pixel_difference=A_   )



@slow
class 					A__   (       unittest.TestCase			):





      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       super().tearDown()
       gc.collect()
       torch.cuda.empty_cache()





      def        __UpperCamelCase( self       ,							A_       ,							A_="cpu"       ,							A_=torch.floataa       ,							A_=0   ):
       '''simple docstring'''




       UpperCamelCase	:					List[str]       	=   torch.Generator(device=A_   ).manual_seed(A_   )
       UpperCamelCase	:					Dict       	=   np.random.RandomState(A_   ).standard_normal((1, 8, 128, 16)   )
       UpperCamelCase	:					Optional[Any]       	=   torch.from_numpy(A_   ).to(device=A_       ,							dtype=A_   )
       UpperCamelCase	:					List[str]       	=   {
           "prompt": "A hammer hitting a wooden surface",
           "latents": latents,
           "generator": generator,
           "num_inference_steps": 3,
           "guidance_scale": 2.5,
       }
       return inputs





      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       UpperCamelCase	:					str       	=   AudioLDMPipeline.from_pretrained("cvssp/audioldm"   )
       UpperCamelCase	:					List[Any]       	=   audioldm_pipe.to(A_   )
       audioldm_pipe.set_progress_bar_config(disable=A_   )

       UpperCamelCase	:					Optional[Any]       	=   self.get_inputs(A_   )
       UpperCamelCase	:					Optional[int]       	=   25
       UpperCamelCase	:					Dict       	=   audioldm_pipe(**A_   ).audios[0]

       assert audio.ndim == 1
       assert len(A_   ) == 8_1920

       UpperCamelCase	:					int       	=   audio[7_7230:7_7240]
       UpperCamelCase	:					Dict       	=   np.array(
           [-0.48_84, -0.46_07, 0.00_23, 0.50_07, 0.58_96, 0.51_51, 0.38_13, -0.02_08, -0.36_87, -0.43_15]   )
       UpperCamelCase	:					Tuple       	=   np.abs(expected_slice - audio_slice   ).max()
       assert max_diff < 1e-2





      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       UpperCamelCase	:					Tuple       	=   AudioLDMPipeline.from_pretrained("cvssp/audioldm"   )
       UpperCamelCase	:					Tuple       	=   LMSDiscreteScheduler.from_config(audioldm_pipe.scheduler.config   )
       UpperCamelCase	:					Optional[Any]       	=   audioldm_pipe.to(A_   )
       audioldm_pipe.set_progress_bar_config(disable=A_   )

       UpperCamelCase	:					int       	=   self.get_inputs(A_   )
       UpperCamelCase	:					Optional[int]       	=   audioldm_pipe(**A_   ).audios[0]

       assert audio.ndim == 1
       assert len(A_   ) == 8_1920

       UpperCamelCase	:					Optional[int]       	=   audio[2_7780:2_7790]
       UpperCamelCase	:					List[Any]       	=   np.array([-0.21_31, -0.08_73, -0.01_24, -0.01_89, 0.05_69, 0.13_73, 0.18_83, 0.28_86, 0.32_97, 0.22_12]   )
       UpperCamelCase	:					List[str]       	=   np.abs(expected_slice - audio_slice   ).max()
       assert max_diff < 3e-2







from math import sqrt



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

 UpperCamelCase	:					List[Any]       	=   True

 # 0 and 1 are none primes.
 if number <= 1:
  UpperCamelCase	:					List[Any]       	=   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:
   UpperCamelCase	:					Union[str, Any]       	=   False
   break

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

 return status



def 		A_				(     _lowerCAmelCase     )						-> Any:
 assert isinstance(_lowerCAmelCase							,   _lowerCAmelCase     ) and (n > 2), "'N' must been an int and > 2"

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

 UpperCamelCase	:					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):
    UpperCamelCase	:					Tuple       	=   0

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

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

 return ans



def 		A_				(     _lowerCAmelCase     )						-> Optional[Any]:
 assert isinstance(_lowerCAmelCase							,   _lowerCAmelCase     ) and (n > 2), "'N' must been an int and > 2"

 UpperCamelCase	:					str       	=   []

 # 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 		A_				(     _lowerCAmelCase     )						-> Any:
 assert isinstance(_lowerCAmelCase							,   _lowerCAmelCase     ) and number >= 0, "'number' must been an int and >= 0"

 UpperCamelCase	:					Optional[Any]       	=   []  # this list will be returns of the function.

 # potential prime number factors.

 UpperCamelCase	:					Tuple       	=   2

 UpperCamelCase	:					str       	=   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 		A_				(     _lowerCAmelCase     )						-> Any:
 assert isinstance(_lowerCAmelCase							,   _lowerCAmelCase     ) and (
     number >= 0
 ), "'number' bust been an int and >= 0"

 UpperCamelCase	:					List[Any]       	=   0

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

 UpperCamelCase	:					List[Any]       	=   max(_lowerCAmelCase     )

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

 return ans



def 		A_				(     _lowerCAmelCase     )						-> Union[str, Any]:
 assert isinstance(_lowerCAmelCase							,   _lowerCAmelCase     ) and (
     number >= 0
 ), "'number' bust been an int and >= 0"

 UpperCamelCase	:					List[Any]       	=   0

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

 UpperCamelCase	:					List[Any]       	=   min(_lowerCAmelCase     )

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

 return ans



def 		A_				(     _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 		A_				(     _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 		A_				(     _lowerCAmelCase     )						-> Any:
 assert (
     isinstance(_lowerCAmelCase							,   _lowerCAmelCase     ) and (number > 2) and is_even(_lowerCAmelCase     )
 ), "'number' must been an int, even and > 2"

 UpperCamelCase	:					List[str]       	=   []  # this list will returned

 # creates a list of prime numbers between 2 up to 'number'
 UpperCamelCase	:					Dict       	=   get_prime_numbers(_lowerCAmelCase     )
 UpperCamelCase	:					Tuple       	=   len(_lowerCAmelCase     )

 # run variable for while-loops.
 UpperCamelCase	:					Optional[int]       	=   0
 UpperCamelCase	:					int       	=   None

 # exit variable. for break up the loops
 UpperCamelCase	:					Union[str, Any]       	=   True

 while i < len_pn and loop:
  UpperCamelCase	:					Tuple       	=   i + 1

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

 UpperCamelCase	:					Tuple       	=   0

 while numbera != 0:
  UpperCamelCase	:					Tuple       	=   numbera % numbera
  UpperCamelCase	:					Any       	=   numbera
  UpperCamelCase	:					Union[str, Any]       	=   rest

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

 return numbera



def 		A_				(     _lowerCAmelCase							,   _lowerCAmelCase     )						-> int:
 assert (
     isinstance(_lowerCAmelCase							,   _lowerCAmelCase     )
     and isinstance(_lowerCAmelCase							,   _lowerCAmelCase     )
     and (numbera >= 1)
     and (numbera >= 1)
 ), "'number1' and 'number2' must been positive integer."

 UpperCamelCase	:					Optional[int]       	=   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'
  UpperCamelCase	:					List[Any]       	=   prime_factorization(_lowerCAmelCase     )
  UpperCamelCase	:					Union[str, Any]       	=   prime_factorization(_lowerCAmelCase     )

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

 UpperCamelCase	:					Optional[int]       	=   0
 UpperCamelCase	:					Tuple       	=   0

 UpperCamelCase	:					List[str]       	=   []  # 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:
    UpperCamelCase	:					str       	=   prime_fac_a.count(_lowerCAmelCase     )
    UpperCamelCase	:					Tuple       	=   prime_fac_a.count(_lowerCAmelCase     )

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

   else:
    UpperCamelCase	:					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:
   UpperCamelCase	:					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 		A_				(     _lowerCAmelCase     )						-> Tuple:
 assert isinstance(_lowerCAmelCase							,   _lowerCAmelCase     ) and (n >= 0), "'number' must been a positive int"

 UpperCamelCase	:					int       	=   0
 UpperCamelCase	:					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 		A_				(     _lowerCAmelCase							,   _lowerCAmelCase     )						-> int:
 assert (
     is_prime(_lowerCAmelCase     ) and is_prime(_lowerCAmelCase     ) and (p_number_a < p_number_a)
 ), "The arguments must been prime numbers and 'pNumber1' < 'pNumber2'"

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

 UpperCamelCase	:					Dict       	=   []  # 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 		A_				(     _lowerCAmelCase     )						-> List[str]:
 assert isinstance(_lowerCAmelCase							,   _lowerCAmelCase     ) and (n >= 1), "'n' must been int and >= 1"

 UpperCamelCase	:					Dict       	=   []  # 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 		A_				(     _lowerCAmelCase     )						-> int:
 assert isinstance(_lowerCAmelCase							,   _lowerCAmelCase     ) and (
     number > 1
 ), "'number' must been an int and >= 1"

 UpperCamelCase	:					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 		A_				(     _lowerCAmelCase							,   _lowerCAmelCase     )						-> Optional[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.
 UpperCamelCase	:					List[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 		A_				(     _lowerCAmelCase     )						-> Dict:
 assert isinstance(_lowerCAmelCase							,   _lowerCAmelCase     ) and (n >= 0), "'n' must been a int and >= 0"

 UpperCamelCase	:					str       	=   1  # this will be return.

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

 return ans



def 		A_				(     _lowerCAmelCase     )						-> Tuple:
 assert isinstance(_lowerCAmelCase							,   _lowerCAmelCase     ) and (n >= 0), "'n' must been an int and >= 0"

 UpperCamelCase	:					Dict       	=   0
 UpperCamelCase	:					Dict       	=   1
 UpperCamelCase	:					Union[str, Any]       	=   1  # this will be return

 for _ in range(n - 1     ):
  UpperCamelCase	:					Any       	=   ans
  ans += fiba
  UpperCamelCase	:					str       	=   tmp

 return ans
