





import unittest

from diffusers.models.unet_ad_blocks import *  # noqa F403
from diffusers.utils import torch_device

from .test_unet_blocks_common import UNetBlockTesterMixin







class     __lowerCAmelCase	(   UpperCamelCase__						,    unittest.TestCase):
      _lowercase    : Union[str, Any]            =      DownBlockaD  # noqa F405
      _lowercase    : Tuple            =      """down"""







      def        _lowercase  (   self							)       ->						Dict:



        '''simple docstring'''




        a__     : str  =[-0.02_32, -0.98_69, 0.80_54, -0.06_37, -0.16_88, -1.42_64, 0.44_70, -1.33_94, 0.09_04]
        super().test_output(lowerCAmelCase__							)







class     __lowerCAmelCase	(   UpperCamelCase__						,    unittest.TestCase):
      _lowercase    : Union[str, Any]            =      ResnetDownsampleBlockaD  # noqa F405
      _lowercase    : Tuple            =      """down"""







      def        _lowercase  (   self							)       ->						int:



        '''simple docstring'''




        a__     : List[Any]  =[0.07_10, 0.24_10, -0.73_20, -1.07_57, -1.13_43, 0.35_40, -0.01_33, -0.25_76, 0.09_48]
        super().test_output(lowerCAmelCase__							)







class     __lowerCAmelCase	(   UpperCamelCase__						,    unittest.TestCase):
      _lowercase    : Tuple            =      AttnDownBlockaD  # noqa F405
      _lowercase    : int            =      """down"""







      def        _lowercase  (   self							)       ->						int:



        '''simple docstring'''




        a__     : Optional[int]  =[0.06_36, 0.89_64, -0.62_34, -1.01_31, 0.08_44, 0.49_35, 0.34_37, 0.09_11, -0.29_57]
        super().test_output(lowerCAmelCase__							)







class     __lowerCAmelCase	(   UpperCamelCase__						,    unittest.TestCase):
      _lowercase    : List[str]            =      CrossAttnDownBlockaD  # noqa F405
      _lowercase    : Tuple            =      """down"""







      def        _lowercase  (   self							)       ->						List[Any]:



        '''simple docstring'''




        a__ ,							a__     : Tuple  =super().prepare_init_args_and_inputs_for_common()
        a__     : Optional[int]  =3_2
        return init_dict, inputs_dict







      def        _lowercase  (   self							)       ->						Tuple:



        '''simple docstring'''




        a__     : List[str]  =[0.22_38, -0.73_96, -0.22_55, -0.38_29, 0.19_25, 1.16_65, 0.06_03, -0.72_95, 0.19_83]
        super().test_output(lowerCAmelCase__							)







class     __lowerCAmelCase	(   UpperCamelCase__						,    unittest.TestCase):
      _lowercase    : Union[str, Any]            =      SimpleCrossAttnDownBlockaD  # noqa F405
      _lowercase    : Optional[Any]            =      """down"""







      @property
      def        _lowercase  (   self							)       ->						str:



        '''simple docstring'''




        return super().get_dummy_input(include_encoder_hidden_states=lowerCAmelCase__							)







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



        '''simple docstring'''




        a__ ,							a__     : Union[str, Any]  =super().prepare_init_args_and_inputs_for_common()
        a__     : Optional[Any]  =3_2
        return init_dict, inputs_dict







      @unittest.skipIf(torch_device == "mps"		,				"MPS result is not consistent"							)
      def        _lowercase  (   self							)       ->						Optional[int]:



        '''simple docstring'''




        a__     : List[str]  =[0.79_21, -0.09_92, -0.19_62, -0.76_95, -0.42_42, 0.78_04, 0.47_37, 0.27_65, 0.33_38]
        super().test_output(lowerCAmelCase__							)







