
'''simple docstring'''

import torch

from diffusers import HeunDiscreteScheduler
from diffusers.utils import torch_device

from .test_schedulers import SchedulerCommonTest






class 				A       (		SCREAMING_SNAKE_CASE__      ):
	snake_case__ :List[Any]				       =       (HeunDiscreteScheduler,)
	snake_case__ :List[str]				       =       10





	def 							__SCREAMING_SNAKE_CASE					(   self     :    str ,							**__magic_name__     :    List[Any]							):


				"""simple docstring"""

				lowerCAmelCase__									=							{
				    "num_train_timesteps": 1100,
				    "beta_start": 0.0001,
				    "beta_end": 0.02,
				    "beta_schedule": "linear",
				}

				config.update(**__magic_name__							)
				return config





	def 							__SCREAMING_SNAKE_CASE					(   self     :    Tuple							):


				"""simple docstring"""

				for timesteps in [10, 50, 100, 1000]:
							self.check_over_configs(num_train_timesteps=__magic_name__							)





	def 							__SCREAMING_SNAKE_CASE					(   self     :    Optional[Any]							):


				"""simple docstring"""

				for beta_start, beta_end in zip([0.0_0001, 0.0001, 0.001] ,							[0.0002, 0.002, 0.02]							):
							self.check_over_configs(beta_start=__magic_name__ ,							beta_end=__magic_name__							)





	def 							__SCREAMING_SNAKE_CASE					(   self     :    List[Any]							):


				"""simple docstring"""

				for schedule in ["linear", "scaled_linear", "exp"]:
							self.check_over_configs(beta_schedule=__magic_name__							)





	def 							__SCREAMING_SNAKE_CASE					(   self     :    List[Any]							):


				"""simple docstring"""

				for clip_sample_range in [1.0, 2.0, 3.0]:
							self.check_over_configs(clip_sample_range=__magic_name__ ,							clip_sample=__magic_name__							)





	def 							__SCREAMING_SNAKE_CASE					(   self     :    Optional[Any]							):


				"""simple docstring"""

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





	def 							__SCREAMING_SNAKE_CASE					(   self     :    Any							):


				"""simple docstring"""

				lowerCAmelCase__									=							self.scheduler_classes[0]
				lowerCAmelCase__									=							self.get_scheduler_config()
				lowerCAmelCase__									=							scheduler_class(**__magic_name__							)

				scheduler.set_timesteps(self.num_inference_steps							)

				lowerCAmelCase__									=							self.dummy_model()
				lowerCAmelCase__									=							self.dummy_sample_deter * scheduler.init_noise_sigma
				lowerCAmelCase__									=							sample.to(__magic_name__							)

				for i, t in enumerate(scheduler.timesteps							):
							lowerCAmelCase__									=							scheduler.scale_model_input(__magic_name__ ,							__magic_name__							)

							lowerCAmelCase__									=							model(__magic_name__ ,							__magic_name__							)

							lowerCAmelCase__									=							scheduler.step(__magic_name__ ,							__magic_name__ ,							__magic_name__							)
							lowerCAmelCase__									=							output.prev_sample

				lowerCAmelCase__									=							torch.sum(torch.abs(__magic_name__							)							)
				lowerCAmelCase__									=							torch.mean(torch.abs(__magic_name__							)							)

				if torch_device in ["cpu", "mps"]:
							assert abs(result_sum.item() - 0.1233							) < 1E-2
							assert abs(result_mean.item() - 0.0002							) < 1E-3
				else:
							# CUDA
							assert abs(result_sum.item() - 0.1233							) < 1E-2
							assert abs(result_mean.item() - 0.0002							) < 1E-3





	def 							__SCREAMING_SNAKE_CASE					(   self     :    List[str]							):


				"""simple docstring"""

				lowerCAmelCase__									=							self.scheduler_classes[0]
				lowerCAmelCase__									=							self.get_scheduler_config(prediction_type="v_prediction"							)
				lowerCAmelCase__									=							scheduler_class(**__magic_name__							)

				scheduler.set_timesteps(self.num_inference_steps							)

				lowerCAmelCase__									=							self.dummy_model()
				lowerCAmelCase__									=							self.dummy_sample_deter * scheduler.init_noise_sigma
				lowerCAmelCase__									=							sample.to(__magic_name__							)

				for i, t in enumerate(scheduler.timesteps							):
							lowerCAmelCase__									=							scheduler.scale_model_input(__magic_name__ ,							__magic_name__							)

							lowerCAmelCase__									=							model(__magic_name__ ,							__magic_name__							)

							lowerCAmelCase__									=							scheduler.step(__magic_name__ ,							__magic_name__ ,							__magic_name__							)
							lowerCAmelCase__									=							output.prev_sample

				lowerCAmelCase__									=							torch.sum(torch.abs(__magic_name__							)							)
				lowerCAmelCase__									=							torch.mean(torch.abs(__magic_name__							)							)

				if torch_device in ["cpu", "mps"]:
							assert abs(result_sum.item() - 4.6934E-07							) < 1E-2
							assert abs(result_mean.item() - 6.1112E-10							) < 1E-3
				else:
							# CUDA
							assert abs(result_sum.item() - 4.693428650170972E-07							) < 1E-2
							assert abs(result_mean.item() - 0.0002							) < 1E-3





	def 							__SCREAMING_SNAKE_CASE					(   self     :    Optional[int]							):


				"""simple docstring"""

				lowerCAmelCase__									=							self.scheduler_classes[0]
				lowerCAmelCase__									=							self.get_scheduler_config()
				lowerCAmelCase__									=							scheduler_class(**__magic_name__							)

				scheduler.set_timesteps(self.num_inference_steps ,							device=__magic_name__							)

				lowerCAmelCase__									=							self.dummy_model()
				lowerCAmelCase__									=							self.dummy_sample_deter.to(__magic_name__							) * scheduler.init_noise_sigma

				for t in scheduler.timesteps:
							lowerCAmelCase__									=							scheduler.scale_model_input(__magic_name__ ,							__magic_name__							)

							lowerCAmelCase__									=							model(__magic_name__ ,							__magic_name__							)

							lowerCAmelCase__									=							scheduler.step(__magic_name__ ,							__magic_name__ ,							__magic_name__							)
							lowerCAmelCase__									=							output.prev_sample

				lowerCAmelCase__									=							torch.sum(torch.abs(__magic_name__							)							)
				lowerCAmelCase__									=							torch.mean(torch.abs(__magic_name__							)							)

				if str(__magic_name__							).startswith("cpu"							):
							# The following sum varies between 148 and 156 on mps. Why?
							assert abs(result_sum.item() - 0.1233							) < 1E-2
							assert abs(result_mean.item() - 0.0002							) < 1E-3
				elif str(__magic_name__							).startswith("mps"							):
							# Larger tolerance on mps
							assert abs(result_mean.item() - 0.0002							) < 1E-2
				else:
							# CUDA
							assert abs(result_sum.item() - 0.1233							) < 1E-2
							assert abs(result_mean.item() - 0.0002							) < 1E-3







	def 							__SCREAMING_SNAKE_CASE					(   self     :    Optional[Any]							):


				"""simple docstring"""

				lowerCAmelCase__									=							self.scheduler_classes[0]
				lowerCAmelCase__									=							self.get_scheduler_config()
				lowerCAmelCase__									=							scheduler_class(**__magic_name__ ,							use_karras_sigmas=__magic_name__							)

				scheduler.set_timesteps(self.num_inference_steps ,							device=__magic_name__							)

				lowerCAmelCase__									=							self.dummy_model()
				lowerCAmelCase__									=							self.dummy_sample_deter.to(__magic_name__							) * scheduler.init_noise_sigma
				lowerCAmelCase__									=							sample.to(__magic_name__							)

				for t in scheduler.timesteps:
							lowerCAmelCase__									=							scheduler.scale_model_input(__magic_name__ ,							__magic_name__							)

							lowerCAmelCase__									=							model(__magic_name__ ,							__magic_name__							)

							lowerCAmelCase__									=							scheduler.step(__magic_name__ ,							__magic_name__ ,							__magic_name__							)
							lowerCAmelCase__									=							output.prev_sample

				lowerCAmelCase__									=							torch.sum(torch.abs(__magic_name__							)							)
				lowerCAmelCase__									=							torch.mean(torch.abs(__magic_name__							)							)

				assert abs(result_sum.item() - 0.0_0015							) < 1E-2
				assert abs(result_mean.item() - 1.9869554535034695E-07							) < 1E-2







'''simple docstring'''

def 					A       ( )   ->    str:







			'''simple docstring'''



			lowerCAmelCase__									=							1

			while True:
						if (
						    sorted(str(UpperCamelCase_ ) )
						    == sorted(str(2 * i ) )
						    == sorted(str(3 * i ) )
						    == sorted(str(4 * i ) )
						    == sorted(str(5 * i ) )
						    == sorted(str(6 * i ) )
						):
									return i

						i += 1


if __name__ == "__main__":
		print(solution())





