class_docstr: A runner class to train and evaluate a model given a task and datasets.
  
  The runner uses pytorch distributed data parallel by default. Future release
  will support other distributed frameworks.
class_docstr_tok: ["A","runner","class","to","train","and","evaluate","a","model","given","a","task","and","datasets",".","The","runner","uses","pytorch","distributed","data","parallel","by","default",".","Future","release","will","support","other","distributed","frameworks","."]
docstr: Save the checkpoint at the current epoch.
code: def _save_checkpoint(self, cur_epoch, is_best=False):
      """
      Save the checkpoint at the current epoch.
      """
      model_no_ddp = self.unwrap_dist_model(self.model)
      param_grad_dic = {
          k: v.requires_grad
          for (k, v) in model_no_ddp.named_parameters()
      }
      state_dict = model_no_ddp.state_dict()
      for k in list(state_dict.keys()):
          if k in param_grad_dic.keys() and not param_grad_dic[k]:
              # delete parameters that do not require gradient
              del state_dict[k]
  
      save_obj = {
          "model": state_dict,
          "optimizer": self.optimizer.state_dict(),
          "config": self.config.to_dict(),
          "scaler": self.scaler.state_dict() if self.scaler else None,
          "epoch": cur_epoch,
      }
      save_to = os.path.join(
          self.output_dir,
          "checkpoint_{}.pth".format("best" if is_best else cur_epoch),
      )
      logging.info(
          "Saving checkpoint at epoch {} to {}.".format(
              cur_epoch, save_to
          )
      )
      torch.save(save_obj, save_to)
  
imports: import datetime
  import json
  import logging
  import os
  import time
  from pathlib import Path
  import torch
  import torch.distributed
  import webdataset
  from lavis.common.dist_utils import download_cached_file, get_rank, get_world_size, is_main_process, main_process
  from lavis.common.registry import registry
  from lavis.common.utils import is_url
  from lavis.datasets.data_utils import concat_datasets, reorg_datasets_by_split
  from lavis.datasets.datasets.dataloader_utils import IterLoader, MultiIterLoader, PrefetchLoader
  from torch.nn.parallel import DistributedDataParallel
  from torch.utils.data import DataLoader, DistributedSampler
  from torch.utils.data.dataset import ChainDataset
label_desc: Use image node_id 32 for calling the RunnerBase obj's underlying member method code with example usage: obj._save_checkpoint(cur_epoch, is_best) without return types