class     __lowerCAmelCase	(   UpperCamelCase__						,    unittest.TestCase):
      _lowercase    : str            =      SkipDownBlockaD  # noqa F405
      _lowercase    : Optional[Any]            =      """down"""







      @property
      def        _lowercase  (   self							)       ->						int:



        '''simple docstring'''




        return super().get_dummy_input(include_skip_sample=lowerCAmelCase__							)







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



        '''simple docstring'''




        a__     : Tuple  =[-0.08_45, -0.20_87, -0.24_65, 0.09_71, 0.19_00, -0.04_84, 0.26_64, 0.41_79, 0.50_69]
        super().test_output(lowerCAmelCase__							)







class     __lowerCAmelCase	(   UpperCamelCase__						,    unittest.TestCase):
      _lowercase    : str            =      AttnSkipDownBlockaD  # noqa F405
      _lowercase    : int            =      """down"""







      @property
      def        _lowercase  (   self							)       ->						Optional[Any]:



        '''simple docstring'''




        return super().get_dummy_input(include_skip_sample=lowerCAmelCase__							)







      def        _lowercase  (   self							)       ->						Tuple:



        '''simple docstring'''




        a__     : Optional[Any]  =[0.55_39, 0.16_09, 0.49_24, 0.05_37, -0.19_95, 0.40_50, 0.09_79, -0.27_21, -0.06_42]
        super().test_output(lowerCAmelCase__							)







class     __lowerCAmelCase	(   UpperCamelCase__						,    unittest.TestCase):
      _lowercase    : List[str]            =      DownEncoderBlockaD  # noqa F405
      _lowercase    : Any            =      """down"""







      @property
      def        _lowercase  (   self							)       ->						Optional[Any]:



        '''simple docstring'''




        return super().get_dummy_input(include_temb=lowerCAmelCase__							)







      def        _lowercase  (   self							)       ->						str:



        '''simple docstring'''




        a__     : Any  ={
            "in_channels": 3_2,
            "out_channels": 3_2,
        }
        a__     : int  =self.dummy_input
        return init_dict, inputs_dict







      def        _lowercase  (   self							)       ->						Any:



        '''simple docstring'''




        a__     : str  =[1.11_02, 0.53_02, 0.48_72, -0.00_23, -0.80_42, 0.04_83, -0.34_89, -0.56_32, 0.76_26]
        super().test_output(lowerCAmelCase__							)







class     __lowerCAmelCase	(   UpperCamelCase__						,    unittest.TestCase):
      _lowercase    : Dict            =      AttnDownEncoderBlockaD  # noqa F405
      _lowercase    : Dict            =      """down"""







      @property
      def        _lowercase  (   self							)       ->						str:



        '''simple docstring'''




        return super().get_dummy_input(include_temb=lowerCAmelCase__							)







      def        _lowercase  (   self							)       ->						List[str]:



        '''simple docstring'''




        a__     : Dict  ={
            "in_channels": 3_2,
            "out_channels": 3_2,
        }
        a__     : Tuple  =self.dummy_input
        return init_dict, inputs_dict







      def        _lowercase  (   self							)       ->						Optional[Any]:



        '''simple docstring'''




        a__     : Optional[Any]  =[0.89_66, -0.14_86, 0.85_68, 0.81_41, -0.90_46, -0.13_42, -0.09_72, -0.74_17, 0.15_38]
        super().test_output(lowerCAmelCase__							)







class     __lowerCAmelCase	(   UpperCamelCase__						,    unittest.TestCase):
      _lowercase    : List[Any]            =      UNetMidBlockaD  # noqa F405
      _lowercase    : List[str]            =      """mid"""







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



        '''simple docstring'''




        a__     : str  ={
            "in_channels": 3_2,
            "temb_channels": 1_2_8,
        }
        a__     : str  =self.dummy_input
        return init_dict, inputs_dict







      def        _lowercase  (   self							)       ->						List[str]:



        '''simple docstring'''




        a__     : List[Any]  =[-0.10_62, 1.72_48, 0.34_94, 1.45_69, -0.09_10, -1.24_21, -0.99_84, 0.67_36, 1.00_28]
        super().test_output(lowerCAmelCase__							)







