class_docstr: Embedder module that serves as a container for embedders to use with different
  meshes. Extends Module to automatically save / load state dict.
class_docstr_tok: ["Embedder","module","that","serves","as","a","container","for","embedders","to","use","with","different","meshes",".","Extends","Module","to","automatically","save","\/","load","state","dict","."]
code: def load_from_model_checkpoint(
      self, fpath: str, prefix: Optional[str] = None
  ):
      if prefix is None:
          prefix = Embedder.DEFAULT_MODEL_CHECKPOINT_PREFIX
      state_dict = None
      if fpath.endswith(".pkl"):
          with PathManager.open(fpath, "rb") as hFile:
              state_dict = pickle.load(hFile, encoding="latin1")
      else:
          with PathManager.open(fpath, "rb") as hFile:
              state_dict = torch.load(
                  hFile, map_location=torch.device("cpu")
              )
      if state_dict is not None and "model" in state_dict:
          state_dict_local = {}
          for key in state_dict["model"]:
              if key.startswith(prefix):
                  v_key = state_dict["model"][key]
                  if isinstance(v_key, np.ndarray):
                      v_key = torch.from_numpy(v_key)
                  state_dict_local[key[len(prefix) :]] = v_key
          # non-strict loading to finetune on different meshes
          self.load_state_dict(state_dict_local, strict=False)
  
file_path: detectron2/projects/DensePose/densepose/modeling/cse/embedder.py
imports: import logging
  import numpy
  import pickle
  from enum import Enum
  from typing import Optional
  import torch
  from torch import nn
  from detectron2.config import CfgNode
  from detectron2.utils.file_io import PathManager
  from .vertex_direct_embedder import VertexDirectEmbedder
  from .vertex_feature_embedder import VertexFeatureEmbedder
label_desc: Use image node_id 2 for calling the Embedder obj's underlying member method code with example usage: obj.load_from_model_checkpoint(fpath, prefix) without return types