



import os
from typing import Any, Callable, Dict, List, Optional, Tuple, Union

import torch
from torch import nn

from ...models.controlnet import ControlNetModel, ControlNetOutput
from ...models.modeling_utils import ModelMixin
from ...utils import logging


__A							       =		logging.get_logger(__name__)






class 						lowercase		(					__UpperCamelCase):






	"""simple docstring"""


	def __init__(      self      :		Tuple		,    __UpperCAmelCase      :		Union[List[ControlNetModel], Tuple[ControlNetModel]]	)     ->					Tuple:
							super().__init__()
							UpperCAmelCase_=  nn.ModuleList(snake_case__	)




	def     _SCREAMING_SNAKE_CASE						(      self      :		Dict		,    __UpperCAmelCase      :		torch.FloatTensor		,    __UpperCAmelCase      :		Union[torch.Tensor, float, int]		,    __UpperCAmelCase      :		torch.Tensor		,    __UpperCAmelCase      :		List[torch.tensor]		,    __UpperCAmelCase      :		List[float]		,    __UpperCAmelCase      :		Optional[torch.Tensor] = None		,    __UpperCAmelCase      :		Optional[torch.Tensor] = None		,    __UpperCAmelCase      :		Optional[torch.Tensor] = None		,    __UpperCAmelCase      :		Optional[Dict[str, Any]] = None		,    __UpperCAmelCase      :		bool = False		,    __UpperCAmelCase      :		bool = True		,    )     ->					Optional[Any]:
							for i, (image, scale, controlnet) in enumerate(zip(snake_case__		,    snake_case__		,    self.nets	)	):
													UpperCAmelCase_,  UpperCAmelCase_=  controlnet(
													    snake_case__		,    snake_case__		,    snake_case__		,    snake_case__		,    snake_case__		,    snake_case__		,    snake_case__		,    snake_case__		,    snake_case__		,    snake_case__		,    snake_case__		,    )

													# merge samples
													if i == 0:
																			UpperCAmelCase_,  UpperCAmelCase_=  down_samples, mid_sample
													else:
																			UpperCAmelCase_=  [
																			    samples_prev + samples_curr
																			    for samples_prev, samples_curr in zip(snake_case__		,    snake_case__	)
																			]
																			mid_block_res_sample += mid_sample

							return down_block_res_samples, mid_block_res_sample




	def     _SCREAMING_SNAKE_CASE						(      self      :		Optional[Any]		,    __UpperCAmelCase      :		Union[str, os.PathLike]		,    __UpperCAmelCase      :		bool = True		,    __UpperCAmelCase      :		Callable = None		,    __UpperCAmelCase      :		bool = False		,    __UpperCAmelCase      :		Optional[str] = None		,    )     ->					Tuple:
							UpperCAmelCase_=  0
							UpperCAmelCase_=  save_directory
							for controlnet in self.nets:
													controlnet.save_pretrained(
													    snake_case__		,    is_main_process=snake_case__		,    save_function=snake_case__		,    safe_serialization=snake_case__		,    variant=snake_case__		,    )

													idx += 1
													UpperCAmelCase_=  model_path_to_save + F"""_{idx}"""




	@classmethod
	def     _SCREAMING_SNAKE_CASE						(      cls      :		Optional[int]		,    __UpperCAmelCase      :		Optional[Union[str, os.PathLike]]		,    **__UpperCAmelCase      :		List[Any]	)     ->					str:
							UpperCAmelCase_=  0
							UpperCAmelCase_=  []

							# load controlnet and append to list until no controlnet directory exists anymore
							# first controlnet has to be saved under `./mydirectory/controlnet` to be compliant with `DiffusionPipeline.from_prertained`
							# second, third, ... controlnets have to be saved under `./mydirectory/controlnet_1`, `./mydirectory/controlnet_2`, ...
							UpperCAmelCase_=  pretrained_model_path
							while os.path.isdir(snake_case__	):
													UpperCAmelCase_=  ControlNetModel.from_pretrained(snake_case__		,    **snake_case__	)
													controlnets.append(snake_case__	)

													idx += 1
													UpperCAmelCase_=  pretrained_model_path + F"""_{idx}"""

							logger.info(F"""{len(snake_case__	)} controlnets loaded from {pretrained_model_path}."""	)

							if len(snake_case__	) == 0:
													raise ValueError(
													    F"""No ControlNets found under {os.path.dirname(snake_case__	)}. Expected at least {pretrained_model_path + "_0"}."""	)

							return cls(snake_case__	)





"""simple docstring"""




import math
from datetime import datetime, timedelta







def 				_UpperCAmelCase		(							lowerCamelCase__  ):





		"""simple docstring"""




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

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

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


if __name__ == "__main__":
			for year in (19_94, 20_00, 20_10, 20_21, 20_23):
						__lowerCAmelCase     :				List[str]    				=    "will be" if year > datetime.now().year else "was"
						print(F"Easter in {year} {tense} {gauss_easter(year)}")