class     __lowerCAmelCase	(   UpperCamelCase__						,    unittest.TestCase):
      _lowercase    : int            =      UNetMidBlockaDCrossAttn  # noqa F405
      _lowercase    : Tuple            =      """mid"""







      def        _lowercase  (   self							)       ->						Any:



        '''simple docstring'''




        a__ ,							a__     : List[str]  =super().prepare_init_args_and_inputs_for_common()
        a__     : Tuple  =3_2
        return init_dict, inputs_dict







      def        _lowercase  (   self							)       ->						Tuple:



        '''simple docstring'''




        a__     : List[Any]  =[0.01_87, 2.42_20, 0.44_84, 1.12_03, -0.61_21, -1.51_22, -0.82_70, 0.78_51, 1.83_35]
        super().test_output(lowerCAmelCase__							)







class     __lowerCAmelCase	(   UpperCamelCase__						,    unittest.TestCase):
      _lowercase    : Tuple            =      UNetMidBlockaDSimpleCrossAttn  # noqa F405
      _lowercase    : Dict            =      """mid"""







      @property
      def        _lowercase  (   self							)       ->						int:



        '''simple docstring'''




        return super().get_dummy_input(include_encoder_hidden_states=lowerCAmelCase__							)







      def        _lowercase  (   self							)       ->						Any:



        '''simple docstring'''




        a__ ,							a__     : Tuple  =super().prepare_init_args_and_inputs_for_common()
        a__     : Any  =3_2
        return init_dict, inputs_dict







      def        _lowercase  (   self							)       ->						str:



        '''simple docstring'''




        a__     : str  =[0.71_43, 1.99_74, 0.54_48, 1.39_77, 0.12_82, -1.12_37, -1.42_38, 0.55_30, 0.88_80]
        super().test_output(lowerCAmelCase__							)







class     __lowerCAmelCase	(   UpperCamelCase__						,    unittest.TestCase):
      _lowercase    : List[str]            =      UpBlockaD  # noqa F405
      _lowercase    : Optional[Any]            =      """up"""







      @property
      def        _lowercase  (   self							)       ->						Tuple:



        '''simple docstring'''




        return super().get_dummy_input(include_res_hidden_states_tuple=lowerCAmelCase__							)







      def        _lowercase  (   self							)       ->						Tuple:



        '''simple docstring'''




        a__     : Optional[int]  =[-0.20_41, -0.41_65, -0.30_22, 0.00_41, -0.66_28, -0.70_53, 0.19_28, -0.03_25, 0.05_23]
        super().test_output(lowerCAmelCase__							)







class     __lowerCAmelCase	(   UpperCamelCase__						,    unittest.TestCase):
      _lowercase    : Optional[int]            =      ResnetUpsampleBlockaD  # noqa F405
      _lowercase    : List[Any]            =      """up"""







      @property
      def        _lowercase  (   self							)       ->						Tuple:



        '''simple docstring'''




        return super().get_dummy_input(include_res_hidden_states_tuple=lowerCAmelCase__							)







      def        _lowercase  (   self							)       ->						str:



        '''simple docstring'''




        a__     : Optional[Any]  =[0.22_87, 0.35_49, -0.13_46, 0.47_97, -0.17_15, -0.96_49, 0.73_05, -0.58_64, -0.62_44]
        super().test_output(lowerCAmelCase__							)







class     __lowerCAmelCase	(   UpperCamelCase__						,    unittest.TestCase):
      _lowercase    : List[str]            =      CrossAttnUpBlockaD  # noqa F405
      _lowercase    : Optional[int]            =      """up"""







      @property
      def        _lowercase  (   self							)       ->						Union[str, Any]:



        '''simple docstring'''




        return super().get_dummy_input(include_res_hidden_states_tuple=lowerCAmelCase__							)







      def        _lowercase  (   self							)       ->						Tuple:



        '''simple docstring'''




        a__ ,							a__     : Optional[int]  =super().prepare_init_args_and_inputs_for_common()
        a__     : Tuple  =3_2
        return init_dict, inputs_dict







      def        _lowercase  (   self							)       ->						Optional[Any]:



        '''simple docstring'''




        a__     : Optional[int]  =[-0.14_03, -0.35_15, -0.04_20, -0.14_25, 0.31_67, 0.50_94, -0.21_81, 0.59_31, 0.55_82]
        super().test_output(lowerCAmelCase__							)







