




from __future__ import annotations

import unittest

from transformers import AlbertConfig, is_tf_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
						import tensorflow as tf

						from transformers import TF_MODEL_FOR_PRETRAINING_MAPPING
						from transformers.models.albert.modeling_tf_albert import (
						    TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
						    TFAlbertForMaskedLM,
						    TFAlbertForMultipleChoice,
						    TFAlbertForPreTraining,
						    TFAlbertForQuestionAnswering,
						    TFAlbertForSequenceClassification,
						    TFAlbertForTokenClassification,
						    TFAlbertModel,
						)






class      A     :
					"""simple docstring"""

					def __init__(      self					:				Dict		,					A__					:				Optional[int]		,					A__					:				Optional[int]=1_3		,					A__					:				Union[str, Any]=7		,					A__					:				List[str]=True		,					A__					:				Any=True		,					A__					:				str=True		,					A__					:				Tuple=True		,					A__					:				Any=9_9		,					A__					:				Union[str, Any]=1_6		,					A__					:				int=3_2		,					A__					:				Any=2		,					A__					:				Optional[int]=4		,					A__					:				List[Any]=3_7		,					A__					:				Union[str, Any]="gelu"		,					A__					:				List[str]=0.1		,					A__					:				Any=0.1		,					A__					:				Union[str, Any]=5_1_2		,					A__					:				List[str]=1_6		,					A__					:				Optional[Any]=2		,					A__					:				List[str]=0.02		,					A__					:				str=3		,					A__					:				Optional[Any]=4		,					A__					:				List[str]=None		,					)			->    Tuple:
											lowerCamelCase__ 					=			parent
											lowerCamelCase__ 					=			1_3
											lowerCamelCase__ 					=			7
											lowerCamelCase__ 					=			True
											lowerCamelCase__ 					=			True
											lowerCamelCase__ 					=			True
											lowerCamelCase__ 					=			True
											lowerCamelCase__ 					=			9_9
											lowerCamelCase__ 					=			1_6
											lowerCamelCase__ 					=			3_2
											lowerCamelCase__ 					=			2
											lowerCamelCase__ 					=			4
											lowerCamelCase__ 					=			3_7
											lowerCamelCase__ 					=			'gelu'
											lowerCamelCase__ 					=			0.1
											lowerCamelCase__ 					=			0.1
											lowerCamelCase__ 					=			5_1_2
											lowerCamelCase__ 					=			1_6
											lowerCamelCase__ 					=			2
											lowerCamelCase__ 					=			0.02
											lowerCamelCase__ 					=			3
											lowerCamelCase__ 					=			4
											lowerCamelCase__ 					=			None




					def 	__snake_case				(      self					:				int     )			->    str:
											lowerCamelCase__ 					=			ids_tensor([self.batch_size, self.seq_length]		,					self.vocab_size     )

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

											lowerCamelCase__ 					=			None
											if self.use_token_type_ids:
																	lowerCamelCase__ 					=			ids_tensor([self.batch_size, self.seq_length]		,					self.type_vocab_size     )

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

											lowerCamelCase__ 					=			AlbertConfig(
											    vocab_size=self.vocab_size		,					hidden_size=self.hidden_size		,					embedding_size=self.embedding_size		,					num_hidden_layers=self.num_hidden_layers		,					num_attention_heads=self.num_attention_heads		,					intermediate_size=self.intermediate_size		,					hidden_act=self.hidden_act		,					hidden_dropout_prob=self.hidden_dropout_prob		,					attention_probs_dropout_prob=self.attention_probs_dropout_prob		,					max_position_embeddings=self.max_position_embeddings		,					type_vocab_size=self.type_vocab_size		,					initializer_range=self.initializer_range		,					)

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




					def 	__snake_case				(      self					:				List[str]		,					A__					:				str		,					A__					:				Any		,					A__					:				Optional[Any]		,					A__					:				Tuple		,					A__					:				str		,					A__					:				str		,					A__					:				int     )			->    str:
											lowerCamelCase__ 					=			TFAlbertModel(config=__SCREAMING_SNAKE_CASE     )
											# inputs = {'input_ids': input_ids,
											#           'attention_mask': input_mask,
											#           'token_type_ids': token_type_ids}
											# sequence_output, pooled_output = model(**inputs)
											lowerCamelCase__ 					=			{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
											lowerCamelCase__ 					=			model(__SCREAMING_SNAKE_CASE     )

											lowerCamelCase__ 					=			[input_ids, input_mask]
											lowerCamelCase__ 					=			model(__SCREAMING_SNAKE_CASE     )

											lowerCamelCase__ 					=			model(__SCREAMING_SNAKE_CASE     )

											self.parent.assertEqual(result.last_hidden_state.shape		,					(self.batch_size, self.seq_length, self.hidden_size)     )
											self.parent.assertEqual(result.pooler_output.shape		,					(self.batch_size, self.hidden_size)     )




					def 	__snake_case				(      self					:				Tuple		,					A__					:				int		,					A__					:				Optional[Any]		,					A__					:				Optional[Any]		,					A__					:				Any		,					A__					:				str		,					A__					:				Optional[int]		,					A__					:				int     )			->    Optional[int]:
											lowerCamelCase__ 					=			self.num_labels
											lowerCamelCase__ 					=			TFAlbertForPreTraining(config=__SCREAMING_SNAKE_CASE     )
											lowerCamelCase__ 					=			{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
											lowerCamelCase__ 					=			model(__SCREAMING_SNAKE_CASE     )
											self.parent.assertEqual(result.prediction_logits.shape		,					(self.batch_size, self.seq_length, self.vocab_size)     )
											self.parent.assertEqual(result.sop_logits.shape		,					(self.batch_size, self.num_labels)     )




					def 	__snake_case				(      self					:				Tuple		,					A__					:				str		,					A__					:				int		,					A__					:				int		,					A__					:				str		,					A__					:				Optional[Any]		,					A__					:				List[str]		,					A__					:				Union[str, Any]     )			->    str:
											lowerCamelCase__ 					=			TFAlbertForMaskedLM(config=__SCREAMING_SNAKE_CASE     )
											lowerCamelCase__ 					=			{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
											lowerCamelCase__ 					=			model(__SCREAMING_SNAKE_CASE     )
											self.parent.assertEqual(result.logits.shape		,					(self.batch_size, self.seq_length, self.vocab_size)     )




					def 	__snake_case				(      self					:				Optional[int]		,					A__					:				List[str]		,					A__					:				List[str]		,					A__					:				List[Any]		,					A__					:				str		,					A__					:				Dict		,					A__					:				Any		,					A__					:				Optional[int]     )			->    Union[str, Any]:
											lowerCamelCase__ 					=			self.num_labels
											lowerCamelCase__ 					=			TFAlbertForSequenceClassification(config=__SCREAMING_SNAKE_CASE     )
											lowerCamelCase__ 					=			{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
											lowerCamelCase__ 					=			model(__SCREAMING_SNAKE_CASE     )
											self.parent.assertEqual(result.logits.shape		,					(self.batch_size, self.num_labels)     )




					def 	__snake_case				(      self					:				Dict		,					A__					:				Any		,					A__					:				int		,					A__					:				int		,					A__					:				Any		,					A__					:				int		,					A__					:				Union[str, Any]		,					A__					:				Union[str, Any]     )			->    Any:
											lowerCamelCase__ 					=			TFAlbertForQuestionAnswering(config=__SCREAMING_SNAKE_CASE     )
											lowerCamelCase__ 					=			{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}
											lowerCamelCase__ 					=			model(__SCREAMING_SNAKE_CASE     )
											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 	__snake_case				(      self					:				Any		,					A__					:				Dict		,					A__					:				Dict		,					A__					:				Optional[Any]		,					A__					:				Tuple		,					A__					:				Dict		,					A__					:				Union[str, Any]		,					A__					:				List[str]     )			->    str:
											lowerCamelCase__ 					=			self.num_choices
											lowerCamelCase__ 					=			TFAlbertForMultipleChoice(config=__SCREAMING_SNAKE_CASE     )
											lowerCamelCase__ 					=			tf.tile(tf.expand_dims(__SCREAMING_SNAKE_CASE		,					1     )		,					(1, self.num_choices, 1)     )
											lowerCamelCase__ 					=			tf.tile(tf.expand_dims(__SCREAMING_SNAKE_CASE		,					1     )		,					(1, self.num_choices, 1)     )
											lowerCamelCase__ 					=			tf.tile(tf.expand_dims(__SCREAMING_SNAKE_CASE		,					1     )		,					(1, self.num_choices, 1)     )
											lowerCamelCase__ 					=			{
											    'input_ids': multiple_choice_inputs_ids,
											    'attention_mask': multiple_choice_input_mask,
											    'token_type_ids': multiple_choice_token_type_ids,
											}
											lowerCamelCase__ 					=			model(__SCREAMING_SNAKE_CASE     )
											self.parent.assertListEqual(list(result['logits'].shape     )		,					[self.batch_size, self.num_choices]     )




					def 	__snake_case				(      self					:				List[str]		,					A__					:				Dict		,					A__					:				Dict		,					A__					:				Union[str, Any]		,					A__					:				str		,					A__					:				List[Any]		,					A__					:				Dict		,					A__					:				List[Any]     )			->    Any:
											lowerCamelCase__ 					=			self.num_labels
											lowerCamelCase__ 					=			TFAlbertForTokenClassification(config=__SCREAMING_SNAKE_CASE     )
											lowerCamelCase__ 					=			{
											    'input_ids': input_ids,
											    'attention_mask': input_mask,
											    'token_type_ids': token_type_ids,
											}
											lowerCamelCase__ 					=			model(__SCREAMING_SNAKE_CASE     )
											self.parent.assertListEqual(list(result['logits'].shape     )		,					[self.batch_size, self.seq_length, self.num_labels]     )




					def 	__snake_case				(      self					:				int     )			->    str:
											lowerCamelCase__ 					=			self.prepare_config_and_inputs()
											(
											    (
											    lowerCamelCase__				
											)					,						(
											    lowerCamelCase__				
											)					,						(
											    lowerCamelCase__				
											)					,						(
											    lowerCamelCase__				
											)					,						(
											    lowerCamelCase__				
											)					,						(
											    lowerCamelCase__				
											)					,						(
											    lowerCamelCase__				
											)					,										
											) 					=			config_and_inputs
											lowerCamelCase__ 					=			{'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
											return config, inputs_dict






@require_tf
class      A     (						UpperCamelCase_     ,  UpperCamelCase_     ,  unittest.TestCase						):
					"""simple docstring"""

					_snake_case:		Union[str, Any]       =(
					    (
					        TFAlbertModel,
					        TFAlbertForPreTraining,
					        TFAlbertForMaskedLM,
					        TFAlbertForSequenceClassification,
					        TFAlbertForQuestionAnswering,
					        TFAlbertForTokenClassification,
					        TFAlbertForMultipleChoice,
					    )
					    if is_tf_available()
					    else ()
					)
					_snake_case:		Dict       =(
					    {
					        """feature-extraction""": TFAlbertModel,
					        """fill-mask""": TFAlbertForMaskedLM,
					        """question-answering""": TFAlbertForQuestionAnswering,
					        """text-classification""": TFAlbertForSequenceClassification,
					        """token-classification""": TFAlbertForTokenClassification,
					        """zero-shot""": TFAlbertForSequenceClassification,
					    }
					    if is_tf_available()
					    else {}
					)
					_snake_case:		Union[str, Any]       =False
					_snake_case:		List[str]       =False




					def 	__snake_case				(      self					:				int		,					A__					:				Any		,					A__					:				str		,					A__					:				Any=False     )			->    Any:
											lowerCamelCase__ 					=			super()._prepare_for_class(__SCREAMING_SNAKE_CASE		,					__SCREAMING_SNAKE_CASE		,					return_labels=__SCREAMING_SNAKE_CASE     )

											if return_labels:
																	if model_class in get_values(__SCREAMING_SNAKE_CASE     ):
																							lowerCamelCase__ 					=			tf.zeros(self.model_tester.batch_size		,					dtype=tf.intaa     )

											return inputs_dict




					def 	__snake_case				(      self					:				Optional[Any]     )			->    Tuple:
											lowerCamelCase__ 					=			TFAlbertModelTester(self     )
											lowerCamelCase__ 					=			ConfigTester(self		,					config_class=__SCREAMING_SNAKE_CASE		,					hidden_size=3_7     )




					def 	__snake_case				(      self					:				Dict     )			->    str:
											self.config_tester.run_common_tests()




					def 	__snake_case				(      self					:				int     )			->    Any:
											lowerCamelCase__ 					=			self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_albert_model(*__SCREAMING_SNAKE_CASE     )




					def 	__snake_case				(      self					:				Optional[int]     )			->    str:
											lowerCamelCase__ 					=			self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_albert_for_pretraining(*__SCREAMING_SNAKE_CASE     )




					def 	__snake_case				(      self					:				int     )			->    Union[str, Any]:
											lowerCamelCase__ 					=			self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_albert_for_masked_lm(*__SCREAMING_SNAKE_CASE     )




					def 	__snake_case				(      self					:				Union[str, Any]     )			->    Dict:
											lowerCamelCase__ 					=			self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_albert_for_multiple_choice(*__SCREAMING_SNAKE_CASE     )




					def 	__snake_case				(      self					:				Union[str, Any]     )			->    List[Any]:
											lowerCamelCase__ 					=			self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_albert_for_sequence_classification(*__SCREAMING_SNAKE_CASE     )




					def 	__snake_case				(      self					:				List[Any]     )			->    List[Any]:
											lowerCamelCase__ 					=			self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_albert_for_question_answering(*__SCREAMING_SNAKE_CASE     )




					@slow
					def 	__snake_case				(      self					:				Dict     )			->    Any:
											for model_name in TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																	lowerCamelCase__ 					=			TFAlbertModel.from_pretrained(__SCREAMING_SNAKE_CASE     )
																	self.assertIsNotNone(__SCREAMING_SNAKE_CASE     )






@require_tf
class      A     (						unittest.TestCase						):
					"""simple docstring"""

					@slow
					def 	__snake_case				(      self					:				Optional[Any]     )			->    Optional[int]:
											lowerCamelCase__ 					=			TFAlbertForPreTraining.from_pretrained('albert-base-v2'     )
											lowerCamelCase__ 					=			tf.constant([[0, 1, 2, 3, 4, 5]]     )
											lowerCamelCase__ 					=			model(__SCREAMING_SNAKE_CASE     )[0]

											lowerCamelCase__ 					=			[1, 6, 3_0_0_0_0]
											self.assertEqual(output.shape		,					__SCREAMING_SNAKE_CASE     )

											lowerCamelCase__ 					=			tf.constant(
											    [
											        [
											            [4.595668, 0.74462754, -1.818147],
											            [4.5954347, 0.7454184, -1.8188258],
											            [4.5954905, 0.7448235, -1.8182316],
											        ]
											    ]     )
											tf.debugging.assert_near(output[:, :3, :3]		,					__SCREAMING_SNAKE_CASE		,					atol=1E-4     )





import tempfile

import torch

from diffusers import (
    DEISMultistepScheduler,
    DPMSolverMultistepScheduler,
    DPMSolverSinglestepScheduler,
    UniPCMultistepScheduler,
)

from .test_schedulers import SchedulerCommonTest






class      A     (						_lowerCAmelCase						):
     """simple docstring"""

     _snake_case:		Optional[int]       =(DPMSolverMultistepScheduler,)
     _snake_case:		Union[str, Any]       =(("num_inference_steps", 25),)




     def 	__snake_case				(      self					:				str		,					**A__					:				Union[str, Any]     )			->    str:
           lowerCamelCase__ 					=			{
               'num_train_timesteps': 1_0_0_0,
               'beta_start': 0.0001,
               'beta_end': 0.02,
               'beta_schedule': 'linear',
               'solver_order': 2,
               'prediction_type': 'epsilon',
               'thresholding': False,
               'sample_max_value': 1.0,
               'algorithm_type': 'dpmsolver++',
               'solver_type': 'midpoint',
               'lower_order_final': False,
               'lambda_min_clipped': -float('inf'     ),
               'variance_type': None,
           }

           config.update(**A__     )
           return config




     def 	__snake_case				(      self					:				Dict		,					A__					:				Dict=0		,					**A__					:				Dict     )			->    Union[str, Any]:
           lowerCamelCase__ 					=			dict(self.forward_default_kwargs     )
           lowerCamelCase__ 					=			kwargs.pop('num_inference_steps'		,					A__     )
           lowerCamelCase__ 					=			self.dummy_sample
           lowerCamelCase__ 					=			0.1 * sample
           lowerCamelCase__ 					=			[residual + 0.2, residual + 0.15, residual + 0.10]

           for scheduler_class in self.scheduler_classes:
                 lowerCamelCase__ 					=			self.get_scheduler_config(**A__     )
                 lowerCamelCase__ 					=			scheduler_class(**A__     )
                 scheduler.set_timesteps(A__     )
                 # copy over dummy past residuals
                 lowerCamelCase__ 					=			dummy_past_residuals[: scheduler.config.solver_order]

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

                 lowerCamelCase__					,						lowerCamelCase__ 					=			sample, sample
                 for t in range(A__		,					time_step + scheduler.config.solver_order + 1     ):
                       lowerCamelCase__ 					=			scheduler.step(A__		,					A__		,					A__		,					**A__     ).prev_sample
                       lowerCamelCase__ 					=			new_scheduler.step(A__		,					A__		,					A__		,					**A__     ).prev_sample

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




     def 	__snake_case				(      self					:				List[str]     )			->    Union[str, Any]:
           pass




     def 	__snake_case				(      self					:				Optional[Any]		,					A__					:				List[str]=0		,					**A__					:				Optional[Any]     )			->    Optional[Any]:
           lowerCamelCase__ 					=			dict(self.forward_default_kwargs     )
           lowerCamelCase__ 					=			kwargs.pop('num_inference_steps'		,					A__     )
           lowerCamelCase__ 					=			self.dummy_sample
           lowerCamelCase__ 					=			0.1 * sample
           lowerCamelCase__ 					=			[residual + 0.2, residual + 0.15, residual + 0.10]

           for scheduler_class in self.scheduler_classes:
                 lowerCamelCase__ 					=			self.get_scheduler_config()
                 lowerCamelCase__ 					=			scheduler_class(**A__     )
                 scheduler.set_timesteps(A__     )

                 # copy over dummy past residuals (must be after setting timesteps)
                 lowerCamelCase__ 					=			dummy_past_residuals[: scheduler.config.solver_order]

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

                       # copy over dummy past residual (must be after setting timesteps)
                       lowerCamelCase__ 					=			dummy_past_residuals[: new_scheduler.config.solver_order]

                 lowerCamelCase__ 					=			scheduler.step(A__		,					A__		,					A__		,					**A__     ).prev_sample
                 lowerCamelCase__ 					=			new_scheduler.step(A__		,					A__		,					A__		,					**A__     ).prev_sample

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




     def 	__snake_case				(      self					:				Tuple		,					A__					:				Any=None		,					**A__					:				Any     )			->    List[str]:
           if scheduler is None:
                 lowerCamelCase__ 					=			self.scheduler_classes[0]
                 lowerCamelCase__ 					=			self.get_scheduler_config(**A__     )
                 lowerCamelCase__ 					=			scheduler_class(**A__     )

           lowerCamelCase__ 					=			1_0
           lowerCamelCase__ 					=			self.dummy_model()
           lowerCamelCase__ 					=			self.dummy_sample_deter
           scheduler.set_timesteps(A__     )

           for i, t in enumerate(scheduler.timesteps     ):
                 lowerCamelCase__ 					=			model(A__		,					A__     )
                 lowerCamelCase__ 					=			scheduler.step(A__		,					A__		,					A__     ).prev_sample

           return sample




     def 	__snake_case				(      self					:				Dict     )			->    Any:
           lowerCamelCase__ 					=			dict(self.forward_default_kwargs     )

           lowerCamelCase__ 					=			kwargs.pop('num_inference_steps'		,					A__     )

           for scheduler_class in self.scheduler_classes:
                 lowerCamelCase__ 					=			self.get_scheduler_config()
                 lowerCamelCase__ 					=			scheduler_class(**A__     )

                 lowerCamelCase__ 					=			self.dummy_sample
                 lowerCamelCase__ 					=			0.1 * sample

                 if num_inference_steps is not None and hasattr(A__		,					'set_timesteps'     ):
                       scheduler.set_timesteps(A__     )
                 elif num_inference_steps is not None and not hasattr(A__		,					'set_timesteps'     ):
                       lowerCamelCase__ 					=			num_inference_steps

                 # copy over dummy past residuals (must be done after set_timesteps)
                 lowerCamelCase__ 					=			[residual + 0.2, residual + 0.15, residual + 0.10]
                 lowerCamelCase__ 					=			dummy_past_residuals[: scheduler.config.solver_order]

                 lowerCamelCase__ 					=			scheduler.timesteps[5]
                 lowerCamelCase__ 					=			scheduler.timesteps[6]

                 lowerCamelCase__ 					=			scheduler.step(A__		,					A__		,					A__		,					**A__     ).prev_sample
                 lowerCamelCase__ 					=			scheduler.step(A__		,					A__		,					A__		,					**A__     ).prev_sample

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




     def 	__snake_case				(      self					:				Dict     )			->    Tuple:
           for timesteps in [2_5, 5_0, 1_0_0, 9_9_9, 1_0_0_0]:
                 self.check_over_configs(num_train_timesteps=A__     )




     def 	__snake_case				(      self					:				int     )			->    str:
           self.check_over_configs(thresholding=A__     )
           for order in [1, 2, 3]:
                 for solver_type in ["midpoint", "heun"]:
                       for threshold in [0.5, 1.0, 2.0]:
                             for prediction_type in ["epsilon", "sample"]:
                                   self.check_over_configs(
                                       thresholding=A__		,					prediction_type=A__		,					sample_max_value=A__		,					algorithm_type='dpmsolver++'		,					solver_order=A__		,					solver_type=A__		,					)




     def 	__snake_case				(      self					:				Any     )			->    Optional[Any]:
           for prediction_type in ["epsilon", "v_prediction"]:
                 self.check_over_configs(prediction_type=A__     )




     def 	__snake_case				(      self					:				Union[str, Any]     )			->    str:
           for algorithm_type in ["dpmsolver", "dpmsolver++", "sde-dpmsolver", "sde-dpmsolver++"]:
                 for solver_type in ["midpoint", "heun"]:
                       for order in [1, 2, 3]:
                             for prediction_type in ["epsilon", "sample"]:
                                   if algorithm_type in ["sde-dpmsolver", "sde-dpmsolver++"]:
                                         if order == 3:
                                               continue
                                   else:
                                         self.check_over_configs(
                                             solver_order=A__		,					solver_type=A__		,					prediction_type=A__		,					algorithm_type=A__		,					)
                                   lowerCamelCase__ 					=			self.full_loop(
                                       solver_order=A__		,					solver_type=A__		,					prediction_type=A__		,					algorithm_type=A__		,					)
                                   assert not torch.isnan(A__     ).any(), "Samples have nan numbers"




     def 	__snake_case				(      self					:				List[Any]     )			->    int:
           self.check_over_configs(lower_order_final=A__     )
           self.check_over_configs(lower_order_final=A__     )




     def 	__snake_case				(      self					:				List[Any]     )			->    Dict:
           self.check_over_configs(lambda_min_clipped=-float('inf'     )     )
           self.check_over_configs(lambda_min_clipped=-5.1     )




     def 	__snake_case				(      self					:				Optional[Any]     )			->    int:
           self.check_over_configs(variance_type=A__     )
           self.check_over_configs(variance_type='learned_range'     )




     def 	__snake_case				(      self					:				Optional[Any]     )			->    List[str]:
           for num_inference_steps in [1, 2, 3, 5, 1_0, 5_0, 1_0_0, 9_9_9, 1_0_0_0]:
                 self.check_over_forward(num_inference_steps=A__		,					time_step=0     )




     def 	__snake_case				(      self					:				List[Any]     )			->    str:
           lowerCamelCase__ 					=			self.full_loop()
           lowerCamelCase__ 					=			torch.mean(torch.abs(A__     )     )

           assert abs(result_mean.item() - 0.3301     ) < 1E-3




     def 	__snake_case				(      self					:				Tuple     )			->    int:
           lowerCamelCase__ 					=			self.full_loop(thresholding=A__		,					dynamic_thresholding_ratio=0.87		,					sample_max_value=0.5     )
           lowerCamelCase__ 					=			torch.mean(torch.abs(A__     )     )

           assert abs(result_mean.item() - 1.1364     ) < 1E-3




     def 	__snake_case				(      self					:				Optional[int]     )			->    List[Any]:
           lowerCamelCase__ 					=			self.full_loop(prediction_type='v_prediction'     )
           lowerCamelCase__ 					=			torch.mean(torch.abs(A__     )     )

           assert abs(result_mean.item() - 0.2251     ) < 1E-3




     def 	__snake_case				(      self					:				Tuple     )			->    Optional[Any]:
           lowerCamelCase__ 					=			self.full_loop(prediction_type='v_prediction'		,					use_karras_sigmas=A__     )
           lowerCamelCase__ 					=			torch.mean(torch.abs(A__     )     )

           assert abs(result_mean.item() - 0.2096     ) < 1E-3




     def 	__snake_case				(      self					:				Any     )			->    Optional[int]:
           # make sure that iterating over schedulers with same config names gives same results
           # for defaults
           lowerCamelCase__ 					=			DPMSolverMultistepScheduler(**self.get_scheduler_config()     )
           lowerCamelCase__ 					=			self.full_loop(scheduler=A__     )
           lowerCamelCase__ 					=			torch.mean(torch.abs(A__     )     )

           assert abs(result_mean.item() - 0.3301     ) < 1E-3

           lowerCamelCase__ 					=			DPMSolverSinglestepScheduler.from_config(scheduler.config     )
           lowerCamelCase__ 					=			UniPCMultistepScheduler.from_config(scheduler.config     )
           lowerCamelCase__ 					=			DEISMultistepScheduler.from_config(scheduler.config     )
           lowerCamelCase__ 					=			DPMSolverMultistepScheduler.from_config(scheduler.config     )

           lowerCamelCase__ 					=			self.full_loop(scheduler=A__     )
           lowerCamelCase__ 					=			torch.mean(torch.abs(A__     )     )

           assert abs(result_mean.item() - 0.3301     ) < 1E-3




     def 	__snake_case				(      self					:				int     )			->    Optional[int]:
           lowerCamelCase__ 					=			self.scheduler_classes[0]
           lowerCamelCase__ 					=			self.get_scheduler_config(thresholding=A__		,					dynamic_thresholding_ratio=0     )
           lowerCamelCase__ 					=			scheduler_class(**A__     )

           lowerCamelCase__ 					=			1_0
           lowerCamelCase__ 					=			self.dummy_model()
           lowerCamelCase__ 					=			self.dummy_sample_deter.half()
           scheduler.set_timesteps(A__     )

           for i, t in enumerate(scheduler.timesteps     ):
                 lowerCamelCase__ 					=			model(A__		,					A__     )
                 lowerCamelCase__ 					=			scheduler.step(A__		,					A__		,					A__     ).prev_sample

           assert sample.dtype == torch.floataa




     def 	__snake_case				(      self					:				List[str]		,					**A__					:				int     )			->    Optional[int]:
           for scheduler_class in self.scheduler_classes:
                 lowerCamelCase__ 					=			self.get_scheduler_config(**A__     )
                 lowerCamelCase__ 					=			scheduler_class(**A__     )

                 scheduler.set_timesteps(scheduler.config.num_train_timesteps     )
                 assert len(scheduler.timesteps.unique()     ) == scheduler.num_inference_steps