code: def load_checkpoint(ckpt_path):
      """Load checkpoint from `ckpt_path` if any else return `None`."""
      checkpoint = None
      if ckpt_path:
          logger.info("Loading checkpoint from %s" % ckpt_path)
          checkpoint = torch.load(
              ckpt_path, map_location=torch.device("cpu")
          )
  
          if "model" in checkpoint.keys():
              # This preserves backward-compat for models using customed layernorm
              def fix_key(s):
                  s = re.sub(
                      r"(.*)\.layer_norm((_\d+)?)\.b_2",
                      r"\1.layer_norm\2.bias",
                      s,
                  )
                  s = re.sub(
                      r"(.*)\.layer_norm((_\d+)?)\.a_2",
                      r"\1.layer_norm\2.weight",
                      s,
                  )
                  return s
  
              checkpoint["model"] = {
                  fix_key(k): v for k, v in checkpoint["model"].items()
              }
              # Force add_ffnbias to True if bias found in model w_1 keys
              for key in checkpoint["model"].keys():
                  if "w_1.bias" in key:
                      checkpoint["opt"].add_ffnbias = True
  
          if not hasattr(checkpoint["opt"], "num_kv"):
              checkpoint["opt"].num_kv = 0
          if not hasattr(checkpoint["opt"], "add_ffnbias"):
              checkpoint["opt"].add_ffnbias = False
          if not hasattr(checkpoint["opt"], "parallel_residual"):
              checkpoint["opt"].parallel_residual = False
          if not hasattr(checkpoint["opt"], "shared_layer_norm"):
              checkpoint["opt"].shared_layer_norm = False
          if not hasattr(checkpoint["opt"], "use_ckpting"):
              checkpoint["opt"].use_ckpting = []
          if not hasattr(
              checkpoint["opt"], "relative_positions_buckets"
          ):
              checkpoint["opt"].relative_positions_buckets = 0
          if not hasattr(checkpoint["opt"], "parallel_mode"):
              checkpoint["opt"].parallel_mode = "data_parallel"
          if not hasattr(checkpoint["opt"], "norm_eps"):
              checkpoint["opt"].norm_eps = 1e-6
  
          # fix v2 compatibility
          if (
              "generator" in checkpoint.keys()
              and checkpoint["generator"]
          ):
              if "0.weight" in checkpoint["generator"]:
                  checkpoint["generator"]["weight"] = checkpoint[
                      "generator"
                  ].pop("0.weight")
              if "0.bias" in checkpoint["generator"]:
                  checkpoint["generator"]["bias"] = checkpoint[
                      "generator"
                  ].pop("0.bias")
          # end of patch for backward compatibility
  
      return checkpoint
  
file_path: OpenNMT-py/onmt/models/model_saver.py
imports: import os
  import torch
  import re
  from collections import deque
  from onmt.utils.logging import logger
  from onmt.inputters.inputter import vocabs_to_dict
  from onmt.modules.lora import lora_state_dict
label_desc: Use image node_id 2 for calling a global function with example usage: load_checkpoint(ckpt_path) and returns: checkpoint, s