class     __lowerCAmelCase	(   UpperCamelCase__						,    unittest.TestCase):
      _lowercase    : Optional[Any]            =      SimpleCrossAttnUpBlockaD  # noqa F405
      _lowercase    : Optional[int]            =      """up"""







      @property
      def        _lowercase  (   self							)       ->						List[Any]:



        '''simple docstring'''




        return super().get_dummy_input(include_res_hidden_states_tuple=lowerCAmelCase__		,				include_encoder_hidden_states=lowerCAmelCase__							)







      def        _lowercase  (   self							)       ->						Any:



        '''simple docstring'''




        a__ ,							a__     : str  =super().prepare_init_args_and_inputs_for_common()
        a__     : Tuple  =3_2
        return init_dict, inputs_dict







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



        '''simple docstring'''




        a__     : Tuple  =[0.26_45, 0.14_80, 0.09_09, 0.80_44, -0.97_58, -0.90_83, 0.09_94, -1.14_53, -0.74_02]
        super().test_output(lowerCAmelCase__							)







class     __lowerCAmelCase	(   UpperCamelCase__						,    unittest.TestCase):
      _lowercase    : str            =      AttnUpBlockaD  # noqa F405
      _lowercase    : Tuple            =      """up"""







      @property
      def        _lowercase  (   self							)       ->						Union[str, Any]:



        '''simple docstring'''




        return super().get_dummy_input(include_res_hidden_states_tuple=lowerCAmelCase__							)







      @unittest.skipIf(torch_device == "mps"		,				"MPS result is not consistent"							)
      def        _lowercase  (   self							)       ->						Union[str, Any]:



        '''simple docstring'''




        a__     : Dict  =[0.09_79, 0.13_26, 0.00_21, 0.06_59, 0.22_49, 0.00_59, 0.11_32, 0.59_52, 0.10_33]
        super().test_output(lowerCAmelCase__							)







class     __lowerCAmelCase	(   UpperCamelCase__						,    unittest.TestCase):
      _lowercase    : Optional[Any]            =      SkipUpBlockaD  # noqa F405
      _lowercase    : Dict            =      """up"""







      @property
      def        _lowercase  (   self							)       ->						str:



        '''simple docstring'''




        return super().get_dummy_input(include_res_hidden_states_tuple=lowerCAmelCase__							)







      def        _lowercase  (   self							)       ->						Tuple:



        '''simple docstring'''




        a__     : Optional[int]  =[-0.08_93, -0.12_34, -0.15_06, -0.03_32, 0.01_23, -0.02_11, 0.05_66, 0.01_43, 0.03_62]
        super().test_output(lowerCAmelCase__							)







class     __lowerCAmelCase	(   UpperCamelCase__						,    unittest.TestCase):
      _lowercase    : Dict            =      AttnSkipUpBlockaD  # noqa F405
      _lowercase    : Union[str, Any]            =      """up"""







      @property
      def        _lowercase  (   self							)       ->						Dict:



        '''simple docstring'''




        return super().get_dummy_input(include_res_hidden_states_tuple=lowerCAmelCase__							)







      def        _lowercase  (   self							)       ->						str:



        '''simple docstring'''




        a__     : Union[str, Any]  =[0.03_61, 0.06_17, 0.27_87, -0.03_50, 0.03_42, 0.34_21, -0.08_43, 0.09_13, 0.30_15]
        super().test_output(lowerCAmelCase__							)







