code: def load_checkpoint(model, optimizer, model_dir, map_to_cpu=False):
      path = os.path.join(model_dir, "checkpoint")
      if os.path.exists(path):
          print("Loading model from %s" % path)
          if map_to_cpu:
              checkpoint = torch.load(
                  path, map_location=lambda storage, location: storage
              )
          else:
              checkpoint = torch.load(path)
          old_state_dict = model.state_dict()
          for key in old_state_dict.keys():
              if key not in checkpoint["model"]:
                  checkpoint["model"][key] = old_state_dict[key]
          model.load_state_dict(checkpoint["model"])
          optimizer.load_state_dict(checkpoint["optimizer"])
          return checkpoint.get("step", 0)
      return 0
  
imports: import os
label_desc: Use image node_id 1 for calling a global function with example usage: load_checkpoint(model, optimizer, model_dir, map_to_cpu) and returns: int, checkpoint