
"""simple docstring"""


import os
import tempfile
import unittest

from transformers import DistilBertConfig, is_torch_available
from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
		import torch

		from transformers import (
		    DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
		    DistilBertForMaskedLM,
		    DistilBertForMultipleChoice,
		    DistilBertForQuestionAnswering,
		    DistilBertForSequenceClassification,
		    DistilBertForTokenClassification,
		    DistilBertModel,
		)







class 					lowerCAmelCase_					(   _lowercase     ):



						'''simple docstring'''


						def __init__(			self  :   Union[str, Any]	,A_  :   List[Any]	,A_  :   List[str]=13	,A_  :   Union[str, Any]=7	,A_  :   Dict=True	,A_  :   List[str]=True	,A_  :   str=False	,A_  :   Any=True	,A_  :   Any=99	,A_  :   List[Any]=32	,A_  :   int=5	,A_  :   Tuple=4	,A_  :   Optional[Any]=37	,A_  :   Optional[Any]="gelu"	,A_  :   str=0.1	,A_  :   Optional[Any]=0.1	,A_  :   Union[str, Any]=512	,A_  :   Any=16	,A_  :   Dict=2	,A_  :   str=0.02	,A_  :   Union[str, Any]=3	,A_  :   Tuple=4	,A_  :   Any=None	,)  -> Optional[int]:
							A     = parent
							A     = batch_size
							A     = seq_length
							A     = is_training
							A     = use_input_mask
							A     = use_token_type_ids
							A     = use_labels
							A     = vocab_size
							A     = hidden_size
							A     = num_hidden_layers
							A     = num_attention_heads
							A     = intermediate_size
							A     = hidden_act
							A     = hidden_dropout_prob
							A     = attention_probs_dropout_prob
							A     = max_position_embeddings
							A     = type_vocab_size
							A     = type_sequence_label_size
							A     = initializer_range
							A     = num_labels
							A     = num_choices
							A     = scope


						def     _SCREAMING_SNAKE_CASE   (			self  :   Any   )  -> int:
							A     = ids_tensor([self.batch_size, self.seq_length]	,self.vocab_size   )

							A     = None
							if self.use_input_mask:
								A     = random_attention_mask([self.batch_size, self.seq_length]   )

							A     = None
							A     = None
							A     = None
							if self.use_labels:
								A     = ids_tensor([self.batch_size]	,self.type_sequence_label_size   )
								A     = ids_tensor([self.batch_size, self.seq_length]	,self.num_labels   )
								A     = ids_tensor([self.batch_size]	,self.num_choices   )

							A     = self.get_config()

							return config, input_ids, input_mask, sequence_labels, token_labels, choice_labels


						def     _SCREAMING_SNAKE_CASE   (			self  :   int   )  -> List[str]:
							return DistilBertConfig(
							    vocab_size=self.vocab_size	,dim=self.hidden_size	,n_layers=self.num_hidden_layers	,n_heads=self.num_attention_heads	,hidden_dim=self.intermediate_size	,hidden_act=self.hidden_act	,dropout=self.hidden_dropout_prob	,attention_dropout=self.attention_probs_dropout_prob	,max_position_embeddings=self.max_position_embeddings	,initializer_range=self.initializer_range	,)


						def     _SCREAMING_SNAKE_CASE   (			self  :   Optional[int]	,A_  :   Dict	,A_  :   Optional[int]	,A_  :   Union[str, Any]	,A_  :   Union[str, Any]	,A_  :   str	,A_  :   Optional[Any]   )  -> Optional[Any]:
							A     = DistilBertModel(config=A_   )
							model.to(A_   )
							model.eval()
							A     = model(A_	,A_   )
							A     = model(A_   )
							self.parent.assertEqual(result.last_hidden_state.shape	,(self.batch_size, self.seq_length, self.hidden_size)   )


						def     _SCREAMING_SNAKE_CASE   (			self  :   int	,A_  :   Tuple	,A_  :   Optional[int]	,A_  :   Dict	,A_  :   int	,A_  :   List[Any]	,A_  :   int   )  -> List[Any]:
							A     = DistilBertForMaskedLM(config=A_   )
							model.to(A_   )
							model.eval()
							A     = model(A_	,attention_mask=A_	,labels=A_   )
							self.parent.assertEqual(result.logits.shape	,(self.batch_size, self.seq_length, self.vocab_size)   )


						def     _SCREAMING_SNAKE_CASE   (			self  :   Optional[Any]	,A_  :   Optional[int]	,A_  :   Dict	,A_  :   int	,A_  :   int	,A_  :   str	,A_  :   Any   )  -> Optional[Any]:
							A     = DistilBertForQuestionAnswering(config=A_   )
							model.to(A_   )
							model.eval()
							A     = model(
							    A_	,attention_mask=A_	,start_positions=A_	,end_positions=A_   )
							self.parent.assertEqual(result.start_logits.shape	,(self.batch_size, self.seq_length)   )
							self.parent.assertEqual(result.end_logits.shape	,(self.batch_size, self.seq_length)   )


						def     _SCREAMING_SNAKE_CASE   (			self  :   int	,A_  :   Union[str, Any]	,A_  :   List[Any]	,A_  :   Optional[Any]	,A_  :   int	,A_  :   List[Any]	,A_  :   Optional[Any]   )  -> Optional[Any]:
							A     = self.num_labels
							A     = DistilBertForSequenceClassification(A_   )
							model.to(A_   )
							model.eval()
							A     = model(A_	,attention_mask=A_	,labels=A_   )
							self.parent.assertEqual(result.logits.shape	,(self.batch_size, self.num_labels)   )


						def     _SCREAMING_SNAKE_CASE   (			self  :   Dict	,A_  :   List[str]	,A_  :   Tuple	,A_  :   List[str]	,A_  :   str	,A_  :   Union[str, Any]	,A_  :   List[str]   )  -> Optional[Any]:
							A     = self.num_labels
							A     = DistilBertForTokenClassification(config=A_   )
							model.to(A_   )
							model.eval()

							A     = model(A_	,attention_mask=A_	,labels=A_   )
							self.parent.assertEqual(result.logits.shape	,(self.batch_size, self.seq_length, self.num_labels)   )


						def     _SCREAMING_SNAKE_CASE   (			self  :   int	,A_  :   Union[str, Any]	,A_  :   List[Any]	,A_  :   Union[str, Any]	,A_  :   int	,A_  :   List[str]	,A_  :   Tuple   )  -> Optional[int]:
							A     = self.num_choices
							A     = DistilBertForMultipleChoice(config=A_   )
							model.to(A_   )
							model.eval()
							A     = input_ids.unsqueeze(1   ).expand(-1	,self.num_choices	,-1   ).contiguous()
							A     = input_mask.unsqueeze(1   ).expand(-1	,self.num_choices	,-1   ).contiguous()
							A     = model(
							    A_	,attention_mask=A_	,labels=A_	,)
							self.parent.assertEqual(result.logits.shape	,(self.batch_size, self.num_choices)   )




						def     _SCREAMING_SNAKE_CASE   (			self  :   str   )  -> Tuple:
							A     = self.prepare_config_and_inputs()
							((A) ,   (A) ,   (A) ,   (A) ,   (A) ,   (A))     = config_and_inputs
							A     = {'input_ids': input_ids, 'attention_mask': input_mask}
							return config, inputs_dict