class     __lowerCAmelCase	(   UpperCamelCase__						,    unittest.TestCase):
      _lowercase    : Dict            =      UpDecoderBlockaD  # noqa F405
      _lowercase    : Tuple            =      """up"""







      @property
      def        _lowercase  (   self							)       ->						Optional[Any]:



        '''simple docstring'''




        return super().get_dummy_input(include_temb=lowerCAmelCase__							)







      def        _lowercase  (   self							)       ->						List[str]:



        '''simple docstring'''




        a__     : Tuple  ={"in_channels": 3_2, "out_channels": 3_2}

        a__     : List[Any]  =self.dummy_input
        return init_dict, inputs_dict







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



        '''simple docstring'''




        a__     : str  =[0.44_04, 0.19_98, -0.98_86, -0.33_20, -0.31_28, -0.70_34, -0.69_55, -0.23_38, -0.31_37]
        super().test_output(lowerCAmelCase__							)







class     __lowerCAmelCase	(   UpperCamelCase__						,    unittest.TestCase):
      _lowercase    : List[str]            =      AttnUpDecoderBlockaD  # noqa F405
      _lowercase    : List[Any]            =      """up"""







      @property
      def        _lowercase  (   self							)       ->						Dict:



        '''simple docstring'''




        return super().get_dummy_input(include_temb=lowerCAmelCase__							)







      def        _lowercase  (   self							)       ->						Dict:



        '''simple docstring'''




        a__     : List[Any]  ={"in_channels": 3_2, "out_channels": 3_2}

        a__     : Dict  =self.dummy_input
        return init_dict, inputs_dict







      def        _lowercase  (   self							)       ->						str:



        '''simple docstring'''




        a__     : List[str]  =[0.67_38, 0.44_91, 0.10_55, 1.07_10, 0.73_16, 0.33_39, 0.33_52, 0.10_23, 0.35_68]
        super().test_output(lowerCAmelCase__							)













import tempfile

import torch

from diffusers import PNDMScheduler

from .test_schedulers import SchedulerCommonTest







