class_docstr: We use DistributedDataSampler for sampling the data. At the beginnning of
  each training epoch/phase, we need to set the epoch for the sampler.
class_docstr_tok: ["We","use","DistributedDataSampler","for","sampling","the","data",".","At","the","beginnning","of","each","training","epoch\/phase",",","we","need","to","set","the","epoch","for","the","sampler","."]
docstr: Called at the start of each epoch or phase to set the data
  sampler epoch. This is important to ensure the data
  is shuffled and the shuffling can be reproduced deterministically
  if the training is resumed from a checkpoint.
docstr_tok: ["Called","at","the","start","of","each","epoch","or","phase","to","set","the","data","sampler","epoch",".","This","is","important","to","ensure","the","data","is","shuffled","and","the","shuffling","can","be","reproduced","deterministically","if","the","training","is","resumed","from","a","checkpoint","."]
code: def on_phase_start(self, task: "tasks.ClassyTask") -> None:
      """
      Called at the start of each epoch or phase to set the data
      sampler epoch. This is important to ensure the data
      is shuffled and the shuffling can be reproduced deterministically
      if the training is resumed from a checkpoint.
      """
      task.phase_start_time = time.time()
      task.batches = 0
      task.losses = []
      # (Re-)Shuffle data:
      phase_type = "train" if task.train else "test"
      # set epoch of distributed sampler
      if hasattr(task.dataloaders[phase_type], "sampler"):
          if hasattr(task.dataloaders[phase_type].sampler, "set_epoch"):
              # task.phase_idx is current running phase id
              task.dataloaders[phase_type].sampler.set_epoch(
                  task.phase_idx
              )
  
      # call set_epoch and for AirstoreDataset since it handles shuffle
      # behavior internally
      if hasattr(task.dataloaders[phase_type], "dataset"):
          dataset = task.dataloaders[phase_type].dataset
          if isinstance(dataset, GenericSSLDataset):
              for data_obj in dataset.data_objs:
                  if isinstance(data_obj, AirstoreDataset):
                      # task.phase_idx is current running phase id
                      data_obj.set_epoch(task.phase_idx)
  
      logging.info(f"Starting phase {task.phase_idx} [{phase_type}]")
  
imports: import logging
  import time
  import torch
  from classy_vision import tasks
  from classy_vision.generic.profiler import compute_activations, compute_flops, count_params
  from classy_vision.hooks.classy_hook import ClassyHook
  from fvcore.common.file_io import PathManager
  from vissl.data import AirstoreDataset, GenericSSLDataset
  from vissl.models.model_helpers import model_output_has_nan
  from vissl.utils.env import get_machine_local_and_dist_rank
label_desc: Use image node_id 1 for calling the SetDataSamplerEpochHook obj's underlying member method code with example usage: obj.on_phase_start(task) without return types