"""simple docstring"""






from functools import lru_cache



def SCREAMING_SNAKE_CASE__			(   __UpperCAmelCase )  ->  set:
   lowercase__:   Optional[int]					=      2
   lowercase__:   List[str]					=      set()
   while i * i <= n:
      if n % i:
         i += 1
      else:
         n //= i
         factors.add(__UpperCAmelCase )
   if n > 1:
      factors.add(__UpperCAmelCase )
   return factors



@lru_cache
def SCREAMING_SNAKE_CASE__			(   __UpperCAmelCase )  ->  int:
   return len(unique_prime_factors(__UpperCAmelCase ) )



def SCREAMING_SNAKE_CASE__			(   __UpperCAmelCase )  ->  bool:
   return len(set(__UpperCAmelCase ) ) in (0, 1)



def SCREAMING_SNAKE_CASE__			(   __UpperCAmelCase )  ->  list:
   lowercase__:   Tuple					=      2

   while True:
      # Increment each value of a generated range
      lowercase__:   int					=      [base + i for i in range(__UpperCAmelCase )]

      # Run elements through out unique_prime_factors function
      # Append our target number to the end.
      lowercase__:   List[Any]					=      [upf_len(__UpperCAmelCase ) for x in group]
      checker.append(__UpperCAmelCase )

      # If all numbers in the list are equal, return the group variable.
      if equality(__UpperCAmelCase ):
         return group

      # Increment our base variable by 1
      base += 1



def SCREAMING_SNAKE_CASE__			(   __UpperCAmelCase = 4 )  ->  int:
   lowercase__:   Tuple					=      run(__UpperCAmelCase )
   return results[0] if len(__UpperCAmelCase ) else None


if __name__ == "__main__":
       print(solution())

"""simple docstring"""






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


__A			   = False


class     UpperCAmelCase						(unittest.TestCase  ):



    """simple docstring"""

    pass



@nightly
@require_torch_gpu
class     UpperCAmelCase						(unittest.TestCase  ):



    """simple docstring"""

    def _snake_case			(   self							):
       # clean up the VRAM after each test
       super().tearDown()
       gc.collect()
       torch.cuda.empty_cache()






    def _snake_case			(   self							):
       lowercase__:   Dict					=      VersatileDiffusionTextToImagePipeline.from_pretrained('''shi-labs/versatile-diffusion'''							)
       # remove text_unet
       pipe.remove_unused_weights()
       pipe.to(_UpperCAmelCase							)
       pipe.set_progress_bar_config(disable=_UpperCAmelCase							)

       lowercase__:   List[str]					=      '''A painting of a squirrel eating a burger '''
       lowercase__:   str					=      torch.manual_seed(0							)
       lowercase__:   Union[str, Any]					=      pipe(
           prompt=_UpperCAmelCase    ,			generator=_UpperCAmelCase    ,			guidance_scale=7.5    ,			num_inference_steps=2    ,			output_type='''numpy'''							).images

       with tempfile.TemporaryDirectory() as tmpdirname:
          pipe.save_pretrained(_UpperCAmelCase							)
          lowercase__:   Optional[Any]					=      VersatileDiffusionTextToImagePipeline.from_pretrained(_UpperCAmelCase							)
       pipe.to(_UpperCAmelCase							)
       pipe.set_progress_bar_config(disable=_UpperCAmelCase							)

       lowercase__:   Optional[int]					=      generator.manual_seed(0							)
       lowercase__:   List[str]					=      pipe(
           prompt=_UpperCAmelCase    ,			generator=_UpperCAmelCase    ,			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 _snake_case			(   self							):
       lowercase__:   Dict					=      VersatileDiffusionTextToImagePipeline.from_pretrained(
           '''shi-labs/versatile-diffusion'''    ,			torch_dtype=torch.floataa							)
       pipe.to(_UpperCAmelCase							)
       pipe.set_progress_bar_config(disable=_UpperCAmelCase							)

       lowercase__:   Tuple					=      '''A painting of a squirrel eating a burger '''
       lowercase__:   Optional[Any]					=      torch.manual_seed(0							)
       lowercase__:   Tuple					=      pipe(
           prompt=_UpperCAmelCase    ,			generator=_UpperCAmelCase    ,			guidance_scale=7.5    ,			num_inference_steps=50    ,			output_type='''numpy'''							).images

       lowercase__:   Union[str, Any]					=      image[0, 253:256, 253:256, -1]

       assert image.shape == (1, 512, 512, 3)
       lowercase__:   Any					=      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
