




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


SCREAMING_SNAKE_CASE:     str									= False



class    lowercase_		(unittest.TestCase ):
						pass



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



						def 	__a					(			self	:   Dict  ):

								"""simple docstring"""

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



						def 	__a					(			self	:   Optional[int]  ):

								"""simple docstring"""

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

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

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

								SCREAMING_SNAKE_CASE_					      =							generator.manual_seed(0  )
								SCREAMING_SNAKE_CASE_					      =							pipe(
								    prompt=_SCREAMING_SNAKE_CASE					,							generator=_SCREAMING_SNAKE_CASE					,							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	:   Optional[int]  ):

								"""simple docstring"""

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

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

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

								assert image.shape == (1, 5_12, 5_12, 3)
								SCREAMING_SNAKE_CASE_					      =							np.array([0.33_67, 0.31_69, 0.26_56, 0.38_70, 0.47_90, 0.37_96, 0.40_09, 0.48_78, 0.47_78]  )

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





def lowerCamelCase__  (     ):

     '''simple docstring'''


     UpperCAmelCase_     :				Dict  =     0
     for i in range(1					,		1001 ):
          total += i**i
     return str(_lowercase )[-10:]


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