


'''simple docstring'''



import gc
import unittest

import numpy as np
import torch

from diffusers import StableDiffusionKDiffusionPipeline
from diffusers.utils import slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu


enable_full_determinism()






@slow
@require_torch_gpu
class  UpperCamelCase__(     unittest.TestCase ):




				def   a__(	self    :				str   )->  Union[str, Any]:

										"""simple docstring"""




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




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

										"""simple docstring"""




										UpperCAmelCase         =			StableDiffusionKDiffusionPipeline.from_pretrained('''CompVis/stable-diffusion-v1-4'''   )
										UpperCAmelCase         =			sd_pipe.to(lowerCAmelCase   )
										sd_pipe.set_progress_bar_config(disable=lowerCAmelCase   )

										sd_pipe.set_scheduler('''sample_euler'''   )

										UpperCAmelCase         =			'''A painting of a squirrel eating a burger'''
										UpperCAmelCase         =			torch.manual_seed(0   )
										UpperCAmelCase         =			sd_pipe([prompt]   ,					generator=lowerCAmelCase   ,					guidance_scale=9.0   ,					num_inference_steps=20   ,					output_type='''np'''   )

										UpperCAmelCase         =			output.images

										UpperCAmelCase         =			image[0, -3:, -3:, -1]

										assert image.shape == (1, 512, 512, 3)
										UpperCAmelCase         =			np.array([0.0447, 0.0492, 0.0468, 0.0408, 0.0383, 0.0408, 0.0354, 0.0380, 0.0339]   )

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




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

										"""simple docstring"""




										UpperCAmelCase         =			StableDiffusionKDiffusionPipeline.from_pretrained('''stabilityai/stable-diffusion-2-1-base'''   )
										UpperCAmelCase         =			sd_pipe.to(lowerCAmelCase   )
										sd_pipe.set_progress_bar_config(disable=lowerCAmelCase   )

										sd_pipe.set_scheduler('''sample_euler'''   )

										UpperCAmelCase         =			'''A painting of a squirrel eating a burger'''
										UpperCAmelCase         =			torch.manual_seed(0   )
										UpperCAmelCase         =			sd_pipe([prompt]   ,					generator=lowerCAmelCase   ,					guidance_scale=9.0   ,					num_inference_steps=20   ,					output_type='''np'''   )

										UpperCAmelCase         =			output.images

										UpperCAmelCase         =			image[0, -3:, -3:, -1]

										assert image.shape == (1, 512, 512, 3)
										UpperCAmelCase         =			np.array([0.1237, 0.1320, 0.1438, 0.1359, 0.1390, 0.1132, 0.1277, 0.1175, 0.1112]   )

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





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

										"""simple docstring"""




										UpperCAmelCase         =			StableDiffusionKDiffusionPipeline.from_pretrained('''stabilityai/stable-diffusion-2-1-base'''   )
										UpperCAmelCase         =			sd_pipe.to(lowerCAmelCase   )
										sd_pipe.set_progress_bar_config(disable=lowerCAmelCase   )

										sd_pipe.set_scheduler('''sample_dpmpp_2m'''   )

										UpperCAmelCase         =			'''A painting of a squirrel eating a burger'''
										UpperCAmelCase         =			torch.manual_seed(0   )
										UpperCAmelCase         =			sd_pipe(
										    [prompt]   ,					generator=lowerCAmelCase   ,					guidance_scale=7.5   ,					num_inference_steps=15   ,					output_type='''np'''   ,					use_karras_sigmas=lowerCAmelCase   ,					)

										UpperCAmelCase         =			output.images

										UpperCAmelCase         =			image[0, -3:, -3:, -1]

										assert image.shape == (1, 512, 512, 3)
										UpperCAmelCase         =			np.array(
										    [0.11381689, 0.12112921, 0.1389457, 0.12549606, 0.1244964, 0.10831517, 0.11562866, 0.10867816, 0.10499048]   )

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









'''simple docstring'''



from ..utils import DummyObject, requires_backends






class  UpperCamelCase__(     metaclass=lowerCAmelCase ):
				__magic_name__       :   List[str]							= ["note_seq"]




				def __init__(	self    :				Any   ,					*lowerCAmelCase    :				List[str]   ,					**lowerCAmelCase    :				int   )->  Optional[int]:

										"""simple docstring"""




										requires_backends(self   ,					['''note_seq''']   )




				@classmethod
				def   a__(	cls    :				Dict   ,					*lowerCAmelCase    :				int   ,					**lowerCAmelCase    :				Optional[int]   )->  Dict:

										"""simple docstring"""




										requires_backends(cls   ,					['''note_seq''']   )





				@classmethod
				def   a__(	cls    :				int   ,					*lowerCAmelCase    :				Tuple   ,					**lowerCAmelCase    :				Optional[Any]   )->  Union[str, Any]:

										"""simple docstring"""




										requires_backends(cls   ,					['''note_seq''']   )





