





"""simple docstring"""







import tempfile

import torch

from diffusers import PNDMScheduler

from .test_schedulers import SchedulerCommonTest




class __magic_name__   (       __lowerCAmelCase		):
       UpperCamelCase    :						Dict      =	(PNDMScheduler,)
       UpperCamelCase    :						Any      =	(('''num_inference_steps''', 50),)
       def 		_lowerCamelCase   (     self   ,  **__magic_name__	):





         """simple docstring"""


         _lowerCAmelCase	      =					{
             'num_train_timesteps': 1_0_0_0,
             'beta_start': 0.00_01,
             'beta_end': 0.02,
             'beta_schedule': 'linear',
         }

         config.update(**_UpperCAmelCase	)
         return config
       def 		_lowerCamelCase   (     self   ,  __magic_name__=0   ,  **__magic_name__	):





         """simple docstring"""


         _lowerCAmelCase	      =					dict(self.forward_default_kwargs	)
         _lowerCAmelCase	      =					kwargs.pop('num_inference_steps'   ,  _UpperCAmelCase	)
         _lowerCAmelCase	      =					self.dummy_sample
         _lowerCAmelCase	      =					0.1 * sample
         _lowerCAmelCase	      =					[residual + 0.2, residual + 0.15, residual + 0.1, residual + 0.05]

         for scheduler_class in self.scheduler_classes:
           _lowerCAmelCase	      =					self.get_scheduler_config(**_UpperCAmelCase	)
           _lowerCAmelCase	      =					scheduler_class(**_UpperCAmelCase	)
           scheduler.set_timesteps(_UpperCAmelCase	)
           # copy over dummy past residuals
           _lowerCAmelCase	      =					dummy_past_residuals[:]

           with tempfile.TemporaryDirectory() as tmpdirname:
             scheduler.save_config(_UpperCAmelCase	)
             _lowerCAmelCase	      =					scheduler_class.from_pretrained(_UpperCAmelCase	)
             new_scheduler.set_timesteps(_UpperCAmelCase	)
             # copy over dummy past residuals
             _lowerCAmelCase	      =					dummy_past_residuals[:]

           _lowerCAmelCase	      =					scheduler.step_prk(_UpperCAmelCase   ,  _UpperCAmelCase   ,  _UpperCAmelCase   ,  **_UpperCAmelCase	).prev_sample
           _lowerCAmelCase	      =					new_scheduler.step_prk(_UpperCAmelCase   ,  _UpperCAmelCase   ,  _UpperCAmelCase   ,  **_UpperCAmelCase	).prev_sample

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

           _lowerCAmelCase	      =					scheduler.step_plms(_UpperCAmelCase   ,  _UpperCAmelCase   ,  _UpperCAmelCase   ,  **_UpperCAmelCase	).prev_sample
           _lowerCAmelCase	      =					new_scheduler.step_plms(_UpperCAmelCase   ,  _UpperCAmelCase   ,  _UpperCAmelCase   ,  **_UpperCAmelCase	).prev_sample

           assert torch.sum(torch.abs(output - new_output	)	) < 1e-5, "Scheduler outputs are not identical"
       def 		_lowerCamelCase   (     self	):





         """simple docstring"""


         pass
       def 		_lowerCamelCase   (     self   ,  __magic_name__=0   ,  **__magic_name__	):





         """simple docstring"""


         _lowerCAmelCase	      =					dict(self.forward_default_kwargs	)
         _lowerCAmelCase	      =					kwargs.pop('num_inference_steps'   ,  _UpperCAmelCase	)
         _lowerCAmelCase	      =					self.dummy_sample
         _lowerCAmelCase	      =					0.1 * sample
         _lowerCAmelCase	      =					[residual + 0.2, residual + 0.15, residual + 0.1, residual + 0.05]

         for scheduler_class in self.scheduler_classes:
           _lowerCAmelCase	      =					self.get_scheduler_config()
           _lowerCAmelCase	      =					scheduler_class(**_UpperCAmelCase	)
           scheduler.set_timesteps(_UpperCAmelCase	)

           # copy over dummy past residuals (must be after setting timesteps)
           _lowerCAmelCase	      =					dummy_past_residuals[:]

           with tempfile.TemporaryDirectory() as tmpdirname:
             scheduler.save_config(_UpperCAmelCase	)
             _lowerCAmelCase	      =					scheduler_class.from_pretrained(_UpperCAmelCase	)
             # copy over dummy past residuals
             new_scheduler.set_timesteps(_UpperCAmelCase	)

             # copy over dummy past residual (must be after setting timesteps)
             _lowerCAmelCase	      =					dummy_past_residuals[:]

           _lowerCAmelCase	      =					scheduler.step_prk(_UpperCAmelCase   ,  _UpperCAmelCase   ,  _UpperCAmelCase   ,  **_UpperCAmelCase	).prev_sample
           _lowerCAmelCase	      =					new_scheduler.step_prk(_UpperCAmelCase   ,  _UpperCAmelCase   ,  _UpperCAmelCase   ,  **_UpperCAmelCase	).prev_sample

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

           _lowerCAmelCase	      =					scheduler.step_plms(_UpperCAmelCase   ,  _UpperCAmelCase   ,  _UpperCAmelCase   ,  **_UpperCAmelCase	).prev_sample
           _lowerCAmelCase	      =					new_scheduler.step_plms(_UpperCAmelCase   ,  _UpperCAmelCase   ,  _UpperCAmelCase   ,  **_UpperCAmelCase	).prev_sample

           assert torch.sum(torch.abs(output - new_output	)	) < 1e-5, "Scheduler outputs are not identical"
       def 		_lowerCamelCase   (     self   ,  **__magic_name__	):





         """simple docstring"""


         _lowerCAmelCase	      =					self.scheduler_classes[0]
         _lowerCAmelCase	      =					self.get_scheduler_config(**_UpperCAmelCase	)
         _lowerCAmelCase	      =					scheduler_class(**_UpperCAmelCase	)

         _lowerCAmelCase	      =					1_0
         _lowerCAmelCase	      =					self.dummy_model()
         _lowerCAmelCase	      =					self.dummy_sample_deter
         scheduler.set_timesteps(_UpperCAmelCase	)

         for i, t in enumerate(scheduler.prk_timesteps	):
           _lowerCAmelCase	      =					model(_UpperCAmelCase   ,  _UpperCAmelCase	)
           _lowerCAmelCase	      =					scheduler.step_prk(_UpperCAmelCase   ,  _UpperCAmelCase   ,  _UpperCAmelCase	).prev_sample

         for i, t in enumerate(scheduler.plms_timesteps	):
           _lowerCAmelCase	      =					model(_UpperCAmelCase   ,  _UpperCAmelCase	)
           _lowerCAmelCase	      =					scheduler.step_plms(_UpperCAmelCase   ,  _UpperCAmelCase   ,  _UpperCAmelCase	).prev_sample

         return sample
       def 		_lowerCamelCase   (     self	):





         """simple docstring"""


         _lowerCAmelCase	      =					dict(self.forward_default_kwargs	)

         _lowerCAmelCase	      =					kwargs.pop('num_inference_steps'   ,  _UpperCAmelCase	)

         for scheduler_class in self.scheduler_classes:
           _lowerCAmelCase	      =					self.get_scheduler_config()
           _lowerCAmelCase	      =					scheduler_class(**_UpperCAmelCase	)

           _lowerCAmelCase	      =					self.dummy_sample
           _lowerCAmelCase	      =					0.1 * sample

           if num_inference_steps is not None and hasattr(_UpperCAmelCase   ,  'set_timesteps'	):
             scheduler.set_timesteps(_UpperCAmelCase	)
           elif num_inference_steps is not None and not hasattr(_UpperCAmelCase   ,  'set_timesteps'	):
             _lowerCAmelCase	      =					num_inference_steps

           # copy over dummy past residuals (must be done after set_timesteps)
           _lowerCAmelCase	      =					[residual + 0.2, residual + 0.15, residual + 0.1, residual + 0.05]
           _lowerCAmelCase	      =					dummy_past_residuals[:]

           _lowerCAmelCase	      =					scheduler.step_prk(_UpperCAmelCase   ,  0   ,  _UpperCAmelCase   ,  **_UpperCAmelCase	).prev_sample
           _lowerCAmelCase	      =					scheduler.step_prk(_UpperCAmelCase   ,  1   ,  _UpperCAmelCase   ,  **_UpperCAmelCase	).prev_sample

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

           _lowerCAmelCase	      =					scheduler.step_plms(_UpperCAmelCase   ,  0   ,  _UpperCAmelCase   ,  **_UpperCAmelCase	).prev_sample
           _lowerCAmelCase	      =					scheduler.step_plms(_UpperCAmelCase   ,  1   ,  _UpperCAmelCase   ,  **_UpperCAmelCase	).prev_sample

           self.assertEqual(output_a.shape   ,  sample.shape	)
           self.assertEqual(output_a.shape   ,  output_a.shape	)
       def 		_lowerCamelCase   (     self	):





         """simple docstring"""


         for timesteps in [1_0_0, 1_0_0_0]:
           self.check_over_configs(num_train_timesteps=_UpperCAmelCase	)
       def 		_lowerCamelCase   (     self	):





         """simple docstring"""


         for steps_offset in [0, 1]:
           self.check_over_configs(steps_offset=_UpperCAmelCase	)

         _lowerCAmelCase	      =					self.scheduler_classes[0]
         _lowerCAmelCase	      =					self.get_scheduler_config(steps_offset=1	)
         _lowerCAmelCase	      =					scheduler_class(**_UpperCAmelCase	)
         scheduler.set_timesteps(1_0	)
         assert torch.equal(
             scheduler.timesteps   ,  torch.LongTensor(
                 [9_0_1, 8_5_1, 8_5_1, 8_0_1, 8_0_1, 7_5_1, 7_5_1, 7_0_1, 7_0_1, 6_5_1, 6_5_1, 6_0_1, 6_0_1, 5_0_1, 4_0_1, 3_0_1, 2_0_1, 1_0_1, 1]	)   ,  )
       def 		_lowerCamelCase   (     self	):





         """simple docstring"""


         for beta_start, beta_end in zip([0.00_01, 0.0_01]   ,  [0.0_02, 0.02]	):
           self.check_over_configs(beta_start=_UpperCAmelCase   ,  beta_end=_UpperCAmelCase	)
       def 		_lowerCamelCase   (     self	):





         """simple docstring"""


         for schedule in ["linear", "squaredcos_cap_v2"]:
           self.check_over_configs(beta_schedule=_UpperCAmelCase	)
       def 		_lowerCamelCase   (     self	):





         """simple docstring"""


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





         """simple docstring"""


         for t in [1, 5, 1_0]:
           self.check_over_forward(time_step=_UpperCAmelCase	)
       def 		_lowerCamelCase   (     self	):





         """simple docstring"""


         for t, num_inference_steps in zip([1, 5, 1_0]   ,  [1_0, 5_0, 1_0_0]	):
           self.check_over_forward(num_inference_steps=_UpperCAmelCase	)
       def 		_lowerCamelCase   (     self	):





         """simple docstring"""


         _lowerCAmelCase	      =					2_7

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

           _lowerCAmelCase	      =					self.get_scheduler_config()
           _lowerCAmelCase	      =					scheduler_class(**_UpperCAmelCase	)

           scheduler.set_timesteps(_UpperCAmelCase	)

           # before power of 3 fix, would error on first step, so we only need to do two
           for i, t in enumerate(scheduler.prk_timesteps[:2]	):
             _lowerCAmelCase	      =					scheduler.step_prk(_UpperCAmelCase   ,  _UpperCAmelCase   ,  _UpperCAmelCase	).prev_sample
       def 		_lowerCamelCase   (     self	):





         """simple docstring"""


         with self.assertRaises(_UpperCAmelCase	):
           _lowerCAmelCase	      =					self.scheduler_classes[0]
           _lowerCAmelCase	      =					self.get_scheduler_config()
           _lowerCAmelCase	      =					scheduler_class(**_UpperCAmelCase	)

           scheduler.step_plms(self.dummy_sample   ,  1   ,  self.dummy_sample	).prev_sample
       def 		_lowerCamelCase   (     self	):





         """simple docstring"""


         _lowerCAmelCase	      =					self.full_loop()
         _lowerCAmelCase	      =					torch.sum(torch.abs(_UpperCAmelCase	)	)
         _lowerCAmelCase	      =					torch.mean(torch.abs(_UpperCAmelCase	)	)

         assert abs(result_sum.item() - 1_98.13_18	) < 1e-2
         assert abs(result_mean.item() - 0.25_80	) < 1e-3
       def 		_lowerCamelCase   (     self	):





         """simple docstring"""


         _lowerCAmelCase	      =					self.full_loop(prediction_type='v_prediction'	)
         _lowerCAmelCase	      =					torch.sum(torch.abs(_UpperCAmelCase	)	)
         _lowerCAmelCase	      =					torch.mean(torch.abs(_UpperCAmelCase	)	)

         assert abs(result_sum.item() - 67.39_86	) < 1e-2
         assert abs(result_mean.item() - 0.08_78	) < 1e-3
       def 		_lowerCamelCase   (     self	):





         """simple docstring"""


         _lowerCAmelCase	      =					self.full_loop(set_alpha_to_one=_UpperCAmelCase   ,  beta_start=0.01	)
         _lowerCAmelCase	      =					torch.sum(torch.abs(_UpperCAmelCase	)	)
         _lowerCAmelCase	      =					torch.mean(torch.abs(_UpperCAmelCase	)	)

         assert abs(result_sum.item() - 2_30.03_99	) < 1e-2
         assert abs(result_mean.item() - 0.29_95	) < 1e-3
       def 		_lowerCamelCase   (     self	):





         """simple docstring"""


         _lowerCAmelCase	      =					self.full_loop(set_alpha_to_one=_UpperCAmelCase   ,  beta_start=0.01	)
         _lowerCAmelCase	      =					torch.sum(torch.abs(_UpperCAmelCase	)	)
         _lowerCAmelCase	      =					torch.mean(torch.abs(_UpperCAmelCase	)	)

         assert abs(result_sum.item() - 1_86.94_82	) < 1e-2
         assert abs(result_mean.item() - 0.24_34	) < 1e-3