@require_torch
class 					lowerCAmelCase_					(   _lowercase		,       _lowercase		,       unittest.TestCase     ):



						'''simple docstring'''


						_lowerCamelCase:     List[str]   =     (
						    (
						        DistilBertModel,
						        DistilBertForMaskedLM,
						        DistilBertForMultipleChoice,
						        DistilBertForQuestionAnswering,
						        DistilBertForSequenceClassification,
						        DistilBertForTokenClassification,
						    )
						    if is_torch_available()
						    else None
						)
						_lowerCamelCase:     Optional[Any]   =     (
						    {
						        '''feature-extraction''': DistilBertModel,
						        '''fill-mask''': DistilBertForMaskedLM,
						        '''question-answering''': DistilBertForQuestionAnswering,
						        '''text-classification''': DistilBertForSequenceClassification,
						        '''token-classification''': DistilBertForTokenClassification,
						        '''zero-shot''': DistilBertForSequenceClassification,
						    }
						    if is_torch_available()
						    else {}
						)
						_lowerCamelCase:     Dict   =     True
						_lowerCamelCase:     Dict   =     True
						_lowerCamelCase:     List[str]   =     True
						_lowerCamelCase:     Any   =     True


						def     _SCREAMING_SNAKE_CASE   (			self  :   List[str]   )  -> List[Any]:
							A     = DistilBertModelTester(self   )
							A     = ConfigTester(self	,config_class=A_	,dim=37   )


						def     _SCREAMING_SNAKE_CASE   (			self  :   Optional[int]   )  -> Optional[Any]:
							self.config_tester.run_common_tests()


						def     _SCREAMING_SNAKE_CASE   (			self  :   Tuple   )  -> Any:
							A     = self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_distilbert_model(*A_   )


						def     _SCREAMING_SNAKE_CASE   (			self  :   Optional[Any]   )  -> List[Any]:
							A     = self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_distilbert_for_masked_lm(*A_   )


						def     _SCREAMING_SNAKE_CASE   (			self  :   List[str]   )  -> Tuple:
							A     = self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_distilbert_for_question_answering(*A_   )


						def     _SCREAMING_SNAKE_CASE   (			self  :   str   )  -> Union[str, Any]:
							A     = self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_distilbert_for_sequence_classification(*A_   )


						def     _SCREAMING_SNAKE_CASE   (			self  :   Optional[Any]   )  -> Optional[int]:
							A     = self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_distilbert_for_token_classification(*A_   )


						def     _SCREAMING_SNAKE_CASE   (			self  :   List[str]   )  -> List[str]:
							A     = self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_distilbert_for_multiple_choice(*A_   )


						@slow
						def     _SCREAMING_SNAKE_CASE   (			self  :   List[Any]   )  -> int:
							for model_name in DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
								A     = DistilBertModel.from_pretrained(A_   )
								self.assertIsNotNone(A_   )




						@slow
						@require_torch_gpu
						def     _SCREAMING_SNAKE_CASE   (			self  :   List[Any]   )  -> Tuple:
							A ,   A     = self.model_tester.prepare_config_and_inputs_for_common()
							for model_class in self.all_model_classes:
								# BertForMultipleChoice behaves incorrectly in JIT environments.
								if model_class == DistilBertForMultipleChoice:
									return

								A     = True
								A     = model_class(config=A_   )

								A     = self._prepare_for_class(A_	,A_   )
								A     = torch.jit.trace(
								    A_	,(inputs_dict['input_ids'].to('cpu'   ), inputs_dict['attention_mask'].to('cpu'   ))   )

								with tempfile.TemporaryDirectory() as tmp:
									torch.jit.save(A_	,os.path.join(A_	,'traced_model.pt'   )   )
									A     = torch.jit.load(os.path.join(A_	,'traced_model.pt'   )	,map_location=A_   )
									loaded(inputs_dict['input_ids'].to(A_   )	,inputs_dict['attention_mask'].to(A_   )   )







