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       :	int									=     False







class 						A(		unittest.TestCase     ):



 '''simple docstring'''


 pass







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



 '''simple docstring'''


 def        a__				(       self      :						List[Any]						)     ->			int:

       """simple docstring"""






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

 def        a__				(       self      :						Optional[int]						)     ->			Any:

       """simple docstring"""






       lowerCamelCase_	  =					VersatileDiffusionTextToImagePipeline.from_pretrained('shi-labs/versatile-diffusion'						)
       # remove text_unet
       pipe.remove_unused_weights()
       pipe.to(A_						)
       pipe.set_progress_bar_config(disable=A_						)

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

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

       lowerCamelCase_	  =					generator.manual_seed(0						)
       lowerCamelCase_	  =					pipe(
           prompt=A_		,							generator=A_		,							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        a__				(       self      :						int						)     ->			int:

       """simple docstring"""






       lowerCamelCase_	  =					VersatileDiffusionTextToImagePipeline.from_pretrained(
           'shi-labs/versatile-diffusion'		,							torch_dtype=torch.floataa						)
       pipe.to(A_						)
       pipe.set_progress_bar_config(disable=A_						)

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

       lowerCamelCase_	  =					image[0, 253:256, 253:256, -1]

       assert image.shape == (1, 512, 512, 3)
       lowerCamelCase_	  =					np.array([0.3367, 0.3169, 0.2656, 0.3870, 0.4790, 0.3796, 0.4009, 0.4878, 0.4778]						)

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









from __future__ import annotations

from fractions import Fraction

def     _SCREAMING_SNAKE_CASE    (							lowercase			: int			,							lowercase			: int  ):


      '''simple docstring'''



      return (
          num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den
      )

def     _SCREAMING_SNAKE_CASE    (							lowercase			: int  ):


      '''simple docstring'''



      lowerCamelCase_	  =					[]
      lowerCamelCase_	  =					11
      lowerCamelCase_	  =					int('1' + '0' * digit_len  )
      for num in range(lowercase			,							lowercase  ):
            while den <= 99:
                  if (num != den) and (num % 10 == den // 10) and (den % 10 != 0):
                        if is_digit_cancelling(lowercase			,							lowercase  ):
                              solutions.append(f"""{num}/{den}"""  )
                  den += 1
            num += 1
            lowerCamelCase_	  =					10
      return solutions

def     _SCREAMING_SNAKE_CASE    (							lowercase			: int = 2  ):


      '''simple docstring'''



      lowerCamelCase_	  =					1.0
      for fraction in fraction_list(lowercase  ):
            lowerCamelCase_	  =					Fraction(lowercase  )
            result *= frac.denominator / frac.numerator
      return int(lowercase  )


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



