import importlib

import torch
import yaml
from omegaconf import OmegaConf
from taming.models.vqgan import VQModel


def    a__       (						__UpperCamelCase   ,					__UpperCamelCase=False ):
      SCREAMING_SNAKE_CASE_      =     OmegaConf.load(__UpperCamelCase )
      if display:
            print(yaml.dump(OmegaConf.to_container(__UpperCamelCase ) ) )
      return config


def    a__       (						__UpperCamelCase   ,					__UpperCamelCase=None   ,					__UpperCamelCase=None ):
      if conf_path is None:
            SCREAMING_SNAKE_CASE_      =     "./model_checkpoints/vqgan_only.yaml"
      SCREAMING_SNAKE_CASE_      =     load_config(__UpperCamelCase   ,					display=__UpperCamelCase )
      SCREAMING_SNAKE_CASE_      =     VQModel(**config.model.params )
      if ckpt_path is None:
            SCREAMING_SNAKE_CASE_      =     "./model_checkpoints/vqgan_only.pt"
      SCREAMING_SNAKE_CASE_      =     torch.load(__UpperCamelCase   ,					map_location=__UpperCamelCase )
      if ".ckpt" in ckpt_path:
            SCREAMING_SNAKE_CASE_      =     sd["state_dict"]
      model.load_state_dict(__UpperCamelCase   ,					strict=__UpperCamelCase )
      model.to(__UpperCamelCase )
      del sd
      return model


def    a__       (						__UpperCamelCase   ,					__UpperCamelCase ):
      SCREAMING_SNAKE_CASE_   ,       SCREAMING_SNAKE_CASE_   ,       SCREAMING_SNAKE_CASE_      =     model.encode(__UpperCamelCase )
      print(F'''VQGAN --- {model.__class__.__name__}: latent shape: {z.shape[2:]}''' )
      SCREAMING_SNAKE_CASE_      =     model.decode(__UpperCamelCase )
      return xrec


def    a__       (						__UpperCamelCase   ,					__UpperCamelCase=False ):
      SCREAMING_SNAKE_CASE_   ,       SCREAMING_SNAKE_CASE_      =     string.rsplit("."   ,					1 )
      if reload:
            SCREAMING_SNAKE_CASE_      =     importlib.import_module(__UpperCamelCase )
            importlib.reload(__UpperCamelCase )
      return getattr(importlib.import_module(__UpperCamelCase   ,					package=__UpperCamelCase )   ,					cls )


def    a__       (						__UpperCamelCase ):
      if "target" not in config:
            raise KeyError("Expected key `target` to instantiate." )
      return get_obj_from_str(config["target"] )(**config.get("params"   ,					{} ) )


def    a__       (						__UpperCamelCase   ,					__UpperCamelCase   ,					__UpperCamelCase=True   ,					__UpperCamelCase=True ):
      SCREAMING_SNAKE_CASE_      =     instantiate_from_config(__UpperCamelCase )
      if sd is not None:
            model.load_state_dict(__UpperCamelCase )
      if gpu:
            model.cuda()
      if eval_mode:
            model.eval()
      return {"model": model}





def    a__       (						__UpperCamelCase   ,					__UpperCamelCase   ,					__UpperCamelCase   ,					__UpperCamelCase ):
      # load the specified checkpoint
      if ckpt:
            SCREAMING_SNAKE_CASE_      =     torch.load(__UpperCamelCase   ,					map_location="cpu" )
            SCREAMING_SNAKE_CASE_      =     pl_sd["global_step"]
            print(F'''loaded model from global step {global_step}.''' )
      else:
            SCREAMING_SNAKE_CASE_      =     {"state_dict": None}
            SCREAMING_SNAKE_CASE_      =     None
      SCREAMING_SNAKE_CASE_      =     load_model_from_config(config.model   ,					pl_sd["state_dict"]   ,					gpu=__UpperCamelCase   ,					eval_mode=__UpperCamelCase )["model"]
      return model, global_step



import math
from datetime import datetime, timedelta


def    a__       (						__UpperCamelCase ):
      SCREAMING_SNAKE_CASE_      =     year % 1_9
      SCREAMING_SNAKE_CASE_      =     year % 4
      SCREAMING_SNAKE_CASE_      =     year % 7
      SCREAMING_SNAKE_CASE_      =     math.floor(year / 1_0_0 )
      SCREAMING_SNAKE_CASE_      =     math.floor((1_3 + 8 * leap_day_inhibits) / 2_5 )
      SCREAMING_SNAKE_CASE_      =     leap_day_inhibits / 4
      SCREAMING_SNAKE_CASE_      =     (
          1_5 - lunar_orbit_correction + leap_day_inhibits - leap_day_reinstall_number
      ) % 3_0
      SCREAMING_SNAKE_CASE_      =     (4 + leap_day_inhibits - leap_day_reinstall_number) % 7

      # days to be added to March 21
      SCREAMING_SNAKE_CASE_      =     (1_9 * metonic_cycle + secular_moon_shift) % 3_0

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

      if days_to_add == 2_9 and days_from_phm_to_sunday == 6:
            return datetime(__UpperCamelCase   ,					4   ,					1_9 )
      elif days_to_add == 2_8 and days_from_phm_to_sunday == 6:
            return datetime(__UpperCamelCase   ,					4   ,					1_8 )
      else:
            return datetime(__UpperCamelCase   ,					3   ,					2_2 ) + 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):
            A   :     Dict       =				"will be" if year > datetime.now().year else "was"
            print(f"Easter in {year} {tense} {gauss_easter(year)}")


