class_docstr: Hook to checkpoint a model's task.
  
  Saves the checkpoints in checkpoint_folder.
docstr: Checkpoint the task every checkpoint_period phases.
  
  We do not necessarily checkpoint the task at the end of every phase.
docstr_tok: ["Checkpoint","the","task","every","checkpoint_period","phases",".","We","do","not","necessarily","checkpoint","the","task","at","the","end","of","every","phase","."]
code: def on_phase_end(self, task) -> None:
      """Checkpoint the task every checkpoint_period phases.
  
      We do not necessarily checkpoint the task at the end of every phase.
      """
      if not is_primary() or task.phase_type not in self.phase_types:
          return
  
      self.phase_counter += 1
      if self.phase_counter % self.checkpoint_period != 0:
          return
  
      checkpoint_name = CheckpointHook.get_checkpoint_name(
          task.phase_idx
      )
      self._save_checkpoint(task, checkpoint_name)
  
file_path: ClassyVision/classy_vision/hooks/checkpoint_hook.py
imports: import logging
  from typing import Any, Collection, Dict, Optional
  from classy_vision.generic.distributed_util import is_primary
  from classy_vision.generic.util import get_checkpoint_dict, save_checkpoint
  from classy_vision.hooks import register_hook
  from classy_vision.hooks.classy_hook import ClassyHook
  from fvcore.common.file_io import PathManager
label_desc: Use image node_id 5 for calling the CheckpointHook obj's underlying member method code with example usage: obj.on_phase_end(task) without return types