class     __lowerCAmelCase	(   UpperCamelCase__):
      _lowercase    : Any            =      (PNDMScheduler,)
      _lowercase    : str            =      (("""num_inference_steps""", 50),)







      def        _lowercase  (   self		,				**lowerCAmelCase__							)       ->						int:



        '''simple docstring'''




        a__     : Dict  ={
            "num_train_timesteps": 1_0_0_0,
            "beta_start": 0.00_01,
            "beta_end": 0.02,
            "beta_schedule": "linear",
        }

        config.update(**lowerCAmelCase__							)
        return config







      def        _lowercase  (   self		,				lowerCAmelCase__=0		,				**lowerCAmelCase__							)       ->						List[Any]:



        '''simple docstring'''




        a__     : Optional[int]  =dict(self.forward_default_kwargs							)
        a__     : Tuple  =kwargs.pop("num_inference_steps"		,				lowerCAmelCase__							)
        a__     : List[str]  =self.dummy_sample
        a__     : List[str]  =0.1 * sample
        a__     : str  =[residual + 0.2, residual + 0.15, residual + 0.1, residual + 0.05]

        for scheduler_class in self.scheduler_classes:
          a__     : int  =self.get_scheduler_config(**lowerCAmelCase__							)
          a__     : Union[str, Any]  =scheduler_class(**lowerCAmelCase__							)
          scheduler.set_timesteps(lowerCAmelCase__							)
          # copy over dummy past residuals
          a__     : Any  =dummy_past_residuals[:]

          with tempfile.TemporaryDirectory() as tmpdirname:
            scheduler.save_config(lowerCAmelCase__							)
            a__     : List[Any]  =scheduler_class.from_pretrained(lowerCAmelCase__							)
            new_scheduler.set_timesteps(lowerCAmelCase__							)
            # copy over dummy past residuals
            a__     : str  =dummy_past_residuals[:]

          a__     : Any  =scheduler.step_prk(lowerCAmelCase__		,				lowerCAmelCase__		,				lowerCAmelCase__		,				**lowerCAmelCase__							).prev_sample
          a__     : Dict  =new_scheduler.step_prk(lowerCAmelCase__		,				lowerCAmelCase__		,				lowerCAmelCase__		,				**lowerCAmelCase__							).prev_sample

          assert torch.sum(torch.abs(output - new_output							)							) < 1E-5, "Scheduler outputs are not identical"

          a__     : Optional[int]  =scheduler.step_plms(lowerCAmelCase__		,				lowerCAmelCase__		,				lowerCAmelCase__		,				**lowerCAmelCase__							).prev_sample
          a__     : Union[str, Any]  =new_scheduler.step_plms(lowerCAmelCase__		,				lowerCAmelCase__		,				lowerCAmelCase__		,				**lowerCAmelCase__							).prev_sample

          assert torch.sum(torch.abs(output - new_output							)							) < 1E-5, "Scheduler outputs are not identical"







      def        _lowercase  (   self							)       ->						int:



        '''simple docstring'''




        pass







      def        _lowercase  (   self		,				lowerCAmelCase__=0		,				**lowerCAmelCase__							)       ->						Optional[Any]:



        '''simple docstring'''




        a__     : Optional[int]  =dict(self.forward_default_kwargs							)
        a__     : List[str]  =kwargs.pop("num_inference_steps"		,				lowerCAmelCase__							)
        a__     : List[str]  =self.dummy_sample
        a__     : int  =0.1 * sample
        a__     : Tuple  =[residual + 0.2, residual + 0.15, residual + 0.1, residual + 0.05]

        for scheduler_class in self.scheduler_classes:
          a__     : Dict  =self.get_scheduler_config()
          a__     : List[str]  =scheduler_class(**lowerCAmelCase__							)
          scheduler.set_timesteps(lowerCAmelCase__							)

          # copy over dummy past residuals (must be after setting timesteps)
          a__     : Dict  =dummy_past_residuals[:]

          with tempfile.TemporaryDirectory() as tmpdirname:
            scheduler.save_config(lowerCAmelCase__							)
            a__     : Dict  =scheduler_class.from_pretrained(lowerCAmelCase__							)
            # copy over dummy past residuals
            new_scheduler.set_timesteps(lowerCAmelCase__							)

            # copy over dummy past residual (must be after setting timesteps)
            a__     : Optional[int]  =dummy_past_residuals[:]

          a__     : Optional[Any]  =scheduler.step_prk(lowerCAmelCase__		,				lowerCAmelCase__		,				lowerCAmelCase__		,				**lowerCAmelCase__							).prev_sample
          a__     : List[Any]  =new_scheduler.step_prk(lowerCAmelCase__		,				lowerCAmelCase__		,				lowerCAmelCase__		,				**lowerCAmelCase__							).prev_sample

          assert torch.sum(torch.abs(output - new_output							)							) < 1E-5, "Scheduler outputs are not identical"

          a__     : List[str]  =scheduler.step_plms(lowerCAmelCase__		,				lowerCAmelCase__		,				lowerCAmelCase__		,				**lowerCAmelCase__							).prev_sample
          a__     : Any  =new_scheduler.step_plms(lowerCAmelCase__		,				lowerCAmelCase__		,				lowerCAmelCase__		,				**lowerCAmelCase__							).prev_sample

          assert torch.sum(torch.abs(output - new_output							)							) < 1E-5, "Scheduler outputs are not identical"







      def        _lowercase  (   self		,				**lowerCAmelCase__							)       ->						int:



        '''simple docstring'''




        a__     : Union[str, Any]  =self.scheduler_classes[0]
        a__     : Optional[Any]  =self.get_scheduler_config(**lowerCAmelCase__							)
        a__     : Any  =scheduler_class(**lowerCAmelCase__							)

        a__     : int  =1_0
        a__     : Union[str, Any]  =self.dummy_model()
        a__     : Optional[int]  =self.dummy_sample_deter
        scheduler.set_timesteps(lowerCAmelCase__							)

        for i, t in enumerate(scheduler.prk_timesteps							):
          a__     : List[Any]  =model(lowerCAmelCase__		,				lowerCAmelCase__							)
          a__     : Optional[Any]  =scheduler.step_prk(lowerCAmelCase__		,				lowerCAmelCase__		,				lowerCAmelCase__							).prev_sample

        for i, t in enumerate(scheduler.plms_timesteps							):
          a__     : int  =model(lowerCAmelCase__		,				lowerCAmelCase__							)
          a__     : int  =scheduler.step_plms(lowerCAmelCase__		,				lowerCAmelCase__		,				lowerCAmelCase__							).prev_sample

        return sample







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



        '''simple docstring'''




        a__     : str  =dict(self.forward_default_kwargs							)

        a__     : Tuple  =kwargs.pop("num_inference_steps"		,				lowerCAmelCase__							)

        for scheduler_class in self.scheduler_classes:
          a__     : Union[str, Any]  =self.get_scheduler_config()
          a__     : List[str]  =scheduler_class(**lowerCAmelCase__							)

          a__     : List[Any]  =self.dummy_sample
          a__     : Dict  =0.1 * sample

          if num_inference_steps is not None and hasattr(lowerCAmelCase__		,				"set_timesteps"							):
            scheduler.set_timesteps(lowerCAmelCase__							)
          elif num_inference_steps is not None and not hasattr(lowerCAmelCase__		,				"set_timesteps"							):
            a__     : int  =num_inference_steps

          # copy over dummy past residuals (must be done after set_timesteps)
          a__     : Tuple  =[residual + 0.2, residual + 0.15, residual + 0.1, residual + 0.05]
          a__     : str  =dummy_past_residuals[:]

          a__     : List[Any]  =scheduler.step_prk(lowerCAmelCase__		,				0		,				lowerCAmelCase__		,				**lowerCAmelCase__							).prev_sample
          a__     : int  =scheduler.step_prk(lowerCAmelCase__		,				1		,				lowerCAmelCase__		,				**lowerCAmelCase__							).prev_sample

          self.assertEqual(output_a.shape		,				sample.shape							)
          self.assertEqual(output_a.shape		,				output_a.shape							)

          a__     : List[str]  =scheduler.step_plms(lowerCAmelCase__		,				0		,				lowerCAmelCase__		,				**lowerCAmelCase__							).prev_sample
          a__     : Dict  =scheduler.step_plms(lowerCAmelCase__		,				1		,				lowerCAmelCase__		,				**lowerCAmelCase__							).prev_sample

          self.assertEqual(output_a.shape		,				sample.shape							)
          self.assertEqual(output_a.shape		,				output_a.shape							)







      def        _lowercase  (   self							)       ->						Tuple:



        '''simple docstring'''




        for timesteps in [1_0_0, 1_0_0_0]:
          self.check_over_configs(num_train_timesteps=lowerCAmelCase__							)







      def        _lowercase  (   self							)       ->						Optional[Any]:



        '''simple docstring'''




        for steps_offset in [0, 1]:
          self.check_over_configs(steps_offset=lowerCAmelCase__							)

        a__     : Optional[Any]  =self.scheduler_classes[0]
        a__     : Tuple  =self.get_scheduler_config(steps_offset=1							)
        a__     : Optional[Any]  =scheduler_class(**lowerCAmelCase__							)
        scheduler.set_timesteps(1_0							)
        assert torch.equal(
            scheduler.timesteps		,				torch.LongTensor(
                [9_0_1, 8_5_1, 8_5_1, 8_0_1, 8_0_1, 7_5_1, 7_5_1, 7_0_1, 7_0_1, 6_5_1, 6_5_1, 6_0_1, 6_0_1, 5_0_1, 4_0_1, 3_0_1, 2_0_1, 1_0_1, 1]							)		,				)







      def        _lowercase  (   self							)       ->						Tuple:



        '''simple docstring'''




        for beta_start, beta_end in zip([0.00_01, 0.0_01]		,				[0.0_02, 0.02]							):
          self.check_over_configs(beta_start=lowerCAmelCase__		,				beta_end=lowerCAmelCase__							)







      def        _lowercase  (   self							)       ->						List[str]:



        '''simple docstring'''




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







      def        _lowercase  (   self							)       ->						List[str]:



        '''simple docstring'''




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







      def        _lowercase  (   self							)       ->						Dict:



        '''simple docstring'''




        for t in [1, 5, 1_0]:
          self.check_over_forward(time_step=lowerCAmelCase__							)







      def        _lowercase  (   self							)       ->						List[Any]:



        '''simple docstring'''




        for t, num_inference_steps in zip([1, 5, 1_0]		,				[1_0, 5_0, 1_0_0]							):
          self.check_over_forward(num_inference_steps=lowerCAmelCase__							)







      def        _lowercase  (   self							)       ->						str:



        '''simple docstring'''




        a__     : Dict  =2_7

        for scheduler_class in self.scheduler_classes:
          a__     : Tuple  =self.dummy_sample
          a__     : Dict  =0.1 * sample

          a__     : Dict  =self.get_scheduler_config()
          a__     : int  =scheduler_class(**lowerCAmelCase__							)

          scheduler.set_timesteps(lowerCAmelCase__							)

          # before power of 3 fix, would error on first step, so we only need to do two
          for i, t in enumerate(scheduler.prk_timesteps[:2]							):
            a__     : Any  =scheduler.step_prk(lowerCAmelCase__		,				lowerCAmelCase__		,				lowerCAmelCase__							).prev_sample







      def        _lowercase  (   self							)       ->						Optional[Any]:



        '''simple docstring'''




        with self.assertRaises(lowerCAmelCase__							):
          a__     : List[Any]  =self.scheduler_classes[0]
          a__     : Dict  =self.get_scheduler_config()
          a__     : Tuple  =scheduler_class(**lowerCAmelCase__							)

          scheduler.step_plms(self.dummy_sample		,				1		,				self.dummy_sample							).prev_sample







      def        _lowercase  (   self							)       ->						Optional[Any]:



        '''simple docstring'''




        a__     : List[Any]  =self.full_loop()
        a__     : str  =torch.sum(torch.abs(lowerCAmelCase__							)							)
        a__     : Optional[Any]  =torch.mean(torch.abs(lowerCAmelCase__							)							)

        assert abs(result_sum.item() - 1_98.13_18							) < 1E-2
        assert abs(result_mean.item() - 0.25_80							) < 1E-3







      def        _lowercase  (   self							)       ->						str:



        '''simple docstring'''




        a__     : str  =self.full_loop(prediction_type="v_prediction"							)
        a__     : int  =torch.sum(torch.abs(lowerCAmelCase__							)							)
        a__     : Optional[int]  =torch.mean(torch.abs(lowerCAmelCase__							)							)

        assert abs(result_sum.item() - 67.39_86							) < 1E-2
        assert abs(result_mean.item() - 0.08_78							) < 1E-3







      def        _lowercase  (   self							)       ->						Optional[int]:



        '''simple docstring'''




        a__     : Tuple  =self.full_loop(set_alpha_to_one=lowerCAmelCase__		,				beta_start=0.01							)
        a__     : str  =torch.sum(torch.abs(lowerCAmelCase__							)							)
        a__     : Dict  =torch.mean(torch.abs(lowerCAmelCase__							)							)

        assert abs(result_sum.item() - 2_30.03_99							) < 1E-2
        assert abs(result_mean.item() - 0.29_95							) < 1E-3







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



        '''simple docstring'''




        a__     : Dict  =self.full_loop(set_alpha_to_one=lowerCAmelCase__		,				beta_start=0.01							)
        a__     : Union[str, Any]  =torch.sum(torch.abs(lowerCAmelCase__							)							)
        a__     : Union[str, Any]  =torch.mean(torch.abs(lowerCAmelCase__							)							)

        assert abs(result_sum.item() - 1_86.94_82							) < 1E-2
        assert abs(result_mean.item() - 0.24_34							) < 1E-3






