class_docstr: A task prepares and holds all the components of a training like optimizer, datasets,
  dataloaders, losses, meters etc. Task also contains the variable like training iteration,
  epoch number etc. that are updated during the training.
  
  We prepare every single component according to the parameter settings user wants
  and specified in the yaml config file.
  
  Task also supports 2 additional things:
  1) converts the model BatchNorm layers to the synchronized batchnorm
  2) sets mixed precision (apex and pytorch both supported)
class_docstr_tok: ["A","task","prepares","and","holds","all","the","components","of","a","training","like","optimizer",",","datasets",",","dataloaders",",","losses",",","meters","etc",".","Task","also","contains","the","variable","like","training","iteration",",","epoch","number","etc",".","that","are","updated","during","the","training",".","We","prepare","every","single","component","according","to","the","parameter","settings","user","wants","and","specified","in","the","yaml","config","file",".","Task","also","supports","2","additional","things",":","1",")","converts","the","model","BatchNorm","layers","to","the","synchronized","batchnorm","2",")","sets","mixed","precision","(","apex","and","pytorch","both","supported",")"]
code: def __init__(self, config: AttrDict):
      super().__init__()
      self.config = config
      self.checkpoint_path = None
  
      # Register the task to the proper device (cpu, gpu, ...)
      self.set_device()
  
      self.checkpoint_folder = None
      self.checkpoint = None
      self.available_splits = []
      self.base_loss = None
      self.meters = None
      self.datasets = None
      self.phases = []
      self.hooks = []
      self.base_model = None
      self.optimizer = None
      self.amp_args = None
      self.amp_type = None
      self.amp_grad_scaler = None
      self.data_and_label_keys = []
      self.set_amp_args()
      self._enable_manual_gradient_reduction = None
      # total number of parameter updates applied to the model by optimizer
      self.num_updates = 0
      # measure time of several training components (data, forward, backward etc..)
      self.perf_stats = None
      # total number of phases including test + train
      self.num_phases = -1  # set by the trainer
      # number of train only phases
      self.num_train_phases = -1  # set by the prepare method
      # number or train epochs set to num_train_phases
      self.num_epochs = -1  # set by the trainer
      # total number of "training" iterations. Inferred from dataloader length and
      # num_train_phases
      self.max_iteration = -1  # set by trainer
      # Current phase id (includes train/test). Starts from 0
      self.phase_idx = -1
      # id of the current training phase training is at. Starts from 0
      self.train_phase_idx = -1  # set by trainer
      # metrics stored during the training.
      self.metrics = {}  # set by the trainer
      self.start_time = -1  # set by trainer
      # time of each batch in training and testing. This can be used to get average
      # batch time etc. batch_time is appended after every parameter update.
      self.batch_time = []  # set by trainer
      # we maintain and store the iteration in the state itself. It counts
      # total number of iterations we do in training phases. Updated
      # after every forward pass of training step.
      # Starts from 1
      self.iteration = 0
      # collect how many total iterations we make irrespective of train/test phase.
      # Useful for debugging purposes. Starts from 1.
      self.local_iteration_num = -1  # set by trainer
      # for every phase, record the start time. Reset at the beginning of each phase
      # by SetDataSamplerEpochHook hook.
      self.phase_start_time = (
          -1
      )  # set by the hook at start of each epoch or phase
      # for every phase, record the number of batches seen. Incremented after every
      # forward pass. Reset at the start of each phase by
      # SetDataSamplerEpochHook hook. Useful for debugging.
      self.batches = (
          -1
      )  # set by the hook at start of each epoch or phase
      # loss curve. Reset at start of each phase/epoch by SetDataSamplerEpochHook hook.
      self.losses = (
          []
      )  # set by the hook at start of each epoch or phase
      # set the bucket_cap_mb for gradient reduction. This can be tuned to overlap
      # communication as much as possible
      self.set_ddp_bucket_cap_mb()
      self.use_gpu = self.device.type == "cuda"
      # optionally save the exponential moving average (ema) of the base_model.
      # and/or run the meters on the ema of the base_model.
      self.ema_model = None
      self.ema_meters = []
  
imports: import gc
  import logging
  import torch
  from classy_vision.generic.distributed_util import is_distributed_training_run
  from classy_vision.generic.util import copy_model_to_gpu
  from classy_vision.hooks import ClassyHook
  from classy_vision.losses import build_loss
  from classy_vision.meters import build_meter
  from classy_vision.optim import build_optimizer, build_optimizer_schedulers
  from classy_vision.tasks import ClassificationTask, register_task
  from classy_vision.tasks.classification_task import AmpType, BroadcastBuffersMode
  from fairscale.nn import FullyShardedDataParallel
  from iopath.common.file_io import g_pathmgr
  from torch.cuda.amp import GradScaler
  from vissl.config import AttrDict
  from vissl.data import build_dataloader, build_dataset, print_sampler_config
  from vissl.models import build_model, convert_sync_bn
  from vissl.optimizers import get_optimizer_param_groups
  from vissl.utils.activation_checkpointing import manual_gradient_reduction
  from vissl.utils.checkpoint import CheckpointLoader
  from vissl.utils.ema_model import ModelEmaV2
  from vissl.utils.misc import is_apex_available, is_fairscale_sharded_available
label_desc: Use image node_id 1 to create a new SelfSupervisionTask object from inherited base classes: ClassificationTask with example: obj = SelfSupervisionTask(config)