code: def load_model_from_config(config, ckpt, verbose=False):
      print(f"Loading model from {ckpt}")
      pl_sd = torch.load(ckpt, map_location="cpu")
      if "global_step" in pl_sd:
          print(f"Global Step: {pl_sd['global_step']}")
      sd = pl_sd["state_dict"]
      model = instantiate_from_config(config.model)
      m, u = model.load_state_dict(sd, strict=False)
      if len(m) > 0 and verbose:
          print("missing keys:")
          print(m)
      if len(u) > 0 and verbose:
          print("unexpected keys:")
          print(u)
  
      model.cuda()
      model.eval()
      return model
  
imports: import argparse, os, sys, glob
  import cv2
  import torch
  import numpy
  from omegaconf import OmegaConf
  from PIL import Image
  from tqdm import tqdm, trange
  from imwatermark import WatermarkEncoder
  from itertools import islice
  from einops import rearrange
  from torchvision.utils import make_grid
  import time
  from pytorch_lightning import seed_everything
  from torch import autocast
  from contextlib import contextmanager, nullcontext
  from ldm.util import instantiate_from_config
  from ldm.models.diffusion.ddim import DDIMSampler
  from ldm.models.diffusion.plms import PLMSSampler
  from ldm.models.diffusion.dpm_solver import DPMSolverSampler
  from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker
  from transformers import AutoFeatureExtractor
label_desc: Use image node_id 3 for calling a global function with example usage: load_model_from_config(config, ckpt, verbose) and returns: model