


import gc
import unittest

import numpy as np
import torch
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer

from diffusers import (
    AutoencoderKL,
    DDIMScheduler,
    EulerAncestralDiscreteScheduler,
    LMSDiscreteScheduler,
    PNDMScheduler,
    StableDiffusionPanoramaPipeline,
    UNetaDConditionModel,
)
from diffusers.utils import slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, skip_mps

from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_IMAGE_PARAMS, TEXT_TO_IMAGE_PARAMS
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin


enable_full_determinism()
@skip_mps
class 	UpperCamelCase__					( __lowercase    ,					__lowercase    ,					unittest.TestCase	):



     """simple docstring"""






     __magic_name__    			=    StableDiffusionPanoramaPipeline
     __magic_name__    			=    TEXT_TO_IMAGE_PARAMS
     __magic_name__    			=    TEXT_TO_IMAGE_BATCH_PARAMS
     __magic_name__    			=    TEXT_TO_IMAGE_IMAGE_PARAMS
     __magic_name__    			=    TEXT_TO_IMAGE_IMAGE_PARAMS







     def a	( self   ):

            '''simple docstring'''

            torch.manual_seed(0   )
            _lowerCAmelCase    :							Any   			=       UNetaDConditionModel(
                block_out_channels=(32, 64)      ,	layers_per_block=1      ,	sample_size=32      ,	in_channels=4      ,	out_channels=4      ,	down_block_types=('DownBlock2D', 'CrossAttnDownBlock2D')      ,	up_block_types=('CrossAttnUpBlock2D', 'UpBlock2D')      ,	cross_attention_dim=32      ,	)
            _lowerCAmelCase    :							Dict   			=       DDIMScheduler()
            torch.manual_seed(0   )
            _lowerCAmelCase    :							str   			=       AutoencoderKL(
                block_out_channels=[32, 64]      ,	in_channels=3      ,	out_channels=3      ,	down_block_types=['DownEncoderBlock2D', 'DownEncoderBlock2D']      ,	up_block_types=['UpDecoderBlock2D', 'UpDecoderBlock2D']      ,	latent_channels=4      ,	)
            torch.manual_seed(0   )
            _lowerCAmelCase    :							Union[str, Any]   			=       CLIPTextConfig(
                bos_token_id=0      ,	eos_token_id=2      ,	hidden_size=32      ,	intermediate_size=37      ,	layer_norm_eps=1E-05      ,	num_attention_heads=4      ,	num_hidden_layers=5      ,	pad_token_id=1      ,	vocab_size=1000      ,	)
            _lowerCAmelCase    :							int   			=       CLIPTextModel(_A   )
            _lowerCAmelCase    :							List[Any]   			=       CLIPTokenizer.from_pretrained('hf-internal-testing/tiny-random-clip'   )

            _lowerCAmelCase    :							Optional[int]   			=       {
                'unet': unet,
                'scheduler': scheduler,
                'vae': vae,
                'text_encoder': text_encoder,
                'tokenizer': tokenizer,
                'safety_checker': None,
                'feature_extractor': None,
            }
            return components







     def a	( self      ,	snake_case__      ,	snake_case__=0   ):

            '''simple docstring'''

            _lowerCAmelCase    :							List[str]   			=       torch.manual_seed(_A   )
            _lowerCAmelCase    :							Dict   			=       {
                'prompt': 'a photo of the dolomites',
                'generator': generator,
                # Setting height and width to None to prevent OOMs on CPU.
                'height': None,
                'width': None,
                'num_inference_steps': 1,
                'guidance_scale': 6.0,
                'output_type': 'numpy',
            }
            return inputs







     def a	( self   ):

            '''simple docstring'''

            _lowerCAmelCase    :							Any   			=       'cpu'  # ensure determinism for the device-dependent torch.Generator
            _lowerCAmelCase    :							Optional[Any]   			=       self.get_dummy_components()
            _lowerCAmelCase    :							Union[str, Any]   			=       StableDiffusionPanoramaPipeline(**_A   )
            _lowerCAmelCase    :							List[Any]   			=       sd_pipe.to(_A   )
            sd_pipe.set_progress_bar_config(disable=_A   )

            _lowerCAmelCase    :							List[Any]   			=       self.get_dummy_inputs(_A   )
            _lowerCAmelCase    :							str   			=       sd_pipe(**_A   ).images
            _lowerCAmelCase    :							Optional[int]   			=       image[0, -3:, -3:, -1]
            assert image.shape == (1, 64, 64, 3)

            _lowerCAmelCase    :							int   			=       np.array([0.6186, 0.5374, 0.4915, 0.4135, 0.4114, 0.4563, 0.5128, 0.4977, 0.4757]   )

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







     def a	( self   ):

            '''simple docstring'''

            super().test_inference_batch_consistent(batch_sizes=[1, 2]   )







     def a	( self   ):

            '''simple docstring'''

            super().test_inference_batch_single_identical(batch_size=2      ,	expected_max_diff=3.25E-3   )







     def a	( self   ):

            '''simple docstring'''

            _lowerCAmelCase    :							List[Any]   			=       'cpu'  # ensure determinism for the device-dependent torch.Generator
            _lowerCAmelCase    :							Union[str, Any]   			=       self.get_dummy_components()
            _lowerCAmelCase    :							Optional[Any]   			=       StableDiffusionPanoramaPipeline(**_A   )
            _lowerCAmelCase    :							str   			=       sd_pipe.to(_A   )
            sd_pipe.set_progress_bar_config(disable=_A   )

            _lowerCAmelCase    :							Union[str, Any]   			=       self.get_dummy_inputs(_A   )
            _lowerCAmelCase    :							Optional[Any]   			=       'french fries'
            _lowerCAmelCase    :							Optional[int]   			=       sd_pipe(**_A      ,	negative_prompt=_A   )
            _lowerCAmelCase    :							Optional[Any]   			=       output.images
            _lowerCAmelCase    :							Optional[Any]   			=       image[0, -3:, -3:, -1]

            assert image.shape == (1, 64, 64, 3)

            _lowerCAmelCase    :							Optional[Any]   			=       np.array([0.6187, 0.5375, 0.4915, 0.4136, 0.4114, 0.4563, 0.5128, 0.4976, 0.4757]   )

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







     def a	( self   ):

            '''simple docstring'''

            _lowerCAmelCase    :							int   			=       'cpu'  # ensure determinism for the device-dependent torch.Generator
            _lowerCAmelCase    :							Tuple   			=       self.get_dummy_components()
            _lowerCAmelCase    :							str   			=       StableDiffusionPanoramaPipeline(**_A   )
            _lowerCAmelCase    :							Union[str, Any]   			=       sd_pipe.to(_A   )
            sd_pipe.set_progress_bar_config(disable=_A   )

            _lowerCAmelCase    :							List[Any]   			=       self.get_dummy_inputs(_A   )
            _lowerCAmelCase    :							List[Any]   			=       sd_pipe(**_A      ,	view_batch_size=2   )
            _lowerCAmelCase    :							Any   			=       output.images
            _lowerCAmelCase    :							str   			=       image[0, -3:, -3:, -1]

            assert image.shape == (1, 64, 64, 3)

            _lowerCAmelCase    :							Optional[Any]   			=       np.array([0.6187, 0.5375, 0.4915, 0.4136, 0.4114, 0.4563, 0.5128, 0.4976, 0.4757]   )

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







     def a	( self   ):

            '''simple docstring'''

            _lowerCAmelCase    :							int   			=       'cpu'  # ensure determinism for the device-dependent torch.Generator
            _lowerCAmelCase    :							List[str]   			=       self.get_dummy_components()
            _lowerCAmelCase    :							str   			=       EulerAncestralDiscreteScheduler(
                beta_start=0.0_0085      ,	beta_end=0.012      ,	beta_schedule='scaled_linear'   )
            _lowerCAmelCase    :							Optional[Any]   			=       StableDiffusionPanoramaPipeline(**_A   )
            _lowerCAmelCase    :							str   			=       sd_pipe.to(_A   )
            sd_pipe.set_progress_bar_config(disable=_A   )

            _lowerCAmelCase    :							Optional[int]   			=       self.get_dummy_inputs(_A   )
            _lowerCAmelCase    :							Any   			=       sd_pipe(**_A   ).images
            _lowerCAmelCase    :							List[Any]   			=       image[0, -3:, -3:, -1]

            assert image.shape == (1, 64, 64, 3)

            _lowerCAmelCase    :							List[str]   			=       np.array([0.4024, 0.6510, 0.4901, 0.5378, 0.5813, 0.5622, 0.4795, 0.4467, 0.4952]   )

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







     def a	( self   ):

            '''simple docstring'''

            _lowerCAmelCase    :							List[str]   			=       'cpu'  # ensure determinism for the device-dependent torch.Generator
            _lowerCAmelCase    :							Dict   			=       self.get_dummy_components()
            _lowerCAmelCase    :							Any   			=       PNDMScheduler(
                beta_start=0.0_0085      ,	beta_end=0.012      ,	beta_schedule='scaled_linear'      ,	skip_prk_steps=_A   )
            _lowerCAmelCase    :							Any   			=       StableDiffusionPanoramaPipeline(**_A   )
            _lowerCAmelCase    :							Any   			=       sd_pipe.to(_A   )
            sd_pipe.set_progress_bar_config(disable=_A   )

            _lowerCAmelCase    :							Union[str, Any]   			=       self.get_dummy_inputs(_A   )
            _lowerCAmelCase    :							Any   			=       sd_pipe(**_A   ).images
            _lowerCAmelCase    :							int   			=       image[0, -3:, -3:, -1]

            assert image.shape == (1, 64, 64, 3)

            _lowerCAmelCase    :							Union[str, Any]   			=       np.array([0.6391, 0.6291, 0.4861, 0.5134, 0.5552, 0.4578, 0.5032, 0.5023, 0.4539]   )

            assert np.abs(image_slice.flatten() - expected_slice   ).max() < 1E-2
