code: 
  
  
  
  
  
  
  """simple docstring"""
  
  
  
  
  
  
  import unittest
  
  import numpy as np
  import torch
  
  from diffusers import DDPMPipeline, DDPMScheduler, UNetaDModel
  from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device
  
  
  enable_full_determinism()
  class 						__lowerCAmelCase   (			unittest.TestCase       ):
  
  
  
  
  
  
  
  		'''simple docstring'''
  
  
  		@property
  		def 					UpperCamelCase__   (      self:		Dict					):
  					torch.manual_seed(0					)
  					UpperCamelCase_     =UNetaDModel(
  					    block_out_channels=(32, 64)				,			layers_per_block=2				,			sample_size=32				,			in_channels=3				,			out_channels=3				,			down_block_types=("DownBlock2D", "AttnDownBlock2D")				,			up_block_types=("AttnUpBlock2D", "UpBlock2D")				,			)
  					return model
  		def 					UpperCamelCase__   (      self:		int					):
  					UpperCamelCase_     ="cpu"
  					UpperCamelCase_     =self.dummy_uncond_unet
  					UpperCamelCase_     =DDPMScheduler()
  
  					UpperCamelCase_     =DDPMPipeline(unet=UpperCamelCase_				,			scheduler=UpperCamelCase_					)
  					ddpm.to(UpperCamelCase_					)
  					ddpm.set_progress_bar_config(disable=UpperCamelCase_					)
  
  					UpperCamelCase_     =torch.Generator(device=UpperCamelCase_					).manual_seed(0					)
  					UpperCamelCase_     =ddpm(generator=UpperCamelCase_				,			num_inference_steps=2				,			output_type="numpy"					).images
  
  					UpperCamelCase_     =torch.Generator(device=UpperCamelCase_					).manual_seed(0					)
  					UpperCamelCase_     =ddpm(generator=UpperCamelCase_				,			num_inference_steps=2				,			output_type="numpy"				,			return_dict=UpperCamelCase_					)[0]
  
  					UpperCamelCase_     =image[0, -3:, -3:, -1]
  					UpperCamelCase_     =image_from_tuple[0, -3:, -3:, -1]
  
  					assert image.shape == (1, 32, 32, 3)
  					UpperCamelCase_     =np.array(
  					    [9.9_5_6e-0_1, 5.7_8_5e-0_1, 4.6_7_5e-0_1, 9.9_3_0e-0_1, 0.0, 1.000, 1.1_9_9e-0_3, 2.6_4_8e-0_4, 5.1_0_1e-0_4]					)
  
  					assert np.abs(image_slice.flatten() - expected_slice					).max() < 1e-2
  					assert np.abs(image_from_tuple_slice.flatten() - expected_slice					).max() < 1e-2
  
  
  
  
  
  		def 					UpperCamelCase__   (      self:		str					):
  					UpperCamelCase_     =self.dummy_uncond_unet
  					UpperCamelCase_     =DDPMScheduler(prediction_type="sample"					)
  
  					UpperCamelCase_     =DDPMPipeline(unet=UpperCamelCase_				,			scheduler=UpperCamelCase_					)
  					ddpm.to(UpperCamelCase_					)
  					ddpm.set_progress_bar_config(disable=UpperCamelCase_					)
  
  					UpperCamelCase_     =torch.manual_seed(0					)
  					UpperCamelCase_     =ddpm(generator=UpperCamelCase_				,			num_inference_steps=2				,			output_type="numpy"					).images
  
  					UpperCamelCase_     =torch.manual_seed(0					)
  					UpperCamelCase_     =ddpm(generator=UpperCamelCase_				,			num_inference_steps=2				,			output_type="numpy"					)[0]
  
  					UpperCamelCase_     =image[0, -3:, -3:, -1]
  					UpperCamelCase_     =image_eps[0, -3:, -3:, -1]
  
  					assert image.shape == (1, 32, 32, 3)
  					UpperCamelCase_     =1e-2 if torch_device != "mps" else 3e-2
  					assert np.abs(image_slice.flatten() - image_eps_slice.flatten()					).max() < tolerance
  
  
  
  
  @slow
  @require_torch_gpu
  class 						__lowerCAmelCase   (			unittest.TestCase       ):
  
  
  
  
  
  
  
  		'''simple docstring'''
  
  
  		def 					UpperCamelCase__   (      self:		Optional[Any]					):
  					UpperCamelCase_     ="google/ddpm-cifar10-32"
  
  					UpperCamelCase_     =UNetaDModel.from_pretrained(UpperCamelCase_					)
  					UpperCamelCase_     =DDPMScheduler.from_pretrained(UpperCamelCase_					)
  
  					UpperCamelCase_     =DDPMPipeline(unet=UpperCamelCase_				,			scheduler=UpperCamelCase_					)
  					ddpm.to(UpperCamelCase_					)
  					ddpm.set_progress_bar_config(disable=UpperCamelCase_					)
  
  					UpperCamelCase_     =torch.manual_seed(0					)
  					UpperCamelCase_     =ddpm(generator=UpperCamelCase_				,			output_type="numpy"					).images
  
  					UpperCamelCase_     =image[0, -3:, -3:, -1]
  
  					assert image.shape == (1, 32, 32, 3)
  					UpperCamelCase_     =np.array([0.4200, 0.3588, 0.1939, 0.3847, 0.3382, 0.2647, 0.4155, 0.3582, 0.3385]					)
  					assert np.abs(image_slice.flatten() - expected_slice					).max() < 1e-2
  
