code: def init_from_ckpt(self, path, ignore_keys=list(), only_model=False):
      sd = torch.load(path, map_location="cpu")
      if "state_dict" in list(sd.keys()):
          sd = sd["state_dict"]
      keys = list(sd.keys())
      for k in keys:
          for ik in ignore_keys:
              if k.startswith(ik):
                  print("Deleting key {} from state_dict.".format(k))
                  del sd[k]
      missing, unexpected = (
          self.load_state_dict(sd, strict=False)
          if not only_model
          else self.model.load_state_dict(sd, strict=False)
      )
      print(
          f"Restored from {path} with {len(missing)} missing and {len(unexpected)} unexpected keys"
      )
      if len(missing) > 0:
          print(f"Missing Keys: {missing}")
      if len(unexpected) > 0:
          print(f"Unexpected Keys: {unexpected}")
  
imports: import os
  import torch
  import pytorch_lightning
  from omegaconf import OmegaConf
  from torch.nn import functional
  from torch.optim import AdamW
  from torch.optim.lr_scheduler import LambdaLR
  from copy import deepcopy
  from einops import rearrange
  from glob import glob
  from natsort import natsorted
  from ldm.modules.diffusionmodules.openaimodel import EncoderUNetModel, UNetModel
  from ldm.util import log_txt_as_img, default, ismap, instantiate_from_config
label_desc: Use image node_id 2 for calling the NoisyLatentImageClassifier obj's underlying member method code with example usage: obj.init_from_ckpt(path, ignore_keys, only_model) without return types