@slow
@require_torch_gpu
class 	UpperCamelCase__					( unittest.TestCase	):



     """simple docstring"""






     def a	( self   ):

            '''simple docstring'''

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







     def a	( self      ,	snake_case__=0   ):

            '''simple docstring'''

            _lowerCAmelCase    :							List[Any]   			=       torch.manual_seed(_A   )
            _lowerCAmelCase    :							Optional[Any]   			=       {
                'prompt': 'a photo of the dolomites',
                'generator': generator,
                'num_inference_steps': 3,
                'guidance_scale': 7.5,
                'output_type': 'numpy',
            }
            return inputs







     def a	( self   ):

            '''simple docstring'''

            _lowerCAmelCase    :							str   			=       'stabilityai/stable-diffusion-2-base'
            _lowerCAmelCase    :							Optional[int]   			=       DDIMScheduler.from_pretrained(_A      ,	subfolder='scheduler'   )
            _lowerCAmelCase    :							Optional[int]   			=       StableDiffusionPanoramaPipeline.from_pretrained(_A      ,	scheduler=_A      ,	safety_checker=_A   )
            pipe.to(_A   )
            pipe.set_progress_bar_config(disable=_A   )
            pipe.enable_attention_slicing()

            _lowerCAmelCase    :							List[str]   			=       self.get_inputs()
            _lowerCAmelCase    :							Optional[int]   			=       pipe(**_A   ).images
            _lowerCAmelCase    :							Optional[Any]   			=       image[0, -3:, -3:, -1].flatten()

            assert image.shape == (1, 512, 2048, 3)

            _lowerCAmelCase    :							List[str]   			=       np.array(
                [
                    0.3696_8392,
                    0.2702_5372,
                    0.3244_6766,
                    0.2837_9387,
                    0.3636_3274,
                    0.3073_3347,
                    0.2710_0027,
                    0.2705_4125,
                    0.2553_6096,
                ]   )

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







     def a	( self   ):

            '''simple docstring'''

            _lowerCAmelCase    :							Any   			=       StableDiffusionPanoramaPipeline.from_pretrained(
                'stabilityai/stable-diffusion-2-base'      ,	safety_checker=_A   )
            _lowerCAmelCase    :							Tuple   			=       LMSDiscreteScheduler.from_config(pipe.scheduler.config   )
            pipe.to(_A   )
            pipe.set_progress_bar_config(disable=_A   )
            pipe.enable_attention_slicing()

            _lowerCAmelCase    :							Optional[Any]   			=       self.get_inputs()
            _lowerCAmelCase    :							List[str]   			=       pipe(**_A   ).images
            _lowerCAmelCase    :							Union[str, Any]   			=       image[0, -3:, -3:, -1].flatten()

            assert image.shape == (1, 512, 2048, 3)

            _lowerCAmelCase    :							int   			=       np.array(
                [
                    [
                        0.0,
                        0.0,
                        0.0,
                        0.0,
                        0.0,
                        0.0,
                        0.0,
                        0.0,
                        0.0,
                    ]
                ]   )

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







     def a	( self   ):

            '''simple docstring'''

            _lowerCAmelCase    :							Any   			=       0

            def callback_fn(snake_case__      ,	snake_case__      ,	snake_case__   ) -> None:
                   _lowerCAmelCase    :							List[str]   			=       True
                   nonlocal number_of_steps
                   number_of_steps += 1
                   if step == 1:
                          _lowerCAmelCase    :							Optional[int]   			=       latents.detach().cpu().numpy()
                          assert latents.shape == (1, 4, 64, 256)
                          _lowerCAmelCase    :							Optional[int]   			=       latents[0, -3:, -3:, -1]

                          _lowerCAmelCase    :							int   			=       np.array(
                              [
                                  0.1868_1869,
                                  0.3390_7816,
                                  0.536_1276,
                                  0.1443_2865,
                                  -0.0285_6611,
                                  -0.7394_1123,
                                  0.2339_7987,
                                  0.4732_2682,
                                  -0.3782_3164,
                              ]   )
                          assert np.abs(latents_slice.flatten() - expected_slice   ).max() < 5E-2
                   elif step == 2:
                          _lowerCAmelCase    :							List[Any]   			=       latents.detach().cpu().numpy()
                          assert latents.shape == (1, 4, 64, 256)
                          _lowerCAmelCase    :							Union[str, Any]   			=       latents[0, -3:, -3:, -1]

                          _lowerCAmelCase    :							Dict   			=       np.array(
                              [
                                  0.1853_9645,
                                  0.3398_7248,
                                  0.537_8559,
                                  0.1443_7142,
                                  -0.0245_5261,
                                  -0.733_8317,
                                  0.2399_0755,
                                  0.4735_6272,
                                  -0.378_6505,
                              ]   )

                          assert np.abs(latents_slice.flatten() - expected_slice   ).max() < 5E-2

            _lowerCAmelCase    :							Tuple   			=       False

            _lowerCAmelCase    :							str   			=       'stabilityai/stable-diffusion-2-base'
            _lowerCAmelCase    :							List[Any]   			=       DDIMScheduler.from_pretrained(_A      ,	subfolder='scheduler'   )
            _lowerCAmelCase    :							Tuple   			=       StableDiffusionPanoramaPipeline.from_pretrained(_A      ,	scheduler=_A      ,	safety_checker=_A   )
            _lowerCAmelCase    :							Any   			=       pipe.to(_A   )
            pipe.set_progress_bar_config(disable=_A   )
            pipe.enable_attention_slicing()

            _lowerCAmelCase    :							str   			=       self.get_inputs()
            pipe(**_A      ,	callback=_A      ,	callback_steps=1   )
            assert callback_fn.has_been_called
            assert number_of_steps == 3







     def a	( self   ):

            '''simple docstring'''

            torch.cuda.empty_cache()
            torch.cuda.reset_max_memory_allocated()
            torch.cuda.reset_peak_memory_stats()

            _lowerCAmelCase    :							List[Any]   			=       'stabilityai/stable-diffusion-2-base'
            _lowerCAmelCase    :							Dict   			=       DDIMScheduler.from_pretrained(_A      ,	subfolder='scheduler'   )
            _lowerCAmelCase    :							int   			=       StableDiffusionPanoramaPipeline.from_pretrained(_A      ,	scheduler=_A      ,	safety_checker=_A   )
            _lowerCAmelCase    :							str   			=       pipe.to(_A   )
            pipe.set_progress_bar_config(disable=_A   )
            pipe.enable_attention_slicing(1   )
            pipe.enable_sequential_cpu_offload()

            _lowerCAmelCase    :							Dict   			=       self.get_inputs()
            _lowerCAmelCase    :							Optional[Any]   			=       pipe(**_A   )

            _lowerCAmelCase    :							Optional[Any]   			=       torch.cuda.max_memory_allocated()
            # make sure that less than 5.2 GB is allocated
            assert mem_bytes < 5.5 * 10**9





