code: def save_checkpoint(model, optimizer, step, model_dir, ignore=[]):
      if not os.path.exists(model_dir):
          os.makedirs(model_dir)
      path = os.path.join(model_dir, "checkpoint")
      state_dict = model.state_dict()
      if ignore:
          for key in state_dict.keys():
              for item in ignore:
                  if key.startswith(item):
                      state_dict.pop(key)
      torch.save(
          {
              "model": state_dict,
              "optimizer": optimizer.state_dict(),
              "step": step,
          },
          path,
      )
  
imports: import os
label_desc: Use image node_id 2 for calling a global function with example usage: save_checkpoint(model, optimizer, step, model_dir, ignore) without return types