import sys

_lowerCamelCase					:   List[Any]							=		(
    '''73167176531330624919225119674426574742355349194934'''
    '''96983520312774506326239578318016984801869478851843'''
    '''85861560789112949495459501737958331952853208805511'''
    '''12540698747158523863050715693290963295227443043557'''
    '''66896648950445244523161731856403098711121722383113'''
    '''62229893423380308135336276614282806444486645238749'''
    '''30358907296290491560440772390713810515859307960866'''
    '''70172427121883998797908792274921901699720888093776'''
    '''65727333001053367881220235421809751254540594752243'''
    '''52584907711670556013604839586446706324415722155397'''
    '''53697817977846174064955149290862569321978468622482'''
    '''83972241375657056057490261407972968652414535100474'''
    '''82166370484403199890008895243450658541227588666881'''
    '''16427171479924442928230863465674813919123162824586'''
    '''17866458359124566529476545682848912883142607690042'''
    '''24219022671055626321111109370544217506941658960408'''
    '''07198403850962455444362981230987879927244284909188'''
    '''84580156166097919133875499200524063689912560717606'''
    '''05886116467109405077541002256983155200055935729725'''
    '''71636269561882670428252483600823257530420752963450'''
)





def 	__lowerCamelCase							(UpperCAmelCase__     :							str  ):
     SCREAMING_SNAKE_CASE    			=       1
     for digit in s:
          product *= int(UpperCAmelCase__  )
     return product





def 	__lowerCamelCase							(UpperCAmelCase__     :							str = N  ):
     SCREAMING_SNAKE_CASE    			=       -sys.maxsize - 1
     SCREAMING_SNAKE_CASE    			=       n[:1_3]
     SCREAMING_SNAKE_CASE    			=       1_3
     while cur_index < len(UpperCAmelCase__  ) - 1_3:
          if int(n[cur_index]  ) >= int(substr[0]  ):
               SCREAMING_SNAKE_CASE    			=       substr[1:] + n[cur_index]
               cur_index += 1
          else:
               SCREAMING_SNAKE_CASE    			=       max(UpperCAmelCase__      , str_eval(UpperCAmelCase__  )  )
               SCREAMING_SNAKE_CASE    			=       n[cur_index : cur_index + 1_3]
               cur_index += 1_3
     return largest_product


if __name__ == "__main__":
       print(f"""{solution() = }""")





import torch

from diffusers import KDPMaDiscreteScheduler
from diffusers.utils import torch_device

from .test_schedulers import SchedulerCommonTest


