docstr: Test that the checkpoint_period works as expected.
docstr_tok: ["Test","that","the","checkpoint_period","works","as","expected","."]
code: def test_checkpoint_period(self) -> None:
      """
      Test that the checkpoint_period works as expected.
      """
      config = get_test_task_config()
      task = build_task(config)
      task.prepare()
  
      checkpoint_folder = self.base_dir + "/checkpoint_end_test/"
      checkpoint_period = 10
  
      for phase_types in [["train"], ["train", "test"]]:
          # create a checkpoint hook
          checkpoint_hook = CheckpointHook(
              checkpoint_folder,
              {},
              phase_types=phase_types,
              checkpoint_period=checkpoint_period,
          )
  
          # create checkpoint dir
          os.mkdir(checkpoint_folder)
  
          # call the on start function
          checkpoint_hook.on_start(task)
  
          # shouldn't create any checkpoints until there are checkpoint_period
          # phases which are in phase_types
          count = 0
          valid_phase_count = 0
          while valid_phase_count < checkpoint_period - 1:
              task.train = count % 2 == 0
              # call the on end phase function
              checkpoint_hook.on_phase_end(task)
              checkpoint = load_checkpoint(checkpoint_folder)
              self.assertIsNone(checkpoint)
              valid_phase_count += (
                  1 if task.phase_type in phase_types else 0
              )
              count += 1
  
          # create a phase which is in phase_types
          task.train = True
          # call the on end phase function
          checkpoint_hook.on_phase_end(task)
          # model should be checkpointed. load and compare
          checkpoint = load_checkpoint(checkpoint_folder)
          self.assertIsNotNone(checkpoint)
          # delete the checkpoint dir
          shutil.rmtree(checkpoint_folder)
  
imports: import copy
  import importlib
  import os
  import shutil
  import tempfile
  import torch
  from classy_vision.generic.util import load_checkpoint
  from classy_vision.hooks import CheckpointHook
  from classy_vision.tasks import build_task
  from classy_vision.trainer import LocalTrainer
  from fvcore.common import file_io
  from fvcore.common.file_io import PathHandler, PathManager
  from test.generic.config_utils import get_fast_test_task_config, get_test_task_config
  from test.generic.hook_test_utils import HookTestBase
label_desc: Use image node_id 6 for calling the TestCheckpointHook obj's underlying member method code with example usage: obj.test_checkpoint_period() without return types