
"""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


lowerCAmelCase								=						False

class     A_	(     unittest.TestCase   ):



							"""simple docstring"""






							pass






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



							"""simple docstring"""






							def       UpperCAmelCase__							(  self  :str       ):





										"""simple docstring"""

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





							def       UpperCAmelCase__							(  self  :List[str]       ):





										"""simple docstring"""

										lowerCamelCase__	:     List[Any]              =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__       )

										lowerCamelCase__	:     Optional[Any]              ='A painting of a squirrel eating a burger '
										lowerCamelCase__	:     Optional[Any]              =torch.manual_seed(0       )
										lowerCamelCase__	:     int              =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__       )
													lowerCamelCase__	:     Dict              =VersatileDiffusionTextToImagePipeline.from_pretrained(SCREAMING_SNAKE_CASE__       )
										pipe.to(SCREAMING_SNAKE_CASE__       )
										pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE__       )

										lowerCamelCase__	:     Union[str, Any]              =generator.manual_seed(0       )
										lowerCamelCase__	:     Any              =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       UpperCAmelCase__							(  self  :int       ):





										"""simple docstring"""

										lowerCamelCase__	:     List[Any]              =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__       )

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

										lowerCamelCase__	:     List[Any]              =image[0, 253:256, 253:256, -1]

										assert image.shape == (1, 512, 512, 3)
										lowerCamelCase__	:     Union[str, Any]              =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

import pprint

import requests

SCREAMING_SNAKE_CASE__   :			str												=    "https://zenquotes.io/api"




def  __magic_name__ (   )			->   list:
				return requests.get(API_ENDPOINT_URL + '''/today'''							).json()




def  __magic_name__ (   )			->   list:
				return requests.get(API_ENDPOINT_URL + '''/random'''							).json()


if __name__ == "__main__":
					SCREAMING_SNAKE_CASE__   :			int												=    random_quotes()
					pprint.pprint(response)



