


'''simple docstring'''

import torch

from diffusers import KDPMaDiscreteScheduler
from diffusers.utils import torch_device

from .test_schedulers import SchedulerCommonTest
class _lowerCamelCase	(						lowercase__							):



		'''simple docstring'''







		A_     :      Union[str, Any]				   =    (KDPMaDiscreteScheduler,)
		A_     :      Union[str, Any]				   =    10







		def        __lowerCAmelCase		( self		:						List[Any]  ,					**_A		:						Optional[int]      )  ->			Optional[int]:
			__magic_name__	:   Tuple					     =					{
			    'num_train_timesteps': 1100,
			    'beta_start': 0.0001,
			    'beta_end': 0.02,
			    'beta_schedule': 'linear',
			}

			config.update(**_A      )
			return config







		def        __lowerCAmelCase		( self		:						List[Any]      )  ->			Tuple:
			for timesteps in [10, 50, 100, 1000]:
				self.check_over_configs(num_train_timesteps=_A      )







		def        __lowerCAmelCase		( self		:						str      )  ->			Optional[Any]:
			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=_A  ,					beta_end=_A      )







		def        __lowerCAmelCase		( self		:						List[str]      )  ->			Optional[int]:
			for schedule in ["linear", "scaled_linear"]:
				self.check_over_configs(beta_schedule=_A      )







		def        __lowerCAmelCase		( self		:						int      )  ->			Any:
			for prediction_type in ["epsilon", "v_prediction"]:
				self.check_over_configs(prediction_type=_A      )







		def        __lowerCAmelCase		( self		:						int      )  ->			str:
			__magic_name__	:   Tuple					     =					self.scheduler_classes[0]
			__magic_name__	:   str					     =					self.get_scheduler_config(prediction_type='v_prediction'      )
			__magic_name__	:   Dict					     =					scheduler_class(**_A      )

			scheduler.set_timesteps(self.num_inference_steps      )

			__magic_name__	:   Dict					     =					self.dummy_model()
			__magic_name__	:   Tuple					     =					self.dummy_sample_deter * scheduler.init_noise_sigma
			__magic_name__	:   Any					     =					sample.to(_A      )

			for i, t in enumerate(scheduler.timesteps      ):
				__magic_name__	:   Optional[int]					     =					scheduler.scale_model_input(_A  ,					_A      )

				__magic_name__	:   int					     =					model(_A  ,					_A      )

				__magic_name__	:   Any					     =					scheduler.step(_A  ,					_A  ,					_A      )
				__magic_name__	:   str					     =					output.prev_sample

			__magic_name__	:   Tuple					     =					torch.sum(torch.abs(_A      )      )
			__magic_name__	:   Any					     =					torch.mean(torch.abs(_A      )      )

			if torch_device in ["cpu", "mps"]:
				assert abs(result_sum.item() - 4.6_934E-07      ) < 1E-2
				assert abs(result_mean.item() - 6.1_112E-10      ) < 1E-3
			else:
				# CUDA
				assert abs(result_sum.item() - 4.693_428_650_170_972E-07      ) < 1E-2
				assert abs(result_mean.item() - 0.0002      ) < 1E-3







		def        __lowerCAmelCase		( self		:						List[Any]      )  ->			Dict:
			if torch_device == "mps":
				return
			__magic_name__	:   Optional[Any]					     =					self.scheduler_classes[0]
			__magic_name__	:   Optional[Any]					     =					self.get_scheduler_config()
			__magic_name__	:   Tuple					     =					scheduler_class(**_A      )

			scheduler.set_timesteps(self.num_inference_steps      )

			__magic_name__	:   Optional[int]					     =					self.dummy_model()
			__magic_name__	:   List[Any]					     =					self.dummy_sample_deter * scheduler.init_noise_sigma
			__magic_name__	:   List[str]					     =					sample.to(_A      )

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

				__magic_name__	:   int					     =					model(_A  ,					_A      )

				__magic_name__	:   Union[str, Any]					     =					scheduler.step(_A  ,					_A  ,					_A      )
				__magic_name__	:   Optional[Any]					     =					output.prev_sample

			__magic_name__	:   Union[str, Any]					     =					torch.sum(torch.abs(_A      )      )
			__magic_name__	:   List[str]					     =					torch.mean(torch.abs(_A      )      )

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







		def        __lowerCAmelCase		( self		:						Dict      )  ->			Optional[Any]:
			if torch_device == "mps":
				return
			__magic_name__	:   Optional[int]					     =					self.scheduler_classes[0]
			__magic_name__	:   Dict					     =					self.get_scheduler_config()
			__magic_name__	:   int					     =					scheduler_class(**_A      )

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

			__magic_name__	:   str					     =					self.dummy_model()
			__magic_name__	:   Union[str, Any]					     =					self.dummy_sample_deter.to(_A      ) * scheduler.init_noise_sigma

			for t in scheduler.timesteps:
				__magic_name__	:   Optional[Any]					     =					scheduler.scale_model_input(_A  ,					_A      )

				__magic_name__	:   Tuple					     =					model(_A  ,					_A      )

				__magic_name__	:   Tuple					     =					scheduler.step(_A  ,					_A  ,					_A      )
				__magic_name__	:   Any					     =					output.prev_sample

			__magic_name__	:   Optional[int]					     =					torch.sum(torch.abs(_A      )      )
			__magic_name__	:   Optional[Any]					     =					torch.mean(torch.abs(_A      )      )

			if str(_A      ).startswith('cpu'      ):
				# The following sum varies between 148 and 156 on mps. Why?
				assert abs(result_sum.item() - 20.4125      ) < 1E-2
				assert abs(result_mean.item() - 0.0266      ) < 1E-3
			else:
				# CUDA
				assert abs(result_sum.item() - 20.4125      ) < 1E-2
				assert abs(result_mean.item() - 0.0266      ) < 1E-3



'''simple docstring'''

def lowerCamelCase      (      lowerCAmelCase    :     int		):





	"""simple docstring"""







	__magic_name__	:   Optional[int]					     =					1
	for i in range(1		,		num + 1		):
		fact *= i
	return fact





def lowerCamelCase      (      lowerCAmelCase    :     int		):





	"""simple docstring"""







	__magic_name__	:   List[str]					     =					0
	while number > 0:
		__magic_name__	:   str					     =					number % 10
		sum_of_digits += last_digit
		__magic_name__	:   Optional[int]					     =					number // 10  # Removing the last_digit from the given number
	return sum_of_digits





def lowerCamelCase      (      lowerCAmelCase    :     int = 100		):





	"""simple docstring"""







	__magic_name__	:   int					     =					factorial(lowerCAmelCase		)
	__magic_name__	:   Any					     =					split_and_add(lowerCAmelCase		)
	return result


if __name__ == "__main__":
							print(solution(int(input('''Enter the Number: ''').strip())))