


'''simple docstring'''





import tempfile
import unittest

import numpy as np
import torch

from diffusers import ScoreSdeVeScheduler

class     __snake_case							(      unittest.TestCase):
					SCREAMING_SNAKE_CASE_		:					List[str] 				= (ScoreSdeVeScheduler,)
					SCREAMING_SNAKE_CASE_		:					Any 				= ()
					@property
					def   a (	self					:	str     )       ->				List[str]:



											'''simple docstring'''





											__magic_name__ 		=			4
											__magic_name__ 		=			3
											__magic_name__ 		=			8
											__magic_name__ 		=			8

											__magic_name__ 		=			torch.rand((batch_size, num_channels, height, width)     )

											return sample
					@property
					def   a (	self					:	List[str]     )       ->				Dict:



											'''simple docstring'''





											__magic_name__ 		=			4
											__magic_name__ 		=			3
											__magic_name__ 		=			8
											__magic_name__ 		=			8

											__magic_name__ 		=			batch_size * num_channels * height * width
											__magic_name__ 		=			torch.arange(_lowerCamelCase     )
											__magic_name__ 		=			sample.reshape(_lowerCamelCase  ,			_lowerCamelCase  ,			_lowerCamelCase  ,			_lowerCamelCase     )
											__magic_name__ 		=			sample / num_elems
											__magic_name__ 		=			sample.permute(3  ,			0  ,			1  ,			2     )

											return sample
					def   a (	self					:	int     )       ->				List[Any]:



											'''simple docstring'''





											def model(_lowerCAmelCase					:	Dict  ,			_lowerCAmelCase					:	Dict  ,			*_lowerCAmelCase					:	List[str]     ):
																	return sample * t / (t + 1)

											return model
					def   a (	self					:	int  ,			**_lowerCAmelCase					:	List[str]     )       ->				Optional[Any]:



											'''simple docstring'''





											__magic_name__ 		=			{
											    """num_train_timesteps""": 2_0_0_0,
											    """snr""": 0.15,
											    """sigma_min""": 0.01,
											    """sigma_max""": 1_3_4_8,
											    """sampling_eps""": 1E-5,
											}

											config.update(**_lowerCamelCase     )
											return config
					def   a (	self					:	int  ,			_lowerCAmelCase					:	List[Any]=0  ,			**_lowerCAmelCase					:	List[Any]     )       ->				Optional[Any]:



											'''simple docstring'''





											__magic_name__ 		=			dict(self.forward_default_kwargs     )

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

																	__magic_name__ 		=			self.get_scheduler_config(**_lowerCamelCase     )
																	__magic_name__ 		=			scheduler_class(**_lowerCamelCase     )

																	with tempfile.TemporaryDirectory() as tmpdirname:
																							scheduler.save_config(_lowerCamelCase     )
																							__magic_name__ 		=			scheduler_class.from_pretrained(_lowerCamelCase     )

																	__magic_name__ 		=			scheduler.step_pred(
																	    _lowerCamelCase  ,			_lowerCamelCase  ,			_lowerCamelCase  ,			generator=torch.manual_seed(0     )  ,			**_lowerCamelCase     ).prev_sample
																	__magic_name__ 		=			new_scheduler.step_pred(
																	    _lowerCamelCase  ,			_lowerCamelCase  ,			_lowerCamelCase  ,			generator=torch.manual_seed(0     )  ,			**_lowerCamelCase     ).prev_sample

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

																	__magic_name__ 		=			scheduler.step_correct(_lowerCamelCase  ,			_lowerCamelCase  ,			generator=torch.manual_seed(0     )  ,			**_lowerCamelCase     ).prev_sample
																	__magic_name__ 		=			new_scheduler.step_correct(
																	    _lowerCamelCase  ,			_lowerCamelCase  ,			generator=torch.manual_seed(0     )  ,			**_lowerCamelCase     ).prev_sample

																	assert torch.sum(torch.abs(output - new_output     )     ) < 1E-5, "Scheduler correction are not identical"
					def   a (	self					:	Tuple  ,			_lowerCAmelCase					:	Dict=0  ,			**_lowerCAmelCase					:	Optional[int]     )       ->				Optional[Any]:



											'''simple docstring'''





											__magic_name__ 		=			dict(self.forward_default_kwargs     )
											kwargs.update(_lowerCamelCase     )

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

																	__magic_name__ 		=			self.get_scheduler_config()
																	__magic_name__ 		=			scheduler_class(**_lowerCamelCase     )

																	with tempfile.TemporaryDirectory() as tmpdirname:
																							scheduler.save_config(_lowerCamelCase     )
																							__magic_name__ 		=			scheduler_class.from_pretrained(_lowerCamelCase     )

																	__magic_name__ 		=			scheduler.step_pred(
																	    _lowerCamelCase  ,			_lowerCamelCase  ,			_lowerCamelCase  ,			generator=torch.manual_seed(0     )  ,			**_lowerCamelCase     ).prev_sample
																	__magic_name__ 		=			new_scheduler.step_pred(
																	    _lowerCamelCase  ,			_lowerCamelCase  ,			_lowerCamelCase  ,			generator=torch.manual_seed(0     )  ,			**_lowerCamelCase     ).prev_sample

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

																	__magic_name__ 		=			scheduler.step_correct(_lowerCamelCase  ,			_lowerCamelCase  ,			generator=torch.manual_seed(0     )  ,			**_lowerCamelCase     ).prev_sample
																	__magic_name__ 		=			new_scheduler.step_correct(
																	    _lowerCamelCase  ,			_lowerCamelCase  ,			generator=torch.manual_seed(0     )  ,			**_lowerCamelCase     ).prev_sample

																	assert torch.sum(torch.abs(output - new_output     )     ) < 1E-5, "Scheduler correction are not identical"
					def   a (	self					:	Dict     )       ->				str:



											'''simple docstring'''





											for timesteps in [1_0, 1_0_0, 1_0_0_0]:
																	self.check_over_configs(num_train_timesteps=_lowerCamelCase     )
					def   a (	self					:	Optional[Any]     )       ->				Optional[int]:



											'''simple docstring'''





											for sigma_min, sigma_max in zip([0.0001, 0.001, 0.01]  ,			[1, 1_0_0, 1_0_0_0]     ):
																	self.check_over_configs(sigma_min=_lowerCamelCase  ,			sigma_max=_lowerCamelCase     )
					def   a (	self					:	str     )       ->				int:



											'''simple docstring'''





											for t in [0.1, 0.5, 0.75]:
																	self.check_over_forward(time_step=_lowerCamelCase     )
					def   a (	self					:	Dict     )       ->				Optional[int]:



											'''simple docstring'''





											__magic_name__ 		=			dict(self.forward_default_kwargs     )

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

											__magic_name__ 		=			3

											__magic_name__ 		=			self.dummy_model()
											__magic_name__ 		=			self.dummy_sample_deter

											scheduler.set_sigmas(_lowerCamelCase     )
											scheduler.set_timesteps(_lowerCamelCase     )
											__magic_name__ 		=			torch.manual_seed(0     )

											for i, t in enumerate(scheduler.timesteps     ):
																	__magic_name__ 		=			scheduler.sigmas[i]

																	for _ in range(scheduler.config.correct_steps     ):
																							with torch.no_grad():
																													__magic_name__ 		=			model(_lowerCamelCase  ,			_lowerCamelCase     )
																							__magic_name__ 		=			scheduler.step_correct(_lowerCamelCase  ,			_lowerCamelCase  ,			generator=_lowerCamelCase  ,			**_lowerCamelCase     ).prev_sample

																	with torch.no_grad():
																							__magic_name__ 		=			model(_lowerCamelCase  ,			_lowerCamelCase     )

																	__magic_name__ 		=			scheduler.step_pred(_lowerCamelCase  ,			_lowerCamelCase  ,			_lowerCamelCase  ,			generator=_lowerCamelCase  ,			**_lowerCamelCase     )
																	__magic_name__ 		=			output.prev_sample, output.prev_sample_mean

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

											assert np.isclose(result_sum.item()  ,			1_4_3_7_2_7_5_8_5_2_8.0     )
											assert np.isclose(result_mean.item()  ,			1_8_7_1_4_5_3_0.0     )







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



											'''simple docstring'''





											__magic_name__ 		=			dict(self.forward_default_kwargs     )

											__magic_name__ 		=			kwargs.pop('num_inference_steps'  ,			_lowerCamelCase     )

											for scheduler_class in self.scheduler_classes:
																	__magic_name__ 		=			self.get_scheduler_config()
																	__magic_name__ 		=			scheduler_class(**_lowerCamelCase     )

																	__magic_name__ 		=			self.dummy_sample
																	__magic_name__ 		=			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'     ):
																							__magic_name__ 		=			num_inference_steps

																	__magic_name__ 		=			scheduler.step_pred(_lowerCamelCase  ,			0  ,			_lowerCamelCase  ,			generator=torch.manual_seed(0     )  ,			**_lowerCamelCase     ).prev_sample
																	__magic_name__ 		=			scheduler.step_pred(_lowerCamelCase  ,			1  ,			_lowerCamelCase  ,			generator=torch.manual_seed(0     )  ,			**_lowerCamelCase     ).prev_sample

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





def 							UpperCamelCase_  (				__snake_case			:						int = 1_00     )->      int:




						'''simple docstring'''
						__magic_name__ 		=			1
						__magic_name__ 		=			0
						for i in range(1	,			num + 1     ):
												fact *= i

						for j in str(__snake_case     ):
												result += int(__snake_case     )

						return result


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