@require_torch
class 					lowerCAmelCase_					(   unittest.TestCase     ):



						'''simple docstring'''


						@slow
						def     _SCREAMING_SNAKE_CASE   (			self  :   Optional[int]   )  -> Tuple:
							A     = DistilBertModel.from_pretrained('distilbert-base-uncased'   )
							A     = torch.tensor([[0, 345, 232, 328, 740, 140, 1695, 69, 6078, 1588, 2]]   )
							A     = torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]   )
							with torch.no_grad():
								A     = model(A_	,attention_mask=A_   )[0]
							A     = torch.Size((1, 11, 768)   )
							self.assertEqual(output.shape	,A_   )
							A     = torch.tensor(
							    [[[-0.16_39, 0.32_99, 0.16_48], [-0.17_46, 0.32_89, 0.17_10], [-0.18_84, 0.33_57, 0.18_10]]]   )

							self.assertTrue(torch.allclose(output[:, 1:4, 1:4]	,A_	,atol=1e-4   )   )







import tempfile

import torch

from diffusers import PNDMScheduler

from .test_schedulers import SchedulerCommonTest



class 				_UpperCamelCase      (a_      ):
      snake_case_	=				(PNDMScheduler,)
      snake_case_	=				(("""num_inference_steps""", 50),)


      def 			__UpperCAmelCase		(						self       ,    **__UpperCamelCase						)->						int:
           __lowerCAmelCase             =       {
               "num_train_timesteps": 1_0_0_0,
               "beta_start": 0.0_0_0_1,
               "beta_end": 0.0_2,
               "beta_schedule": "linear",
           }

           config.update(**__UpperCamelCase						)
           return config


      def 			__UpperCAmelCase		(						self       ,    __UpperCamelCase=0       ,    **__UpperCamelCase						)->						Optional[int]:
           __lowerCAmelCase             =       dict(self.forward_default_kwargs						)
           __lowerCAmelCase             =       kwargs.pop("num_inference_steps"       ,    __UpperCamelCase						)
           __lowerCAmelCase             =       self.dummy_sample
           __lowerCAmelCase             =       0.1 * sample
           __lowerCAmelCase             =       [residual + 0.2, residual + 0.1_5, residual + 0.1, residual + 0.0_5]

           for scheduler_class in self.scheduler_classes:
                __lowerCAmelCase             =       self.get_scheduler_config(**__UpperCamelCase						)
                __lowerCAmelCase             =       scheduler_class(**__UpperCamelCase						)
                scheduler.set_timesteps(__UpperCamelCase						)
                # copy over dummy past residuals
                __lowerCAmelCase             =       dummy_past_residuals[:]

                with tempfile.TemporaryDirectory() as tmpdirname:
                     scheduler.save_config(__UpperCamelCase						)
                     __lowerCAmelCase             =       scheduler_class.from_pretrained(__UpperCamelCase						)
                     new_scheduler.set_timesteps(__UpperCamelCase						)
                     # copy over dummy past residuals
                     __lowerCAmelCase             =       dummy_past_residuals[:]

                __lowerCAmelCase             =       scheduler.step_prk(__UpperCamelCase       ,    __UpperCamelCase       ,    __UpperCamelCase       ,    **__UpperCamelCase						).prev_sample
                __lowerCAmelCase             =       new_scheduler.step_prk(__UpperCamelCase       ,    __UpperCamelCase       ,    __UpperCamelCase       ,    **__UpperCamelCase						).prev_sample

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

                __lowerCAmelCase             =       scheduler.step_plms(__UpperCamelCase       ,    __UpperCamelCase       ,    __UpperCamelCase       ,    **__UpperCamelCase						).prev_sample
                __lowerCAmelCase             =       new_scheduler.step_plms(__UpperCamelCase       ,    __UpperCamelCase       ,    __UpperCamelCase       ,    **__UpperCamelCase						).prev_sample

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


      def 			__UpperCAmelCase		(						self						)->						Dict:
           pass


      def 			__UpperCAmelCase		(						self       ,    __UpperCamelCase=0       ,    **__UpperCamelCase						)->						Dict:
           __lowerCAmelCase             =       dict(self.forward_default_kwargs						)
           __lowerCAmelCase             =       kwargs.pop("num_inference_steps"       ,    __UpperCamelCase						)
           __lowerCAmelCase             =       self.dummy_sample
           __lowerCAmelCase             =       0.1 * sample
           __lowerCAmelCase             =       [residual + 0.2, residual + 0.1_5, residual + 0.1, residual + 0.0_5]

           for scheduler_class in self.scheduler_classes:
                __lowerCAmelCase             =       self.get_scheduler_config()
                __lowerCAmelCase             =       scheduler_class(**__UpperCamelCase						)
                scheduler.set_timesteps(__UpperCamelCase						)

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

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

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

                __lowerCAmelCase             =       scheduler.step_prk(__UpperCamelCase       ,    __UpperCamelCase       ,    __UpperCamelCase       ,    **__UpperCamelCase						).prev_sample
                __lowerCAmelCase             =       new_scheduler.step_prk(__UpperCamelCase       ,    __UpperCamelCase       ,    __UpperCamelCase       ,    **__UpperCamelCase						).prev_sample

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

                __lowerCAmelCase             =       scheduler.step_plms(__UpperCamelCase       ,    __UpperCamelCase       ,    __UpperCamelCase       ,    **__UpperCamelCase						).prev_sample
                __lowerCAmelCase             =       new_scheduler.step_plms(__UpperCamelCase       ,    __UpperCamelCase       ,    __UpperCamelCase       ,    **__UpperCamelCase						).prev_sample

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


      def 			__UpperCAmelCase		(						self       ,    **__UpperCamelCase						)->						Tuple:
           __lowerCAmelCase             =       self.scheduler_classes[0]
           __lowerCAmelCase             =       self.get_scheduler_config(**__UpperCamelCase						)
           __lowerCAmelCase             =       scheduler_class(**__UpperCamelCase						)

           __lowerCAmelCase             =       1_0
           __lowerCAmelCase             =       self.dummy_model()
           __lowerCAmelCase             =       self.dummy_sample_deter
           scheduler.set_timesteps(__UpperCamelCase						)

           for i, t in enumerate(scheduler.prk_timesteps						):
                __lowerCAmelCase             =       model(__UpperCamelCase       ,    __UpperCamelCase						)
                __lowerCAmelCase             =       scheduler.step_prk(__UpperCamelCase       ,    __UpperCamelCase       ,    __UpperCamelCase						).prev_sample

           for i, t in enumerate(scheduler.plms_timesteps						):
                __lowerCAmelCase             =       model(__UpperCamelCase       ,    __UpperCamelCase						)
                __lowerCAmelCase             =       scheduler.step_plms(__UpperCamelCase       ,    __UpperCamelCase       ,    __UpperCamelCase						).prev_sample

           return sample


      def 			__UpperCAmelCase		(						self						)->						int:
           __lowerCAmelCase             =       dict(self.forward_default_kwargs						)

           __lowerCAmelCase             =       kwargs.pop("num_inference_steps"       ,    __UpperCamelCase						)

           for scheduler_class in self.scheduler_classes:
                __lowerCAmelCase             =       self.get_scheduler_config()
                __lowerCAmelCase             =       scheduler_class(**__UpperCamelCase						)

                __lowerCAmelCase             =       self.dummy_sample
                __lowerCAmelCase             =       0.1 * sample

                if num_inference_steps is not None and hasattr(__UpperCamelCase       ,    "set_timesteps"						):
                     scheduler.set_timesteps(__UpperCamelCase						)
                elif num_inference_steps is not None and not hasattr(__UpperCamelCase       ,    "set_timesteps"						):
                     __lowerCAmelCase             =       num_inference_steps

                # copy over dummy past residuals (must be done after set_timesteps)
                __lowerCAmelCase             =       [residual + 0.2, residual + 0.1_5, residual + 0.1, residual + 0.0_5]
                __lowerCAmelCase             =       dummy_past_residuals[:]

                __lowerCAmelCase             =       scheduler.step_prk(__UpperCamelCase       ,    0       ,    __UpperCamelCase       ,    **__UpperCamelCase						).prev_sample
                __lowerCAmelCase             =       scheduler.step_prk(__UpperCamelCase       ,    1       ,    __UpperCamelCase       ,    **__UpperCamelCase						).prev_sample

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

                __lowerCAmelCase             =       scheduler.step_plms(__UpperCamelCase       ,    0       ,    __UpperCamelCase       ,    **__UpperCamelCase						).prev_sample
                __lowerCAmelCase             =       scheduler.step_plms(__UpperCamelCase       ,    1       ,    __UpperCamelCase       ,    **__UpperCamelCase						).prev_sample

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


      def 			__UpperCAmelCase		(						self						)->						List[str]:
           for timesteps in [1_0_0, 1_0_0_0]:
                self.check_over_configs(num_train_timesteps=__UpperCamelCase						)


      def 			__UpperCAmelCase		(						self						)->						Any:
           for steps_offset in [0, 1]:
                self.check_over_configs(steps_offset=__UpperCamelCase						)

           __lowerCAmelCase             =       self.scheduler_classes[0]
           __lowerCAmelCase             =       self.get_scheduler_config(steps_offset=1						)
           __lowerCAmelCase             =       scheduler_class(**__UpperCamelCase						)
           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 			__UpperCAmelCase		(						self						)->						int:
           for beta_start, beta_end in zip([0.0_0_0_1, 0.0_0_1]       ,    [0.0_0_2, 0.0_2]						):
                self.check_over_configs(beta_start=__UpperCamelCase       ,    beta_end=__UpperCamelCase						)


      def 			__UpperCAmelCase		(						self						)->						Optional[int]:
           for schedule in ["linear", "squaredcos_cap_v2"]:
                self.check_over_configs(beta_schedule=__UpperCamelCase						)


      def 			__UpperCAmelCase		(						self						)->						Dict:
           for prediction_type in ["epsilon", "v_prediction"]:
                self.check_over_configs(prediction_type=__UpperCamelCase						)


      def 			__UpperCAmelCase		(						self						)->						List[Any]:
           for t in [1, 5, 1_0]:
                self.check_over_forward(time_step=__UpperCamelCase						)


      def 			__UpperCAmelCase		(						self						)->						Optional[Any]:
           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=__UpperCamelCase						)


      def 			__UpperCAmelCase		(						self						)->						int:
           # earlier version of set_timesteps() caused an error indexing alpha's with inference steps as power of 3
           __lowerCAmelCase             =       2_7

           for scheduler_class in self.scheduler_classes:
                __lowerCAmelCase             =       self.dummy_sample
                __lowerCAmelCase             =       0.1 * sample

                __lowerCAmelCase             =       self.get_scheduler_config()
                __lowerCAmelCase             =       scheduler_class(**__UpperCamelCase						)

                scheduler.set_timesteps(__UpperCamelCase						)

                # 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]						):
                     __lowerCAmelCase             =       scheduler.step_prk(__UpperCamelCase       ,    __UpperCamelCase       ,    __UpperCamelCase						).prev_sample


      def 			__UpperCAmelCase		(						self						)->						Dict:
           with self.assertRaises(__UpperCamelCase						):
                __lowerCAmelCase             =       self.scheduler_classes[0]
                __lowerCAmelCase             =       self.get_scheduler_config()
                __lowerCAmelCase             =       scheduler_class(**__UpperCamelCase						)

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


      def 			__UpperCAmelCase		(						self						)->						Any:
           __lowerCAmelCase             =       self.full_loop()
           __lowerCAmelCase             =       torch.sum(torch.abs(__UpperCamelCase						)						)
           __lowerCAmelCase             =       torch.mean(torch.abs(__UpperCamelCase						)						)

           assert abs(result_sum.item() - 1_9_8.1_3_1_8						) < 1e-2
           assert abs(result_mean.item() - 0.2_5_8_0						) < 1e-3


      def 			__UpperCAmelCase		(						self						)->						str:
           __lowerCAmelCase             =       self.full_loop(prediction_type="v_prediction"						)
           __lowerCAmelCase             =       torch.sum(torch.abs(__UpperCamelCase						)						)
           __lowerCAmelCase             =       torch.mean(torch.abs(__UpperCamelCase						)						)

           assert abs(result_sum.item() - 6_7.3_9_8_6						) < 1e-2
           assert abs(result_mean.item() - 0.0_8_7_8						) < 1e-3


      def 			__UpperCAmelCase		(						self						)->						Any:
           # We specify different beta, so that the first alpha is 0.99
           __lowerCAmelCase             =       self.full_loop(set_alpha_to_one=__UpperCamelCase       ,    beta_start=0.0_1						)
           __lowerCAmelCase             =       torch.sum(torch.abs(__UpperCamelCase						)						)
           __lowerCAmelCase             =       torch.mean(torch.abs(__UpperCamelCase						)						)

           assert abs(result_sum.item() - 2_3_0.0_3_9_9						) < 1e-2
           assert abs(result_mean.item() - 0.2_9_9_5						) < 1e-3


      def 			__UpperCAmelCase		(						self						)->						Optional[Any]:
           # We specify different beta, so that the first alpha is 0.99
           __lowerCAmelCase             =       self.full_loop(set_alpha_to_one=__UpperCamelCase       ,    beta_start=0.0_1						)
           __lowerCAmelCase             =       torch.sum(torch.abs(__UpperCamelCase						)						)
           __lowerCAmelCase             =       torch.mean(torch.abs(__UpperCamelCase						)						)

           assert abs(result_sum.item() - 1_8_6.9_4_8_2						) < 1e-2
           assert abs(result_mean.item() - 0.2_4_3_4						) < 1e-3






