code: def init(version="Stable unCLIP-L", load_karlo_prior=False):
      state = dict()
      if not "model" in state:
          if version == "Stable unCLIP-L":
              config = "configs/stable-diffusion/v2-1-stable-unclip-l-inference.yaml"
              ckpt = "checkpoints/sd21-unclip-l.ckpt"
  
          elif version == "Stable unOpenCLIP-H":
              config = "configs/stable-diffusion/v2-1-stable-unclip-h-inference.yaml"
              ckpt = "checkpoints/sd21-unclip-h.ckpt"
  
          elif version == "Full Karlo":
              from ldm.modules.karlo.kakao.sampler import T2ISampler
  
              st.info("Loading full KARLO..")
              karlo = T2ISampler.from_pretrained(
                  root_dir="checkpoints/karlo_models",
                  clip_model_path="ViT-L-14.pt",
                  clip_stat_path="ViT-L-14_stats.th",
                  sampling_type="default",
              )
              state["karlo_prior"] = karlo
              state["msg"] = "loaded full Karlo"
              return state
          else:
              raise ValueError(f"version {version} unknown!")
  
          config = OmegaConf.load(config)
          model, msg = load_model_from_config(config, ckpt, vae_sd=None)
          state["msg"] = msg
  
          if load_karlo_prior:
              from ldm.modules.karlo.kakao.sampler import PriorSampler
  
              st.info("Loading KARLO CLIP prior...")
              karlo_prior = PriorSampler.from_pretrained(
                  root_dir="checkpoints/karlo_models",
                  clip_model_path="ViT-L-14.pt",
                  clip_stat_path="ViT-L-14_stats.th",
                  sampling_type="default",
              )
              state["karlo_prior"] = karlo_prior
          state["model"] = model
          state["ckpt"] = ckpt
          state["config"] = config
      return state
  
imports: import importlib
  import streamlit
  import torch
  import cv2
  import numpy
  import PIL
  from omegaconf import OmegaConf
  from PIL import Image
  from tqdm import trange
  import io, os
  from torch import autocast
  from einops import rearrange, repeat
  from torchvision.utils import make_grid
  from pytorch_lightning import seed_everything
  from contextlib import nullcontext
  from ldm.models.diffusion.ddim import DDIMSampler
  from ldm.models.diffusion.plms import PLMSSampler
  from ldm.models.diffusion.dpm_solver import DPMSolverSampler
label_desc: Use image node_id 9 for calling a global function with example usage: init(version, load_karlo_prior) and returns: state, state