"""simple docstring"""

import math
from datetime import datetime, timedelta






def 		_snake_case	(   _snake_case				:   int				)       ->   datetime:






      '''simple docstring'''


      _A     =  year % 19
      _A     =  year % 4
      _A     =  year % 7
      _A     =  math.floor(year / 1_00				)
      _A     =  math.floor((13 + 8 * leap_day_inhibits) / 25				)
      _A     =  leap_day_inhibits / 4
      _A     =  (
          15 - lunar_orbit_correction + leap_day_inhibits - leap_day_reinstall_number
      ) % 30
      _A     =  (4 + leap_day_inhibits - leap_day_reinstall_number) % 7

      # days to be added to March 21
      _A     =  (19 * metonic_cycle + secular_moon_shift) % 30

      # PHM -> Paschal Full Moon
      _A     =  (
          2 * julian_leap_year
          + 4 * non_leap_year
          + 6 * days_to_add
          + century_starting_point
      ) % 7

      if days_to_add == 29 and days_from_phm_to_sunday == 6:
            return datetime(_snake_case							,    4							,    19				)
      elif days_to_add == 28 and days_from_phm_to_sunday == 6:
            return datetime(_snake_case							,    4							,    18				)
      else:
            return datetime(_snake_case							,    3							,    22				) + timedelta(
                days=int(days_to_add + days_from_phm_to_sunday				)				)


if __name__ == "__main__":
       for year in (1_994, 2_000, 2_010, 2_021, 2_023):
              a							      =     '''will be''' if year > datetime.now().year else '''was'''
              print(F'''Easter in {year} {tense} {gauss_easter(year)}''')

