code: def load_train_checkpoint(cfg, model, optimizer, scaler=None):
      """
      Loading checkpoint logic for training.
      """
      if cfg.TRAIN.AUTO_RESUME and has_checkpoint(cfg.OUTPUT_DIR):
          last_checkpoint = get_last_checkpoint(
              cfg.OUTPUT_DIR, cfg.TASK
          )
          logger.info(
              "Load from last checkpoint, {}.".format(last_checkpoint)
          )
          checkpoint_epoch = load_checkpoint(
              last_checkpoint,
              model,
              cfg.NUM_GPUS > 1,
              optimizer,
              scaler=scaler,
              clear_name_pattern=cfg.TRAIN.CHECKPOINT_CLEAR_NAME_PATTERN,
          )
          start_epoch = checkpoint_epoch + 1
      elif cfg.TRAIN.CHECKPOINT_FILE_PATH != "":
          logger.info("Load from given checkpoint file.")
          checkpoint_epoch = load_checkpoint(
              cfg.TRAIN.CHECKPOINT_FILE_PATH,
              model,
              cfg.NUM_GPUS > 1,
              optimizer,
              scaler=scaler,
              inflation=cfg.TRAIN.CHECKPOINT_INFLATE,
              convert_from_caffe2=cfg.TRAIN.CHECKPOINT_TYPE == "caffe2",
              epoch_reset=cfg.TRAIN.CHECKPOINT_EPOCH_RESET,
              clear_name_pattern=cfg.TRAIN.CHECKPOINT_CLEAR_NAME_PATTERN,
              image_init=cfg.TRAIN.CHECKPOINT_IN_INIT,
          )
          start_epoch = checkpoint_epoch + 1
      else:
          start_epoch = 0
  
      return start_epoch
  
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 14 for calling a global function with example usage: load_train_checkpoint(cfg, model, optimizer, scaler) and returns: start_epoch