class_docstr: Hook to checkpoint a model's task.
  
  Saves the checkpoints in checkpoint_folder.
docstr: The constructor method of CheckpointHook.
  
  Args:
      checkpoint_folder: Folder to store checkpoints in
      input_args: Any arguments to save about the runtime setup. For example,
          it is useful to store the config that was used to instantiate the model.
      phase_types: If `phase_types` is specified, only checkpoint on those phase
          types. Each item in `phase_types` must be either "train" or "test". If
          not specified, it is set to checkpoint after "train" phases.
      checkpoint_period: Checkpoint at the end of every x phases (default 1)
docstr_tok: ["The","constructor","method","of","CheckpointHook",".","Args",":","checkpoint_folder",":","Folder","to","store","checkpoints","in","input_args",":","Any","arguments","to","save","about","the","runtime","setup",".","For","example",",","it","is","useful","to","store","the","config","that","was","used","to","instantiate","the","model",".","phase_types",":","If","`","phase_types","`","is","specified",",","only","checkpoint","on","those","phase","types",".","Each","item","in","`","phase_types","`","must","be","either","``","train","''","or","``","test","''",".","If","not","specified",",","it","is","set","to","checkpoint","after","``","train","''","phases",".","checkpoint_period",":","Checkpoint","at","the","end","of","every","x","phases","(","default","1",")"]
code: def __init__(
      self,
      checkpoint_folder: str,
      input_args: Any = None,
      phase_types: Optional[Collection[str]] = None,
      checkpoint_period: int = 1,
  ) -> None:
      """The constructor method of CheckpointHook.
  
      Args:
          checkpoint_folder: Folder to store checkpoints in
          input_args: Any arguments to save about the runtime setup. For example,
              it is useful to store the config that was used to instantiate the model.
          phase_types: If `phase_types` is specified, only checkpoint on those phase
              types. Each item in `phase_types` must be either "train" or "test". If
              not specified, it is set to checkpoint after "train" phases.
          checkpoint_period: Checkpoint at the end of every x phases (default 1)
      """
      super().__init__()
      assert isinstance(
          checkpoint_folder, str
      ), "checkpoint_folder must be a string specifying the checkpoint directory"
      assert (
          isinstance(checkpoint_period, int) and checkpoint_period > 0
      ), "checkpoint_period must be a positive integer"
  
      self.checkpoint_folder: str = checkpoint_folder
      self.input_args: Any = input_args
      if phase_types is None:
          phase_types = ["train"]
      assert len(phase_types) > 0 and all(
          phase_type in ["train", "test"] for phase_type in phase_types
      ), "phase_types should contain one or more of ['train', 'test']"
      assert (
          isinstance(checkpoint_period, int) and checkpoint_period > 0
      ), "checkpoint period must be positive"
  
      self.phase_types: Collection[str] = phase_types
      self.checkpoint_period: int = checkpoint_period
      self.phase_counter: int = 0
  
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 1 to create a new CheckpointHook object from inherited base classes: ClassyHook with example: obj = CheckpointHook(checkpoint_folder, input_args, phase_types, checkpoint_period)