class_docstr: The main entry point for any training or feature extraction workflows in VISSL.
  
  The trainer constructs a train_task which prepares all the components of the
  training (optimizer, loss, meters, model etc) using the settings specified by user
  in the yaml config file. See the vissl/trainer/train_task.py for more details.
  
  Args:
      cfg (AttrDict): user specified input config that has optimizer, loss, meters etc
                      settings relevant to the training
      dist_run_id (str): For multi-gpu training with PyTorch, we have to specify
                         how the gpus are going to rendezvous. This requires specifying
                         the communication method: file, tcp and the unique rendezvous
                         run_id that is specific to 1 run.
                         We recommend:
                              1) for 1node: use init_method=tcp and run_id=auto
                              2) for multi-node, use init_method=tcp and specify
                              run_id={master_node}:{port}
      checkpoint_path (str): if the training is being resumed from a checkpoint, path to
                        the checkpoint. The tools/run_distributed_engines.py automatically
                        looks for the checkpoint in the checkpoint directory.
      checkpoint_folder (str): what directory to use for checkpointing. The
                        tools/run_distributed_engines.py creates the directory based on user
                        input in the yaml config file.
      hooks (List[ClassyHooks]): the list of hooks to use during the training. The hooks
                        vissl/engines/{train, extract_features}.py determine the hooks.
docstr: Extract workflow supports multi-gpu feature extraction and also extracting
  predicted labels. Since we are only extracting features or label predictions,
  only the model is built (and initialized from some model weights file
  if specified by user). Optionally the meters are built if the labels
  are being extracted. The model is set to the eval mode fully.
  
  The features / labels are extracted for whatever data splits (train, val, test)
  the user wants.
docstr_tok: ["Extract","workflow","supports","multi-gpu","feature","extraction","and","also","extracting","predicted","labels",".","Since","we","are","only","extracting","features","or","label","predictions",",","only","the","model","is","built","(","and","initialized","from","some","model","weights","file","if","specified","by","user",")",".","Optionally","the","meters","are","built","if","the","labels","are","being","extracted",".","The","model","is","set","to","the","eval","mode","fully",".","The","features","\/","labels","are","extracted","for","whatever","data","splits","(","train",",","val",",","test",")","the","user","wants","."]
code: def extract(
      self,
      output_folder: str,
      extract_features: bool = True,
      extract_predictions: bool = False,
  ) -> None:
      """
      Extract workflow supports multi-gpu feature extraction and also extracting
      predicted labels. Since we are only extracting features or label predictions,
      only the model is built (and initialized from some model weights file
      if specified by user). Optionally the meters are built if the labels
      are being extracted. The model is set to the eval mode fully.
  
      The features / labels are extracted for whatever data splits (train, val, test)
      the user wants.
      """
      # support feature/label predictions extraction on gpu only.
      assert self.task.device.type == "cuda", "Set MACHINE.DEVICE = gpu"
      self.task.prepare_extraction(pin_memory=self.cfg.DATA.PIN_MEMORY)
  
      # Create distributed model
      self.task.add_dummy_layer()
      self.task.init_distributed_data_parallel_model()
      if is_primary():
          logging.info(f"Model is:\n {self.task.model}")
  
      # Get the names of the features that we are extracting. If user doesn't
      # specify the features to evaluate, we get the full model output and freeze
      # head/trunk both as caution.
      feat_names = get_trunk_output_feature_names(self.cfg.MODEL)
      if len(feat_names) == 0:
          feat_names = ["heads"]
  
      self.task.train = False
      self.task.run_hooks(SSLClassyHookFunctions.on_start.name)
      for split in self.task.available_splits:
          logging.info(
              f"============== Split: {split} ======================="
          )
          self.task.data_iterator = iter(
              self.task.dataloaders[split.lower()]
          )
          if extract_features:
              logging.info(
                  f"Extracting features for partition: {split.lower()}"
              )
              self._extract_split_features(
                  feat_names, self.task, split, output_folder
              )
              logging.info(
                  f"Done getting features for partition: {split.lower()}"
              )
          if extract_predictions:
              logging.info(
                  f"Extracting predictions for partition: {split.lower()}"
              )
              self._extract_split_label_predictions(
                  feat_names, self.task, split, output_folder
              )
              logging.info(
                  f"Done getting predictions for partition: {split.lower()}"
              )
      self.task.run_hooks(SSLClassyHookFunctions.on_end.name)
  
      self._cleanup_task()
  
imports: import gc
  import itertools
  import logging
  import os
  import socket
  import time
  from types import SimpleNamespace
  from typing import Any, Dict, List, Tuple
  import numpy
  import torch
  import torch.distributed
  from classy_vision.generic.distributed_util import barrier, is_primary, set_cpu_device, set_cuda_device_index
  from classy_vision.hooks.classy_hook import ClassyHook
  from classy_vision.tasks import ClassyTask, TASK_REGISTRY
  from vissl.config import AttrDict
  from vissl.hooks import SSLClassyHookFunctions
  from vissl.models.model_helpers import get_trunk_output_feature_names
  from vissl.trainer.train_steps import get_train_step
  from vissl.utils.distributed_utils import all_gather_heterogeneous, all_gather_sizes
  from vissl.utils.env import get_machine_local_and_dist_rank
  from vissl.utils.io import save_file
label_desc: Use image node_id 6 for calling the SelfSupervisionTrainer obj's underlying member method code with example usage: obj.extract(output_folder, extract_features, extract_predictions) without return types