





from typing import List, Optional, Tuple, Union

import torch

from ...schedulers import DDIMScheduler
from ...utils import randn_tensor
from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput
class 		SCREAMING_SNAKE_CASE_							(    __SCREAMING_SNAKE_CASE   ):
				"""simple docstring"""




				def __init__(     self  :List[str]						,    __lowercase  :Tuple						,    __lowercase  :List[Any]			):
											super().__init__()

											# make sure scheduler can always be converted to DDIM
											__lowerCamelCase      :      Any         =DDIMScheduler.from_config(scheduler.config			)

											self.register_modules(unet=_a						,    scheduler=_a			)




				@torch.no_grad()
				def __call__(     self  :Optional[int]						,    __lowercase  :Optional[Any] = 1						,    __lowercase  :Any = None						,    __lowercase  :List[str] = 0.0						,    __lowercase  :Union[str, Any] = 50						,    __lowercase  :Dict = None						,    __lowercase  :Dict = "pil"						,    __lowercase  :Tuple = True						,    ):

											# Sample gaussian noise to begin loop
											if isinstance(self.unet.config.sample_size						,    _a			):
																		__lowerCamelCase      :      List[Any]         =(
																		    batch_size,
																		    self.unet.config.in_channels,
																		    self.unet.config.sample_size,
																		    self.unet.config.sample_size,
																		)
											else:
																		__lowerCamelCase      :      Optional[int]         =(batch_size, self.unet.config.in_channels, *self.unet.config.sample_size)

											if isinstance(_a						,    _a			) and len(_a			) != batch_size:
																		raise ValueError(
																		    f'You have passed a list of generators of length {len(_a			)}, but requested an effective batch'
																		    f' size of {batch_size}. Make sure the batch size matches the length of the generators.'			)

											__lowerCamelCase      :      Any         =randn_tensor(_a						,    generator=_a						,    device=self.device						,    dtype=self.unet.dtype			)

											# set step values
											self.scheduler.set_timesteps(_a			)

											for t in self.progress_bar(self.scheduler.timesteps			):
																		# 1. predict noise model_output
																		__lowerCamelCase      :      str         =self.unet(_a						,    _a			).sample

																		# 2. predict previous mean of image x_t-1 and add variance depending on eta
																		# eta corresponds to η in paper and should be between [0, 1]
																		# do x_t -> x_t-1
																		__lowerCamelCase      :      List[str]         =self.scheduler.step(
																		    _a						,    _a						,    _a						,    eta=_a						,    use_clipped_model_output=_a						,    generator=_a			).prev_sample

											__lowerCamelCase      :      List[Any]         =(image / 2 + 0.5).clamp(0						,    1			)
											__lowerCamelCase      :      Any         =image.cpu().permute(0						,    2						,    3						,    1			).numpy()
											if output_type == "pil":
																		__lowerCamelCase      :      str         =self.numpy_to_pil(_a			)

											if not return_dict:
																		return (image,)

											return ImagePipelineOutput(images=_a			)











"""simple docstring"""





import math
from datetime import datetime, timedelta



def 				lowerCAmelCase_			(      SCREAMING_SNAKE_CASE       :							int   ):


							'''simple docstring'''







							__lowerCamelCase      :      Any         =year % 19
							__lowerCamelCase      :      Optional[Any]         =year % 4
							__lowerCamelCase      :      Tuple         =year % 7
							__lowerCamelCase      :      Optional[int]         =math.floor(year / 100   )
							__lowerCamelCase      :      List[str]         =math.floor((13 + 8 * leap_day_inhibits) / 25   )
							__lowerCamelCase      :      Any         =leap_day_inhibits / 4
							__lowerCamelCase      :      Optional[Any]         =(
							    15 - lunar_orbit_correction + leap_day_inhibits - leap_day_reinstall_number
							) % 30
							__lowerCamelCase      :      Optional[Any]         =(4 + leap_day_inhibits - leap_day_reinstall_number) % 7

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

							# PHM -> Paschal Full Moon
							__lowerCamelCase      :      str         =(
							    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(SCREAMING_SNAKE_CASE    ,						4    ,						19   )
							elif days_to_add == 28 and days_from_phm_to_sunday == 6:
														return datetime(SCREAMING_SNAKE_CASE    ,						4    ,						18   )
							else:
														return datetime(SCREAMING_SNAKE_CASE    ,						3    ,						22   ) + timedelta(
														    days=int(days_to_add + days_from_phm_to_sunday   )   )


if __name__ == "__main__":
							for year in (1994, 2000, 2010, 2021, 2023):
														_UpperCamelCase							=      'will be' if year > datetime.now().year else 'was'
														print(f'''Easter in {year} {tense} {gauss_easter(year)}''')




