



from math import sqrt
def 		UpperCamelCase	(   snake_case__       :    int	)	->     bool:
   assert isinstance(snake_case__       ,     snake_case__	) and (
       number >= 0
   ), "'number' must been an int and positive"

   UpperCamelCase    :  int							=	True

   # 0 and 1 are none primes.
   if number <= 1:
      UpperCamelCase    :  Union[str, Any]							=	False

   for divisor in range(2       ,     int(round(sqrt(snake_case__	)	)	) + 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(snake_case__       ,     snake_case__	), "'status' must been from type bool"

   return status
def 		UpperCamelCase	(   snake_case__       :    Tuple	)	->     str:
   assert isinstance(snake_case__       ,     snake_case__	) and (n > 2), "'N' must been an int and > 2"

   # beginList: contains all natural numbers from 2 up to N
   UpperCamelCase    :  Union[str, Any]							=	list(range(2       ,     n + 1	)	)

   UpperCamelCase    :  Union[str, Any]							=	[]  # this list will be returns.

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

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

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

   return ans
def 		UpperCamelCase	(   snake_case__       :    List[str]	)	->     List[Any]:
   assert isinstance(snake_case__       ,     snake_case__	) and (n > 2), "'N' must been an int and > 2"

   UpperCamelCase    :  List[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(snake_case__	):
         ans.append(snake_case__	)

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

   return ans
def 		UpperCamelCase	(   snake_case__       :    Union[str, Any]	)	->     int:
   assert isinstance(snake_case__       ,     snake_case__	) and number >= 0, "'number' must been an int and >= 0"

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

   # potential prime number factors.

   UpperCamelCase    :  List[str]							=	2

   UpperCamelCase    :  str							=	number

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

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

   else:
      ans.append(snake_case__	)

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

   return ans
def 		UpperCamelCase	(   snake_case__       :    Optional[Any]	)	->     Tuple:
   assert isinstance(snake_case__       ,     snake_case__	) and (
       number >= 0
   ), "'number' bust been an int and >= 0"

   UpperCamelCase    :  Optional[Any]							=	0

   # prime factorization of 'number'
   UpperCamelCase    :  List[str]							=	prime_factorization(snake_case__	)

   UpperCamelCase    :  Optional[int]							=	max(snake_case__	)

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

   return ans
def 		UpperCamelCase	(   snake_case__       :    Union[str, Any]	)	->     Dict:
   assert isinstance(snake_case__       ,     snake_case__	) and (
       number >= 0
   ), "'number' bust been an int and >= 0"

   UpperCamelCase    :  List[str]							=	0

   # prime factorization of 'number'
   UpperCamelCase    :  List[str]							=	prime_factorization(snake_case__	)

   UpperCamelCase    :  int							=	min(snake_case__	)

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

   return ans
def 		UpperCamelCase	(   snake_case__       :    List[str]	)	->     Tuple:
   assert isinstance(snake_case__       ,     snake_case__	), "'number' must been an int"
   assert isinstance(number % 2 == 0       ,     snake_case__	), "compare bust been from type bool"

   return number % 2 == 0
def 		UpperCamelCase	(   snake_case__       :    str	)	->     int:
   assert isinstance(snake_case__       ,     snake_case__	), "'number' must been an int"
   assert isinstance(number % 2 != 0       ,     snake_case__	), "compare bust been from type bool"

   return number % 2 != 0
def 		UpperCamelCase	(   snake_case__       :    Optional[int]	)	->     Optional[Any]:
   assert (
       isinstance(snake_case__       ,     snake_case__	) and (number > 2) and is_even(snake_case__	)
   ), "'number' must been an int, even and > 2"

   UpperCamelCase    :  str							=	[]  # this list will returned

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

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

   # exit variable. for break up the loops
   UpperCamelCase    :  Optional[int]							=	True

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

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

         j += 1

      i += 1

   # precondition
   assert (
       isinstance(snake_case__       ,     snake_case__	)
       and (len(snake_case__	) == 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 		UpperCamelCase	(   snake_case__       :    List[str]       ,     snake_case__       :    Optional[Any]	)	->     str:
   assert (
       isinstance(snake_case__       ,     snake_case__	)
       and isinstance(snake_case__       ,     snake_case__	)
       and (numbera >= 0)
       and (numbera >= 0)
   ), "'number1' and 'number2' must been positive integer."

   UpperCamelCase    :  str							=	0

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

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

   return numbera
def 		UpperCamelCase	(   snake_case__       :    List[Any]       ,     snake_case__       :    int	)	->     Union[str, Any]:
   assert (
       isinstance(snake_case__       ,     snake_case__	)
       and isinstance(snake_case__       ,     snake_case__	)
       and (numbera >= 1)
       and (numbera >= 1)
   ), "'number1' and 'number2' must been positive integer."

   UpperCamelCase    :  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'
      UpperCamelCase    :  List[Any]							=	prime_factorization(snake_case__	)
      UpperCamelCase    :  Tuple							=	prime_factorization(snake_case__	)

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

   UpperCamelCase    :  List[str]							=	0
   UpperCamelCase    :  Any							=	0

   UpperCamelCase    :  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:
            UpperCamelCase    :  Optional[Any]							=	prime_fac_a.count(snake_case__	)
            UpperCamelCase    :  Tuple							=	prime_fac_a.count(snake_case__	)

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

         else:
            UpperCamelCase    :  Dict							=	prime_fac_a.count(snake_case__	)

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

         done.append(snake_case__	)

    # iterates through primeFac2
   for n in prime_fac_a:
      if n not in done:
         UpperCamelCase    :  Any							=	prime_fac_a.count(snake_case__	)

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

         done.append(snake_case__	)

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

   return ans
def 		UpperCamelCase	(   snake_case__       :    str	)	->     Optional[Any]:
   assert isinstance(snake_case__       ,     snake_case__	) and (n >= 0), "'number' must been a positive int"

   UpperCamelCase    :  Optional[int]							=	0
   UpperCamelCase    :  Any							=	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(snake_case__	):
         ans += 1

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

   return ans
def 		UpperCamelCase	(   snake_case__       :    Any       ,     snake_case__       :    List[Any]	)	->     List[str]:
   assert (
       is_prime(snake_case__	) and is_prime(snake_case__	) and (p_number_a < p_number_a)
   ), "The arguments must been prime numbers and 'pNumber1' < 'pNumber2'"

   UpperCamelCase    :  Optional[int]							=	p_number_a + 1  # jump to the next number

   UpperCamelCase    :  str							=	[]  # this list will be returns.

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

   while number < p_number_a:
      ans.append(snake_case__	)

      number += 1

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

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

   # 'ans' contains not 'pNumber1' and 'pNumber2' !
   return ans
def 		UpperCamelCase	(   snake_case__       :    int	)	->     Tuple:
   assert isinstance(snake_case__       ,     snake_case__	) and (n >= 1), "'n' must been int and >= 1"

   UpperCamelCase    :  Tuple							=	[]  # will be returned.

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

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

   return ans
def 		UpperCamelCase	(   snake_case__       :    Optional[Any]	)	->     str:
   assert isinstance(snake_case__       ,     snake_case__	) and (
       number > 1
   ), "'number' must been an int and >= 1"

   UpperCamelCase    :  Tuple							=	get_divisors(snake_case__	)

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

   # summed all divisors up to 'number' (exclusive), hence [:-1]
   return sum(divisors[:-1]	) == number
def 		UpperCamelCase	(   snake_case__       :    Tuple       ,     snake_case__       :    List[str]	)	->     int:
   assert (
       isinstance(snake_case__       ,     snake_case__	)
       and isinstance(snake_case__       ,     snake_case__	)
       and (denominator != 0)
   ), "The arguments must been from type int and 'denominator' != 0"

   # build the greatest common divisor of numerator and denominator.
   UpperCamelCase    :  Optional[Any]							=	gcd(abs(snake_case__	)       ,     abs(snake_case__	)	)

   # precondition
   assert (
       isinstance(snake_case__       ,     snake_case__	)
       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 		UpperCamelCase	(   snake_case__       :    Any	)	->     Optional[Any]:
   assert isinstance(snake_case__       ,     snake_case__	) and (n >= 0), "'n' must been a int and >= 0"

   UpperCamelCase    :  List[Any]							=	1  # this will be return.

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

   return ans


def 		UpperCamelCase	(   snake_case__       :    str	)	->     str:
   assert isinstance(snake_case__       ,     snake_case__	) and (n >= 0), "'n' must been an int and >= 0"

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

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

   return ans








import gc
import random
import unittest

import numpy as np
import torch
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer

import diffusers
from diffusers import (
    AutoencoderKL,
    EulerDiscreteScheduler,
    StableDiffusionLatentUpscalePipeline,
    StableDiffusionPipeline,
    UNetaDConditionModel,
)
from diffusers.schedulers import KarrasDiffusionSchedulers
from diffusers.utils import floats_tensor, load_image, load_numpy, slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu

from ..pipeline_params import TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_PARAMS
from ..test_pipelines_common import PipelineKarrasSchedulerTesterMixin, PipelineLatentTesterMixin, PipelineTesterMixin


enable_full_determinism()
def 		UpperCamelCase	(   snake_case__       :    Tuple	)	->     List[str]:
   UpperCamelCase    :  Optional[Any]							=	[tensor.shape for tensor in tensor_list]
   return all(shape == shapes[0] for shape in shapes[1:]	)



class 				lowerCAmelCase_		(  a__       ,    a__       ,    a__       ,    unittest.TestCase							):
       UpperCAmelCase__				:					str        =  StableDiffusionLatentUpscalePipeline
       UpperCAmelCase__				:					Optional[Any]        =  TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {
           "height",
           "width",
           "cross_attention_kwargs",
           "negative_prompt_embeds",
           "prompt_embeds",
       }
       UpperCAmelCase__				:					str        =  PipelineTesterMixin.required_optional_params - {"num_images_per_prompt"}
       UpperCAmelCase__				:					Any        =  TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
       UpperCAmelCase__				:					List[str]        =  frozenset(
           []							)  # TO-DO: update image_params once pipeline is refactored with VaeImageProcessor.preprocess
       UpperCAmelCase__				:					Union[str, Any]        =  frozenset([]							)

       UpperCAmelCase__				:					Optional[int]        =  True
       @property
       def 					snake_case_       (			self       )     ->		Union[str, Any]:
          UpperCamelCase    :  List[Any]							=	1
          UpperCamelCase    :  List[str]							=	4
          UpperCamelCase    :  List[str]							=	(16, 16)

          UpperCamelCase    :  Optional[int]							=	floats_tensor((batch_size, num_channels) + sizes,			rng=random.Random(0       )       ).to(SCREAMING_SNAKE_CASE_       )
          return image
       def 					snake_case_       (			self       )     ->		int:
          torch.manual_seed(0       )
          UpperCamelCase    :  int							=	UNetaDConditionModel(
              act_fn='gelu',			attention_head_dim=8,			norm_num_groups=SCREAMING_SNAKE_CASE_,			block_out_channels=[32, 32, 64, 64],			time_cond_proj_dim=160,			conv_in_kernel=1,			conv_out_kernel=1,			cross_attention_dim=32,			down_block_types=(
                  'KDownBlock2D',
                  'KCrossAttnDownBlock2D',
                  'KCrossAttnDownBlock2D',
                  'KCrossAttnDownBlock2D',
              ),			in_channels=8,			mid_block_type=SCREAMING_SNAKE_CASE_,			only_cross_attention=SCREAMING_SNAKE_CASE_,			out_channels=5,			resnet_time_scale_shift='scale_shift',			time_embedding_type='fourier',			timestep_post_act='gelu',			up_block_types=('KCrossAttnUpBlock2D', 'KCrossAttnUpBlock2D', 'KCrossAttnUpBlock2D', 'KUpBlock2D'),			)
          UpperCamelCase    :  Tuple							=	AutoencoderKL(
              block_out_channels=[32, 32, 64, 64],			in_channels=3,			out_channels=3,			down_block_types=[
                  'DownEncoderBlock2D',
                  'DownEncoderBlock2D',
                  'DownEncoderBlock2D',
                  'DownEncoderBlock2D',
              ],			up_block_types=['UpDecoderBlock2D', 'UpDecoderBlock2D', 'UpDecoderBlock2D', 'UpDecoderBlock2D'],			latent_channels=4,			)
          UpperCamelCase    :  Tuple							=	EulerDiscreteScheduler(prediction_type='sample'       )
          UpperCamelCase    :  Optional[int]							=	CLIPTextConfig(
              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,			hidden_act='quick_gelu',			projection_dim=512,			)
          UpperCamelCase    :  Any							=	CLIPTextModel(SCREAMING_SNAKE_CASE_       )
          UpperCamelCase    :  Union[str, Any]							=	CLIPTokenizer.from_pretrained('hf-internal-testing/tiny-random-clip'       )

          UpperCamelCase    :  Optional[int]							=	{
              'unet': model.eval(),
              'vae': vae.eval(),
              'scheduler': scheduler,
              'text_encoder': text_encoder,
              'tokenizer': tokenizer,
          }

          return components
       def 					snake_case_       (			self,			SCREAMING_SNAKE_CASE_,			SCREAMING_SNAKE_CASE_=0       )     ->		List[str]:
          if str(SCREAMING_SNAKE_CASE_       ).startswith('mps'       ):
             UpperCamelCase    :  List[str]							=	torch.manual_seed(SCREAMING_SNAKE_CASE_       )
          else:
             UpperCamelCase    :  Optional[Any]							=	torch.Generator(device=SCREAMING_SNAKE_CASE_       ).manual_seed(SCREAMING_SNAKE_CASE_       )
          UpperCamelCase    :  List[str]							=	{
              'prompt': 'A painting of a squirrel eating a burger',
              'image': self.dummy_image.cpu(),
              'generator': generator,
              'num_inference_steps': 2,
              'output_type': 'numpy',
          }
          return inputs
       def 					snake_case_       (			self       )     ->		List[Any]:
          UpperCamelCase    :  str							=	'cpu'

          UpperCamelCase    :  Tuple							=	self.get_dummy_components()
          UpperCamelCase    :  Dict							=	self.pipeline_class(**SCREAMING_SNAKE_CASE_       )
          pipe.to(SCREAMING_SNAKE_CASE_       )
          pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE_       )

          UpperCamelCase    :  Union[str, Any]							=	self.get_dummy_inputs(SCREAMING_SNAKE_CASE_       )
          UpperCamelCase    :  List[Any]							=	pipe(**SCREAMING_SNAKE_CASE_       ).images
          UpperCamelCase    :  str							=	image[0, -3:, -3:, -1]

          self.assertEqual(image.shape,			(1, 256, 256, 3)       )
          UpperCamelCase    :  List[Any]							=	np.array(
              [0.47_22_24_12, 0.41_92_16_33, 0.44_71_74_34, 0.46_87_41_92, 0.42_58_82_58, 0.46_15_07_26, 0.4_67_75_34, 0.45_58_38_32, 0.48_57_90_55]       )
          UpperCamelCase    :  Dict							=	np.abs(image_slice.flatten() - expected_slice       ).max()
          self.assertLessEqual(SCREAMING_SNAKE_CASE_,			1e-3       )
       def 					snake_case_       (			self       )     ->		List[Any]:
          super().test_attention_slicing_forward_pass(expected_max_diff=7e-3       )
       def 					snake_case_       (			self       )     ->		Tuple:
          super().test_cpu_offload_forward_pass(expected_max_diff=3e-3       )
       def 					snake_case_       (			self       )     ->		Dict:
          super().test_dict_tuple_outputs_equivalent(expected_max_difference=3e-3       )
       def 					snake_case_       (			self       )     ->		Any:
          super().test_inference_batch_single_identical(expected_max_diff=7e-3       )
       def 					snake_case_       (			self       )     ->		List[str]:
          super().test_pt_np_pil_outputs_equivalent(expected_max_diff=3e-3       )
       def 					snake_case_       (			self       )     ->		Optional[int]:
          super().test_save_load_local(expected_max_difference=3e-3       )
       def 					snake_case_       (			self       )     ->		int:
          super().test_save_load_optional_components(expected_max_difference=3e-3       )






       def 					snake_case_       (			self       )     ->		Optional[Any]:
          UpperCamelCase    :  Optional[Any]							=	[
              'DDIMScheduler',
              'DDPMScheduler',
              'PNDMScheduler',
              'HeunDiscreteScheduler',
              'EulerAncestralDiscreteScheduler',
              'KDPM2DiscreteScheduler',
              'KDPM2AncestralDiscreteScheduler',
              'DPMSolverSDEScheduler',
          ]
          UpperCamelCase    :  Tuple							=	self.get_dummy_components()
          UpperCamelCase    :  Tuple							=	self.pipeline_class(**SCREAMING_SNAKE_CASE_       )

          # make sure that PNDM does not need warm-up
          pipe.scheduler.register_to_config(skip_prk_steps=SCREAMING_SNAKE_CASE_       )

          pipe.to(SCREAMING_SNAKE_CASE_       )
          pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE_       )
          UpperCamelCase    :  int							=	self.get_dummy_inputs(SCREAMING_SNAKE_CASE_       )
          UpperCamelCase    :  Optional[Any]							=	2

          UpperCamelCase    :  Optional[Any]							=	[]
          for scheduler_enum in KarrasDiffusionSchedulers:
             if scheduler_enum.name in skip_schedulers:
                # no sigma schedulers are not supported
                # no schedulers
                continue

             UpperCamelCase    :  List[Any]							=	getattr(SCREAMING_SNAKE_CASE_,			scheduler_enum.name       )
             UpperCamelCase    :  List[str]							=	scheduler_cls.from_config(pipe.scheduler.config       )
             UpperCamelCase    :  List[str]							=	pipe(**SCREAMING_SNAKE_CASE_       )[0]
             outputs.append(SCREAMING_SNAKE_CASE_       )

          assert check_same_shape(SCREAMING_SNAKE_CASE_       )






@require_torch_gpu
@slow
class 				lowerCAmelCase_		(  unittest.TestCase							):
       def 					snake_case_       (			self       )     ->		Union[str, Any]:
          super().tearDown()
          gc.collect()
          torch.cuda.empty_cache()
       def 					snake_case_       (			self       )     ->		List[Any]:
          UpperCamelCase    :  Dict							=	torch.manual_seed(33       )

          UpperCamelCase    :  Union[str, Any]							=	StableDiffusionPipeline.from_pretrained('CompVis/stable-diffusion-v1-4',			torch_dtype=torch.floataa       )
          pipe.to('cuda'       )

          UpperCamelCase    :  Tuple							=	StableDiffusionLatentUpscalePipeline.from_pretrained(
              'stabilityai/sd-x2-latent-upscaler',			torch_dtype=torch.floataa       )
          upscaler.to('cuda'       )

          UpperCamelCase    :  Union[str, Any]							=	'a photo of an astronaut high resolution, unreal engine, ultra realistic'

          UpperCamelCase    :  int							=	pipe(SCREAMING_SNAKE_CASE_,			generator=SCREAMING_SNAKE_CASE_,			output_type='latent'       ).images

          UpperCamelCase    :  List[str]							=	upscaler(
              prompt=SCREAMING_SNAKE_CASE_,			image=SCREAMING_SNAKE_CASE_,			num_inference_steps=20,			guidance_scale=0,			generator=SCREAMING_SNAKE_CASE_,			output_type='np',			).images[0]

          UpperCamelCase    :  Optional[int]							=	load_numpy(
              'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/latent-upscaler/astronaut_1024.npy'       )
          assert np.abs((expected_image - image).mean()       ) < 5e-2






       def 					snake_case_       (			self       )     ->		int:
          UpperCamelCase    :  List[Any]							=	torch.manual_seed(33       )

          UpperCamelCase    :  Union[str, Any]							=	StableDiffusionLatentUpscalePipeline.from_pretrained(
              'stabilityai/sd-x2-latent-upscaler',			torch_dtype=torch.floataa       )
          upscaler.to('cuda'       )

          UpperCamelCase    :  Dict							=	'the temple of fire by Ross Tran and Gerardo Dottori, oil on canvas'

          UpperCamelCase    :  List[str]							=	load_image(
              'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/latent-upscaler/fire_temple_512.png'       )

          UpperCamelCase    :  str							=	upscaler(
              prompt=SCREAMING_SNAKE_CASE_,			image=SCREAMING_SNAKE_CASE_,			num_inference_steps=20,			guidance_scale=0,			generator=SCREAMING_SNAKE_CASE_,			output_type='np',			).images[0]

          UpperCamelCase    :  Optional[Any]							=	load_numpy(
              'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/latent-upscaler/fire_temple_1024.npy'       )
          assert np.abs((expected_image - image).max()       ) < 5e-2



