code: def save_checkpoint(
      state, is_best=False, save_path=".", filename=None
  ):
      """
      Saves checkpoint to file.
  
      :param state: (dict): the dictionary to save. Can have other values besides just model weights.
      :param is_best: (bool): whether this is the best result we've seen thus far
      :param save_path: (string): local dir to save to
      :param filename: (string): name of the file to save under `save_path`
  
      :return:
      """
      if not filename:
          print("ERROR: No filename defined.  Checkpoint is NOT saved.")
      save_path1 = os.path.expanduser(save_path)
      if not os.path.exists(save_path1):
          os.makedirs(save_path1)
      torch.save(state, os.path.join(save_path1, filename))
      if is_best:
          pos = filename.find("_ep_")
          if pos and pos > 0:
              bestname = filename[:pos] + "_best.pth.tar"
          shutil.copyfile(
              os.path.join(save_path1, filename),
              os.path.join(save_path1, bestname),
          )
  
file_path: pywick/pywick/callbacks/ModelCheckpoint.py
imports: import json
  import math
  import os
  import shutil
  import torch
  from .None import Callback
label_desc: Use image node_id 3 for calling a global function with example usage: save_checkpoint(state, is_best, save_path, filename) without return types