




import gc
import tempfile
import unittest

import numpy as np
import torch

from diffusers import VersatileDiffusionTextToImagePipeline
from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device


__lowerCAmelCase		:				Optional[int]       			=		False




class     snake_case__							(unittest.TestCase   ):
				"""simple docstring"""



				pass




@nightly
@require_torch_gpu
class     snake_case__							(unittest.TestCase   ):
				"""simple docstring"""



				def 							__UpperCAmelCase							(      self				:     Optional[Any]							)					->     List[str]:
							# clean up the VRAM after each test
							super().tearDown()
							gc.collect()
							torch.cuda.empty_cache()





				def 							__UpperCAmelCase							(      self				:     Dict							)					->     int:
							a    =			VersatileDiffusionTextToImagePipeline.from_pretrained("shi-labs/versatile-diffusion"							)
							# remove text_unet
							pipe.remove_unused_weights()
							pipe.to(__lowerCamelCase							)
							pipe.set_progress_bar_config(disable=__lowerCamelCase							)

							a    =			"A painting of a squirrel eating a burger "
							a    =			torch.manual_seed(0							)
							a    =			pipe(
							    prompt=__lowerCamelCase					,      generator=__lowerCamelCase					,      guidance_scale=7.5					,      num_inference_steps=2					,      output_type="numpy"							).images

							with tempfile.TemporaryDirectory() as tmpdirname:
										pipe.save_pretrained(__lowerCamelCase							)
										a    =			VersatileDiffusionTextToImagePipeline.from_pretrained(__lowerCamelCase							)
							pipe.to(__lowerCamelCase							)
							pipe.set_progress_bar_config(disable=__lowerCamelCase							)

							a    =			generator.manual_seed(0							)
							a    =			pipe(
							    prompt=__lowerCamelCase					,      generator=__lowerCamelCase					,      guidance_scale=7.5					,      num_inference_steps=2					,      output_type="numpy"							).images

							assert np.abs(image - new_image							).sum() < 1e-5, "Models don't have the same forward pass"





				def 							__UpperCAmelCase							(      self				:     str							)					->     List[str]:
							a    =			VersatileDiffusionTextToImagePipeline.from_pretrained(
							    "shi-labs/versatile-diffusion"					,      torch_dtype=torch.floataa							)
							pipe.to(__lowerCamelCase							)
							pipe.set_progress_bar_config(disable=__lowerCamelCase							)

							a    =			"A painting of a squirrel eating a burger "
							a    =			torch.manual_seed(0							)
							a    =			pipe(
							    prompt=__lowerCamelCase					,      generator=__lowerCamelCase					,      guidance_scale=7.5					,      num_inference_steps=50					,      output_type="numpy"							).images

							a    =			image[0, 2_53:2_56, 2_53:2_56, -1]

							assert image.shape == (1, 5_12, 5_12, 3)
							a    =			np.array([0.3_367, 0.3_169, 0.2_656, 0.3_870, 0.4_790, 0.3_796, 0.4_009, 0.4_878, 0.4_778]							)

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













from __future__ import annotations

from functools import lru_cache
from math import ceil

__lowerCamelCase       :     str   =     100

__lowerCamelCase       :     Any   =     set(range(3, NUM_PRIMES, 2))
primes.add(2)
__lowerCamelCase       :     int

for prime in range(3, ceil(NUM_PRIMES**0.5), 2):
    if prime not in primes:
        continue
    primes.difference_update(set(range(prime * prime, NUM_PRIMES, prime)))



@lru_cache(maxsize=100     )
def 		A_				(     _lowerCAmelCase     )						-> set[int]:
 if number_to_partition < 0:
  return set()
 elif number_to_partition == 0:
  return {1}

 UpperCamelCase	:					set[int]       	=   set()
 UpperCamelCase	:					int
 UpperCamelCase	:					int

 for prime in primes:
  if prime > number_to_partition:
   continue
  for sub in partition(number_to_partition - prime     ):
   ret.add(sub * prime     )

 return ret



def 		A_				(     _lowerCAmelCase = 5000     )						-> int | None:
 for number_to_partition in range(1							,   _lowerCAmelCase     ):
  if len(partition(_lowerCAmelCase     )     ) > number_unique_partitions:
   return number_to_partition
 return None


if __name__ == "__main__":
    print(f"""{solution() = }""")
