




'''simple docstring'''



import torch

from diffusers import EulerAncestralDiscreteScheduler
from diffusers.utils import torch_device

from .test_schedulers import SchedulerCommonTest







class 	lowercase_					(				A     ):


   """simple docstring"""

   lowerCamelCase_       						=		(EulerAncestralDiscreteScheduler,)
   lowerCamelCase_       						=		10



   def 							lowerCAmelCase_    (					self      :			int						,   **__lowerCamelCase      :			Optional[Any]					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   {
          "num_train_timesteps": 1_1_0_0,
          "beta_start": 0.0_0_0_1,
          "beta_end": 0.0_2,
          "beta_schedule": "linear",
      }

      config.update(**__lowerCamelCase					)
      return config



   def 							lowerCAmelCase_    (					self      :			Tuple					):

      """simple docstring"""
      for timesteps in [1_0, 5_0, 1_0_0, 1_0_0_0]:
         self.check_over_configs(num_train_timesteps=__lowerCamelCase					)



   def 							lowerCAmelCase_    (					self      :			List[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=__lowerCamelCase						,   beta_end=__lowerCamelCase					)



   def 							lowerCAmelCase_    (					self      :			Optional[int]					):

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



   def 							lowerCAmelCase_    (					self      :			List[str]					):

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



   def 							lowerCAmelCase_    (					self      :			List[str]					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   self.scheduler_classes[0]
      _SCREAMING_SNAKE_CASE =   self.get_scheduler_config()
      _SCREAMING_SNAKE_CASE =   scheduler_class(**__lowerCamelCase					)

      scheduler.set_timesteps(self.num_inference_steps					)

      _SCREAMING_SNAKE_CASE =   torch.manual_seed(0					)

      _SCREAMING_SNAKE_CASE =   self.dummy_model()
      _SCREAMING_SNAKE_CASE =   self.dummy_sample_deter * scheduler.init_noise_sigma.cpu()
      _SCREAMING_SNAKE_CASE =   sample.to(__lowerCamelCase					)

      for i, t in enumerate(scheduler.timesteps					):
         _SCREAMING_SNAKE_CASE =   scheduler.scale_model_input(__lowerCamelCase						,   __lowerCamelCase					)

         _SCREAMING_SNAKE_CASE =   model(__lowerCamelCase						,   __lowerCamelCase					)

         _SCREAMING_SNAKE_CASE =   scheduler.step(__lowerCamelCase						,   __lowerCamelCase						,   __lowerCamelCase						,   generator=__lowerCamelCase					)
         _SCREAMING_SNAKE_CASE =   output.prev_sample

      _SCREAMING_SNAKE_CASE =   torch.sum(torch.abs(__lowerCamelCase					)					)
      _SCREAMING_SNAKE_CASE =   torch.mean(torch.abs(__lowerCamelCase					)					)

      assert abs(result_sum.item() - 1_5_2.3_1_9_2					) < 1e-2
      assert abs(result_mean.item() - 0.1_9_8_3					) < 1e-3



   def 							lowerCAmelCase_    (					self      :			str					):

      """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(**__lowerCamelCase					)

      scheduler.set_timesteps(self.num_inference_steps					)

      _SCREAMING_SNAKE_CASE =   torch.manual_seed(0					)

      _SCREAMING_SNAKE_CASE =   self.dummy_model()
      _SCREAMING_SNAKE_CASE =   self.dummy_sample_deter * scheduler.init_noise_sigma
      _SCREAMING_SNAKE_CASE =   sample.to(__lowerCamelCase					)

      for i, t in enumerate(scheduler.timesteps					):
         _SCREAMING_SNAKE_CASE =   scheduler.scale_model_input(__lowerCamelCase						,   __lowerCamelCase					)

         _SCREAMING_SNAKE_CASE =   model(__lowerCamelCase						,   __lowerCamelCase					)

         _SCREAMING_SNAKE_CASE =   scheduler.step(__lowerCamelCase						,   __lowerCamelCase						,   __lowerCamelCase						,   generator=__lowerCamelCase					)
         _SCREAMING_SNAKE_CASE =   output.prev_sample

      _SCREAMING_SNAKE_CASE =   torch.sum(torch.abs(__lowerCamelCase					)					)
      _SCREAMING_SNAKE_CASE =   torch.mean(torch.abs(__lowerCamelCase					)					)

      assert abs(result_sum.item() - 1_0_8.4_4_3_9					) < 1e-2
      assert abs(result_mean.item() - 0.1_4_1_2					) < 1e-3



   def 							lowerCAmelCase_    (					self      :			List[Any]					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   self.scheduler_classes[0]
      _SCREAMING_SNAKE_CASE =   self.get_scheduler_config()
      _SCREAMING_SNAKE_CASE =   scheduler_class(**__lowerCamelCase					)

      scheduler.set_timesteps(self.num_inference_steps						,   device=__lowerCamelCase					)
      _SCREAMING_SNAKE_CASE =   torch.manual_seed(0					)

      _SCREAMING_SNAKE_CASE =   self.dummy_model()
      _SCREAMING_SNAKE_CASE =   self.dummy_sample_deter * scheduler.init_noise_sigma.cpu()
      _SCREAMING_SNAKE_CASE =   sample.to(__lowerCamelCase					)

      for t in scheduler.timesteps:
         _SCREAMING_SNAKE_CASE =   scheduler.scale_model_input(__lowerCamelCase						,   __lowerCamelCase					)

         _SCREAMING_SNAKE_CASE =   model(__lowerCamelCase						,   __lowerCamelCase					)

         _SCREAMING_SNAKE_CASE =   scheduler.step(__lowerCamelCase						,   __lowerCamelCase						,   __lowerCamelCase						,   generator=__lowerCamelCase					)
         _SCREAMING_SNAKE_CASE =   output.prev_sample

      _SCREAMING_SNAKE_CASE =   torch.sum(torch.abs(__lowerCamelCase					)					)
      _SCREAMING_SNAKE_CASE =   torch.mean(torch.abs(__lowerCamelCase					)					)

      assert abs(result_sum.item() - 1_5_2.3_1_9_2					) < 1e-2
      assert abs(result_mean.item() - 0.1_9_8_3					) < 1e-3







'''simple docstring'''



def 				SCREAMING_SNAKE_CASE_				(							__A       :				List[Any] ,  __A       :				Dict						)				->				Union[str, Any]:
   if n == 0:
      return 1

   elif n % 2 == 1:
      return binary_exponentiation(__A ,  n - 1						) * a

   else:
      _SCREAMING_SNAKE_CASE =   binary_exponentiation(__A ,  n / 2						)
      return b * b


if __name__ == "__main__":
 try:
  lowerCamelCase_	 =		int(input('Enter Base : ').strip())
  lowerCamelCase_	 =		int(input('Enter Power : ').strip())
 except ValueError:
  print('Invalid literal for integer')

 lowerCamelCase_	 =		binary_exponentiation(BASE, POWER)
 print(f'''{BASE}^({POWER}) : {RESULT}''')

