class_docstr: Save checkpoints periodically.
  
  Args:
      interval (int): The saving period. If ``by_epoch=True``, interval
          indicates epochs, otherwise it indicates iterations.
          Default: -1, which means "never".
      by_epoch (bool): Saving checkpoints by epoch or by iteration.
          Default: True.
      save_optimizer (bool): Whether to save optimizer state_dict in the
          checkpoint. It is usually used for resuming experiments.
          Default: True.
      out_dir (str, optional): The root directory to save checkpoints. If not
          specified, ``runner.work_dir`` will be used by default. If
          specified, the ``out_dir`` will be the concatenation of ``out_dir``
          and the last level directory of ``runner.work_dir``.
          `Changed in version 1.3.16.`
      max_keep_ckpts (int, optional): The maximum checkpoints to keep.
          In some cases we want only the latest few checkpoints and would
          like to delete old ones to save the disk space.
          Default: -1, which means unlimited.
      save_last (bool, optional): Whether to force the last checkpoint to be
          saved regardless of interval. Default: True.
      sync_buffer (bool, optional): Whether to synchronize buffers in
          different gpus. Default: False.
      file_client_args (dict, optional): Arguments to instantiate a
          FileClient. See :class:`mmcv.fileio.FileClient` for details.
          Default: None.
          `New in version 1.3.16.`
  
  .. warning::
      Before v1.3.16, the ``out_dir`` argument indicates the path where the
      checkpoint is stored. However, since v1.3.16, ``out_dir`` indicates the
      root directory and the final path to save checkpoint is the
      concatenation of ``out_dir`` and the last level directory of
      ``runner.work_dir``. Suppose the value of ``out_dir`` is "/path/of/A"
      and the value of ``runner.work_dir`` is "/path/of/B", then the final
      path will be "/path/of/A/B".
class_docstr_tok: ["Save","checkpoints","periodically",".","Args",":","interval","(","int",")",":","The","saving","period",".","If","``","by_epoch=True","``",",","interval","indicates","epochs",",","otherwise","it","indicates","iterations",".","Default",":","-1",",","which","means","``","never","''",".","by_epoch","(","bool",")",":","Saving","checkpoints","by","epoch","or","by","iteration",".","Default",":","True",".","save_optimizer","(","bool",")",":","Whether","to","save","optimizer","state_dict","in","the","checkpoint",".","It","is","usually","used","for","resuming","experiments",".","Default",":","True",".","out_dir","(","str",",","optional",")",":","The","root","directory","to","save","checkpoints",".","If","not","specified",",","``","runner.work_dir","``","will","be","used","by","default",".","If","specified",",","the","``","out_dir","``","will","be","the","concatenation","of","``","out_dir","``","and","the","last","level","directory","of","``","runner.work_dir","``",".","`","Changed","in","version","1.3.16.","`","max_keep_ckpts","(","int",",","optional",")",":","The","maximum","checkpoints","to","keep",".","In","some","cases","we","want","only","the","latest","few","checkpoints","and","would","like","to","delete","old","ones","to","save","the","disk","space",".","Default",":","-1",",","which","means","unlimited",".","save_last","(","bool",",","optional",")",":","Whether","to","force","the","last","checkpoint","to","be","saved","regardless","of","interval",".","Default",":","True",".","sync_buffer","(","bool",",","optional",")",":","Whether","to","synchronize","buffers","in","different","gpus",".","Default",":","False",".","file_client_args","(","dict",",","optional",")",":","Arguments","to","instantiate","a","FileClient",".","See",":","class",":","`","mmcv.fileio.FileClient","`","for","details",".","Default",":","None",".","`","New","in","version","1.3.16.","`","..","warning",":",":","Before","v1.3.16",",","the","``","out_dir","``","argument","indicates","the","path","where","the","checkpoint","is","stored",".","However",",","since","v1.3.16",",","``","out_dir","``","indicates","the","root","directory","and","the","final","path","to","save","checkpoint","is","the","concatenation","of","``","out_dir","``","and","the","last","level","directory","of","``","runner.work_dir","``",".","Suppose","the","value","of","``","out_dir","``","is","``","\/path\/of\/A","''","and","the","value","of","``","runner.work_dir","``","is","``","\/path\/of\/B","''",",","then","the","final","path","will","be","``","\/path\/of\/A\/B","''","."]
code: def after_train_iter(self, runner):
      if self.by_epoch:
          return
  
      # save checkpoint for following cases:
      # 1. every ``self.interval`` iterations
      # 2. reach the last iteration of training
      if self.every_n_iters(runner, self.interval) or (
          self.save_last and self.is_last_iter(runner)
      ):
          runner.logger.info(
              f"Saving checkpoint at {runner.iter + 1} iterations"
          )
          if self.sync_buffer:
              allreduce_params(runner.model.buffers())
          self._save_checkpoint(runner)
  
file_path: lavis/lavis/common/annotator/uniformer/mmcv/runner/hooks/checkpoint.py
imports: import os.path
  import warnings
  from annotator.uniformer.mmcv.fileio import FileClient
  from ..dist_utils import allreduce_params, master_only
  from .hook import HOOKS, Hook
label_desc: Use image node_id 5 for calling the CheckpointHook obj's underlying member method code with example usage: obj.after_train_iter(runner) without return types