code: def save_checkpoint(
      path_to_job, model, optimizer, epoch, cfg, scaler=None
  ):
      """
      Save a checkpoint.
      Args:
          model (model): model to save the weight to the checkpoint.
          optimizer (optim): optimizer to save the historical state.
          epoch (int): current number of epoch of the model.
          cfg (CfgNode): configs to save.
          scaler (GradScaler): the mixed precision scale.
      """
      # Save checkpoints only from the master process.
      if not du.is_master_proc(cfg.NUM_GPUS * cfg.NUM_SHARDS):
          return
      # Ensure that the checkpoint dir exists.
      pathmgr.mkdirs(get_checkpoint_dir(path_to_job))
      # Omit the DDP wrapper in the multi-gpu setting.
      sd = (
          model.module.state_dict()
          if cfg.NUM_GPUS > 1
          else model.state_dict()
      )
      normalized_sd = sub_to_normal_bn(sd)
  
      # Record the state.
      checkpoint = {
          "epoch": epoch,
          "model_state": normalized_sd,
          "optimizer_state": optimizer.state_dict(),
          "cfg": cfg.dump(),
      }
      if scaler is not None:
          checkpoint["scaler_state"] = scaler.state_dict()
      # Write the checkpoint.
      path_to_checkpoint = get_path_to_checkpoint(
          path_to_job, epoch + 1, cfg.TASK
      )
      with pathmgr.open(path_to_checkpoint, "wb") as f:
          torch.save(checkpoint, f)
      return path_to_checkpoint
  
imports: import copy
  import math
  import numpy
  import os
  import pickle
  from collections import OrderedDict
  import torch
  import slowfast.utils.distributed
  import slowfast.utils.logging
  from slowfast.utils.c2_model_loading import get_name_convert_func
  from slowfast.utils.env import checkpoint_pathmgr
label_desc: Use image node_id 7 for calling a global function with example usage: save_checkpoint(path_to_job, model, optimizer, epoch, cfg, scaler) and returns: path_to_checkpoint