style_context: 
  
  
  
  
  
  
  """simple docstring"""
  
  
  
  
  
  
  import unittest
  from dataclasses import dataclass
  from typing import List, Union
  
  import numpy as np
  import PIL.Image
  
  from diffusers.utils.outputs import BaseOutput
  @dataclass
  class 						__lowerCAmelCase   (			UpperCAmelCase       ):
  
  
  
  
  
  
  
    '''simple docstring'''
  
  
    __lowerCamelCase       :    Union[List[PIL.Image.Image], np.ndarray]
  
  
  
  
  class 						__lowerCAmelCase   (			unittest.TestCase       ):
  
  
  
  
  
  
  
    '''simple docstring'''
  
  
    def 					UpperCamelCase__   (      self:		Tuple					):
       UpperCamelCase_     =CustomOutput(images=np.random.rand(1				,			3				,			4				,			4					)					)
  
       # check every way of getting the attribute
       assert isinstance(outputs.images				,			np.ndarray					)
       assert outputs.images.shape == (1, 3, 4, 4)
       assert isinstance(outputs["images"]				,			np.ndarray					)
       assert outputs["images"].shape == (1, 3, 4, 4)
       assert isinstance(outputs[0]				,			np.ndarray					)
       assert outputs[0].shape == (1, 3, 4, 4)
  
       # test with a non-tensor attribute
       UpperCamelCase_     =CustomOutput(images=[PIL.Image.new("RGB"				,			(4, 4)					)]					)
  
       # check every way of getting the attribute
       assert isinstance(outputs.images				,			UpperCamelCase_					)
       assert isinstance(outputs.images[0]				,			PIL.Image.Image					)
       assert isinstance(outputs["images"]				,			UpperCamelCase_					)
       assert isinstance(outputs["images"][0]				,			PIL.Image.Image					)
       assert isinstance(outputs[0]				,			UpperCamelCase_					)
       assert isinstance(outputs[0][0]				,			PIL.Image.Image					)
  
  
  
  
  
    def 					UpperCamelCase__   (      self:		Optional[int]					):
       # test output reinitialization with a `dict` for compatibility with `accelerate`
       UpperCamelCase_     =CustomOutput({"images": np.random.rand(1				,			3				,			4				,			4					)}					)
  
       # check every way of getting the attribute
       assert isinstance(outputs.images				,			np.ndarray					)
       assert outputs.images.shape == (1, 3, 4, 4)
       assert isinstance(outputs["images"]				,			np.ndarray					)
       assert outputs["images"].shape == (1, 3, 4, 4)
       assert isinstance(outputs[0]				,			np.ndarray					)
       assert outputs[0].shape == (1, 3, 4, 4)
  
       # test with a non-tensor attribute
       UpperCamelCase_     =CustomOutput({"images": [PIL.Image.new("RGB"				,			(4, 4)					)]}					)
  
       # check every way of getting the attribute
       assert isinstance(outputs.images				,			UpperCamelCase_					)
       assert isinstance(outputs.images[0]				,			PIL.Image.Image					)
       assert isinstance(outputs["images"]				,			UpperCamelCase_					)
       assert isinstance(outputs["images"][0]				,			PIL.Image.Image					)
       assert isinstance(outputs[0]				,			UpperCamelCase_					)
       assert isinstance(outputs[0][0]				,			PIL.Image.Image					)
  