



'''simple docstring'''





import unittest

import numpy as np
import torch

from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel
from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device


enable_full_determinism()



class  snake_case__						(    unittest.TestCase				):
 @property
 def A_   (   self						:							Optional[int]  )      ->   Any:







       '''simple docstring'''
       torch.manual_seed(0  )
       __snake_case :   Optional[Any]													=    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 A_   (   self						:							Dict  )      ->   int:







       '''simple docstring'''
       __snake_case :   Optional[Any]													=    self.dummy_uncond_unet
       __snake_case :   Optional[int]													=    PNDMScheduler()

       __snake_case :   List[Any]													=    PNDMPipeline(unet=__a      ,     scheduler=__a  )
       pndm.to(__a  )
       pndm.set_progress_bar_config(disable=__a  )

       __snake_case :   Optional[Any]													=    torch.manual_seed(0  )
       __snake_case :   List[Any]													=    pndm(generator=__a      ,     num_inference_steps=20      ,     output_type='numpy'  ).images

       __snake_case :   int													=    torch.manual_seed(0  )
       __snake_case :   Any													=    pndm(generator=__a      ,     num_inference_steps=20      ,     output_type='numpy'      ,     return_dict=__a  )[0]

       __snake_case :   str													=    image[0, -3:, -3:, -1]
       __snake_case :   Optional[int]													=    image_from_tuple[0, -3:, -3:, -1]

       assert image.shape == (1, 32, 32, 3)
       __snake_case :   Dict													=    np.array([1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0]  )

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



@slow
@require_torch
class  snake_case__						(    unittest.TestCase				):
 def A_   (   self						:							Tuple  )      ->   Optional[Any]:







       '''simple docstring'''
       __snake_case :   Tuple													=    'google/ddpm-cifar10-32'

       __snake_case :   List[Any]													=    UNetaDModel.from_pretrained(__a  )
       __snake_case :   str													=    PNDMScheduler()

       __snake_case :   List[str]													=    PNDMPipeline(unet=__a      ,     scheduler=__a  )
       pndm.to(__a  )
       pndm.set_progress_bar_config(disable=__a  )
       __snake_case :   List[str]													=    torch.manual_seed(0  )
       __snake_case :   int													=    pndm(generator=__a      ,     output_type='numpy'  ).images

       __snake_case :   List[Any]													=    image[0, -3:, -3:, -1]

       assert image.shape == (1, 32, 32, 3)
       __snake_case :   Union[str, Any]													=    np.array([0.1_5_6_4, 0.1_4_6_4_5, 0.1_4_0_6, 0.1_4_7_1_5, 0.1_2_4_2_5, 0.1_4_0_4_5, 0.1_3_1_1_5, 0.1_2_1_7_5, 0.1_2_5]  )

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








'''simple docstring'''





from ..utils import DummyObject, requires_backends



class  snake_case__						(    metaclass=SCREAMING_SNAKE_CASE_				):
 A__				= ['''note_seq''']
 def __init__(   self						:							Tuple      ,     *__a						:							int      ,     **__a						:							List[str]  )      ->   Any:







       '''simple docstring'''
       requires_backends(self      ,     ['note_seq']  )
 @classmethod
 def A_   (   cls						:							Optional[Any]      ,     *__a						:							Optional[Any]      ,     **__a						:							List[str]  )      ->   Union[str, Any]:







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





 @classmethod
 def A_   (   cls						:							List[Any]      ,     *__a						:							Union[str, Any]      ,     **__a						:							List[str]  )      ->   Any:







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