'''simple docstring'''







import torch

from diffusers import DDPMScheduler

from .test_schedulers import SchedulerCommonTest
class 	UpperCamelCase__					( SCREAMING_SNAKE_CASE_	):



     """simple docstring"""






     __magic_name__    			=    (DDPMScheduler,)







     def a	( self      ,	**snake_case__   ):

            '''simple docstring'''

            _lowerCAmelCase    :							Union[str, Any]   			=       {
                'num_train_timesteps': 1000,
                'beta_start': 0.0001,
                'beta_end': 0.02,
                'beta_schedule': 'linear',
                'variance_type': 'fixed_small',
                'clip_sample': True,
            }

            config.update(**snake_case__   )
            return config







     def a	( self   ):

            '''simple docstring'''

            for timesteps in [1, 5, 100, 1000]:
                   self.check_over_configs(num_train_timesteps=snake_case__   )







     def a	( self   ):

            '''simple docstring'''

            for beta_start, beta_end in zip([0.0001, 0.001, 0.01, 0.1]      ,	[0.002, 0.02, 0.2, 2]   ):
                   self.check_over_configs(beta_start=snake_case__      ,	beta_end=snake_case__   )







     def a	( self   ):

            '''simple docstring'''

            for schedule in ["linear", "squaredcos_cap_v2"]:
                   self.check_over_configs(beta_schedule=snake_case__   )







     def a	( self   ):

            '''simple docstring'''

            for variance in ["fixed_small", "fixed_large", "other"]:
                   self.check_over_configs(variance_type=snake_case__   )







     def a	( self   ):

            '''simple docstring'''

            for clip_sample in [True, False]:
                   self.check_over_configs(clip_sample=snake_case__   )







     def a	( self   ):

            '''simple docstring'''

            self.check_over_configs(thresholding=snake_case__   )
            for threshold in [0.5, 1.0, 2.0]:
                   for prediction_type in ["epsilon", "sample", "v_prediction"]:
                          self.check_over_configs(
                              thresholding=snake_case__      ,	prediction_type=snake_case__      ,	sample_max_value=snake_case__      ,	)







     def a	( self   ):

            '''simple docstring'''

            for prediction_type in ["epsilon", "sample", "v_prediction"]:
                   self.check_over_configs(prediction_type=snake_case__   )







     def a	( self   ):

            '''simple docstring'''

            for t in [0, 500, 999]:
                   self.check_over_forward(time_step=snake_case__   )







     def a	( self   ):

            '''simple docstring'''

            _lowerCAmelCase    :							List[Any]   			=       self.scheduler_classes[0]
            _lowerCAmelCase    :							Optional[Any]   			=       self.get_scheduler_config()
            _lowerCAmelCase    :							List[Any]   			=       scheduler_class(**snake_case__   )

            assert torch.sum(torch.abs(scheduler._get_variance(0   ) - 0.0   )   ) < 1E-5
            assert torch.sum(torch.abs(scheduler._get_variance(487   ) - 0.0_0979   )   ) < 1E-5
            assert torch.sum(torch.abs(scheduler._get_variance(999   ) - 0.02   )   ) < 1E-5







     def a	( self   ):

            '''simple docstring'''

            _lowerCAmelCase    :							Optional[Any]   			=       self.scheduler_classes[0]
            _lowerCAmelCase    :							Optional[Any]   			=       self.get_scheduler_config()
            _lowerCAmelCase    :							List[Any]   			=       scheduler_class(**snake_case__   )

            _lowerCAmelCase    :							Optional[int]   			=       len(snake_case__   )

            _lowerCAmelCase    :							str   			=       self.dummy_model()
            _lowerCAmelCase    :							str   			=       self.dummy_sample_deter
            _lowerCAmelCase    :							Union[str, Any]   			=       torch.manual_seed(0   )

            for t in reversed(range(snake_case__   )   ):
                   # 1. predict noise residual
                   _lowerCAmelCase    :							List[Any]   			=       model(snake_case__      ,	snake_case__   )

                   # 2. predict previous mean of sample x_t-1
                   _lowerCAmelCase    :							Any   			=       scheduler.step(snake_case__      ,	snake_case__      ,	snake_case__      ,	generator=snake_case__   ).prev_sample

                   # if t > 0:
                   #     noise = self.dummy_sample_deter
                   #     variance = scheduler.get_variance(t) ** (0.5) * noise
                   #
                   # sample = pred_prev_sample + variance
                   _lowerCAmelCase    :							Dict   			=       pred_prev_sample

            _lowerCAmelCase    :							Dict   			=       torch.sum(torch.abs(snake_case__   )   )
            _lowerCAmelCase    :							List[str]   			=       torch.mean(torch.abs(snake_case__   )   )

            assert abs(result_sum.item() - 258.9606   ) < 1E-2
            assert abs(result_mean.item() - 0.3372   ) < 1E-3







     def a	( self   ):

            '''simple docstring'''

            _lowerCAmelCase    :							int   			=       self.scheduler_classes[0]
            _lowerCAmelCase    :							Any   			=       self.get_scheduler_config(prediction_type='v_prediction'   )
            _lowerCAmelCase    :							Union[str, Any]   			=       scheduler_class(**snake_case__   )

            _lowerCAmelCase    :							Optional[int]   			=       len(snake_case__   )

            _lowerCAmelCase    :							Any   			=       self.dummy_model()
            _lowerCAmelCase    :							Tuple   			=       self.dummy_sample_deter
            _lowerCAmelCase    :							Optional[int]   			=       torch.manual_seed(0   )

            for t in reversed(range(snake_case__   )   ):
                   # 1. predict noise residual
                   _lowerCAmelCase    :							Union[str, Any]   			=       model(snake_case__      ,	snake_case__   )

                   # 2. predict previous mean of sample x_t-1
                   _lowerCAmelCase    :							Dict   			=       scheduler.step(snake_case__      ,	snake_case__      ,	snake_case__      ,	generator=snake_case__   ).prev_sample

                   # if t > 0:
                   #     noise = self.dummy_sample_deter
                   #     variance = scheduler.get_variance(t) ** (0.5) * noise
                   #
                   # sample = pred_prev_sample + variance
                   _lowerCAmelCase    :							Tuple   			=       pred_prev_sample

            _lowerCAmelCase    :							Any   			=       torch.sum(torch.abs(snake_case__   )   )
            _lowerCAmelCase    :							Dict   			=       torch.mean(torch.abs(snake_case__   )   )

            assert abs(result_sum.item() - 202.0296   ) < 1E-2
            assert abs(result_mean.item() - 0.2631   ) < 1E-3







     def a	( self   ):

            '''simple docstring'''

            _lowerCAmelCase    :							List[Any]   			=       self.scheduler_classes[0]
            _lowerCAmelCase    :							Optional[int]   			=       self.get_scheduler_config()
            _lowerCAmelCase    :							Union[str, Any]   			=       scheduler_class(**snake_case__   )

            _lowerCAmelCase    :							Union[str, Any]   			=       [100, 87, 50, 1, 0]

            scheduler.set_timesteps(timesteps=snake_case__   )

            _lowerCAmelCase    :							Union[str, Any]   			=       scheduler.timesteps

            for i, timestep in enumerate(snake_case__   ):
                   if i == len(snake_case__   ) - 1:
                          _lowerCAmelCase    :							str   			=       -1
                   else:
                          _lowerCAmelCase    :							Optional[Any]   			=       timesteps[i + 1]

                   _lowerCAmelCase    :							int   			=       scheduler.previous_timestep(snake_case__   )
                   _lowerCAmelCase    :							int   			=       prev_t.item()

                   self.assertEqual(snake_case__      ,	snake_case__   )







     def a	( self   ):

            '''simple docstring'''

            _lowerCAmelCase    :							Optional[int]   			=       self.scheduler_classes[0]
            _lowerCAmelCase    :							Tuple   			=       self.get_scheduler_config()
            _lowerCAmelCase    :							List[Any]   			=       scheduler_class(**snake_case__   )

            _lowerCAmelCase    :							Optional[int]   			=       [100, 87, 50, 51, 0]

            with self.assertRaises(snake_case__      ,	msg='`custom_timesteps` must be in descending order.'   ):
                   scheduler.set_timesteps(timesteps=snake_case__   )







     def a	( self   ):

            '''simple docstring'''

            _lowerCAmelCase    :							Optional[int]   			=       self.scheduler_classes[0]
            _lowerCAmelCase    :							List[str]   			=       self.get_scheduler_config()
            _lowerCAmelCase    :							Union[str, Any]   			=       scheduler_class(**snake_case__   )

            _lowerCAmelCase    :							Optional[int]   			=       [100, 87, 50, 1, 0]
            _lowerCAmelCase    :							int   			=       len(snake_case__   )

            with self.assertRaises(snake_case__      ,	msg='Can only pass one of `num_inference_steps` or `custom_timesteps`.'   ):
                   scheduler.set_timesteps(num_inference_steps=snake_case__      ,	timesteps=snake_case__   )







     def a	( self   ):

            '''simple docstring'''

            _lowerCAmelCase    :							Optional[int]   			=       self.scheduler_classes[0]
            _lowerCAmelCase    :							int   			=       self.get_scheduler_config()
            _lowerCAmelCase    :							Any   			=       scheduler_class(**snake_case__   )

            _lowerCAmelCase    :							Any   			=       [scheduler.config.num_train_timesteps]

            with self.assertRaises(
                snake_case__      ,	msg='`timesteps` must start before `self.config.train_timesteps`: {scheduler.config.num_train_timesteps}}'      ,	):
                   scheduler.set_timesteps(timesteps=snake_case__   )

