code: def load_checkpoint(checkpoint, optimizer=True):
      """Loads entire model from file_path. If optimizer is True, loads
      optimizer assuming it is present in checkpoint.
  
      Args:
          checkpoint: (string) filename which needs to be loaded
          optimizer: (bool) resume optimizer from checkpoint
      """
      if not os.path.exists(checkpoint):
          raise ValueError("File doesn't exist {}".format(checkpoint))
      checkpoint = torch.load(
          checkpoint, map_location=torch.device("cpu")
      )
  
      if optimizer:
          return checkpoint["model"], checkpoint["optim"]
      return checkpoint["model"]
  
file_path: DeepKE/src/deepke/triple_extraction/PRGC/util.py
imports: import logging
  import os
  import shutil
  import json
  from pathlib import Path
  import torch
label_desc: Use image node_id 3 for calling a global function with example usage: load_checkpoint(checkpoint, optimizer) and returns: checkpoint, checkpoint,  checkpoint