class 						lowercase    (     a     ):
							lowercase__						:       Tuple								=							(KDPMaDiscreteScheduler,)
							lowercase__						:       Optional[int]								=							10




							def 	__snake_case(						self   :					Optional[Any]	,							**_UpperCamelCase   :					List[Any]      )					->				Tuple:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       {
												    "num_train_timesteps": 1_100,
												    "beta_start": 0.0_0_0_1,
												    "beta_end": 0.0_2,
												    "beta_schedule": "linear",
												}

												config.update(**_UpperCamelCase      )
												return config




							def 	__snake_case(						self   :					int      )					->				List[Any]:



												'''simple docstring'''

												for timesteps in [10, 50, 100, 1_000]:
																	self.check_over_configs(num_train_timesteps=_UpperCamelCase      )




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



												'''simple docstring'''

												for beta_start, beta_end in zip([0.0_0_0_0_1, 0.0_0_0_1, 0.0_0_1]	,							[0.0_0_0_2, 0.0_0_2, 0.0_2]      ):
																	self.check_over_configs(beta_start=_UpperCamelCase	,							beta_end=_UpperCamelCase      )




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



												'''simple docstring'''

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




							def 	__snake_case(						self   :					Optional[int]      )					->				int:



												'''simple docstring'''

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




							def 	__snake_case(						self   :					Optional[int]      )					->				Any:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.scheduler_classes[0]
												SCREAMING_SNAKE_CASE    			=       self.get_scheduler_config(prediction_type="v_prediction"      )
												SCREAMING_SNAKE_CASE    			=       scheduler_class(**_UpperCamelCase      )

												scheduler.set_timesteps(self.num_inference_steps      )

												SCREAMING_SNAKE_CASE    			=       self.dummy_model()
												SCREAMING_SNAKE_CASE    			=       self.dummy_sample_deter * scheduler.init_noise_sigma
												SCREAMING_SNAKE_CASE    			=       sample.to(_UpperCamelCase      )

												for i, t in enumerate(scheduler.timesteps      ):
																	SCREAMING_SNAKE_CASE    			=       scheduler.scale_model_input(_UpperCamelCase	,							_UpperCamelCase      )

																	SCREAMING_SNAKE_CASE    			=       model(_UpperCamelCase	,							_UpperCamelCase      )

																	SCREAMING_SNAKE_CASE    			=       scheduler.step(_UpperCamelCase	,							_UpperCamelCase	,							_UpperCamelCase      )
																	SCREAMING_SNAKE_CASE    			=       output.prev_sample

												SCREAMING_SNAKE_CASE    			=       torch.sum(torch.abs(_UpperCamelCase      )      )
												SCREAMING_SNAKE_CASE    			=       torch.mean(torch.abs(_UpperCamelCase      )      )

												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.0_0_0_2      ) < 1e-3




							def 	__snake_case(						self   :					Dict      )					->				int:



												'''simple docstring'''

												if torch_device == "mps":
																	return
												SCREAMING_SNAKE_CASE    			=       self.scheduler_classes[0]
												SCREAMING_SNAKE_CASE    			=       self.get_scheduler_config()
												SCREAMING_SNAKE_CASE    			=       scheduler_class(**_UpperCamelCase      )

												scheduler.set_timesteps(self.num_inference_steps      )

												SCREAMING_SNAKE_CASE    			=       self.dummy_model()
												SCREAMING_SNAKE_CASE    			=       self.dummy_sample_deter * scheduler.init_noise_sigma
												SCREAMING_SNAKE_CASE    			=       sample.to(_UpperCamelCase      )

												for i, t in enumerate(scheduler.timesteps      ):
																	SCREAMING_SNAKE_CASE    			=       scheduler.scale_model_input(_UpperCamelCase	,							_UpperCamelCase      )

																	SCREAMING_SNAKE_CASE    			=       model(_UpperCamelCase	,							_UpperCamelCase      )

																	SCREAMING_SNAKE_CASE    			=       scheduler.step(_UpperCamelCase	,							_UpperCamelCase	,							_UpperCamelCase      )
																	SCREAMING_SNAKE_CASE    			=       output.prev_sample

												SCREAMING_SNAKE_CASE    			=       torch.sum(torch.abs(_UpperCamelCase      )      )
												SCREAMING_SNAKE_CASE    			=       torch.mean(torch.abs(_UpperCamelCase      )      )

												if torch_device in ["cpu", "mps"]:
																	assert abs(result_sum.item() - 2_0.4_1_2_5      ) < 1e-2
																	assert abs(result_mean.item() - 0.0_2_6_6      ) < 1e-3
												else:
																	# CUDA
																	assert abs(result_sum.item() - 2_0.4_1_2_5      ) < 1e-2
																	assert abs(result_mean.item() - 0.0_2_6_6      ) < 1e-3





							def 	__snake_case(						self   :					Tuple      )					->				str:



												'''simple docstring'''

												if torch_device == "mps":
																	return
												SCREAMING_SNAKE_CASE    			=       self.scheduler_classes[0]
												SCREAMING_SNAKE_CASE    			=       self.get_scheduler_config()
												SCREAMING_SNAKE_CASE    			=       scheduler_class(**_UpperCamelCase      )

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

												SCREAMING_SNAKE_CASE    			=       self.dummy_model()
												SCREAMING_SNAKE_CASE    			=       self.dummy_sample_deter.to(_UpperCamelCase      ) * scheduler.init_noise_sigma

												for t in scheduler.timesteps:
																	SCREAMING_SNAKE_CASE    			=       scheduler.scale_model_input(_UpperCamelCase	,							_UpperCamelCase      )

																	SCREAMING_SNAKE_CASE    			=       model(_UpperCamelCase	,							_UpperCamelCase      )

																	SCREAMING_SNAKE_CASE    			=       scheduler.step(_UpperCamelCase	,							_UpperCamelCase	,							_UpperCamelCase      )
																	SCREAMING_SNAKE_CASE    			=       output.prev_sample

												SCREAMING_SNAKE_CASE    			=       torch.sum(torch.abs(_UpperCamelCase      )      )
												SCREAMING_SNAKE_CASE    			=       torch.mean(torch.abs(_UpperCamelCase      )      )

												if str(_UpperCamelCase      ).startswith("cpu"      ):
																	# The following sum varies between 148 and 156 on mps. Why?
																	assert abs(result_sum.item() - 2_0.4_1_2_5      ) < 1e-2
																	assert abs(result_mean.item() - 0.0_2_6_6      ) < 1e-3
												else:
																	# CUDA
																	assert abs(result_sum.item() - 2_0.4_1_2_5      ) < 1e-2
																	assert abs(result_mean.item() - 0.0_2_6_6      ) < 1e-3




