code: def init_from_ckpt(
      self,
      path: str,
  ) -> None:
      if path.endswith("ckpt"):
          sd = torch.load(path, map_location="cpu")["state_dict"]
      elif path.endswith("safetensors"):
          sd = load_safetensors(path)
      else:
          raise NotImplementedError
  
      missing, unexpected = self.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 math
  from contextlib import contextmanager
  from typing import Any, Dict, List, Optional, Tuple, Union
  import pytorch_lightning
  import torch
  from omegaconf import ListConfig, OmegaConf
  from safetensors.torch import load_file
  from torch.optim.lr_scheduler import LambdaLR
  from ..modules import UNCONDITIONAL_CONFIG
  from ..modules.autoencoding.temporal_ae import VideoDecoder
  from ..modules.diffusionmodules.wrappers import OPENAIUNETWRAPPER
  from ..modules.ema import LitEma
  from ..util import default, disabled_train, get_obj_from_str, instantiate_from_config, log_txt_as_img
label_desc: Use image node_id 2 for calling the DiffusionEngine obj's underlying member method code with example usage: obj.init_from_ckpt(path) without return types