class_docstr: Hook used to trigger the profiling features of VISSL
code: def __init__(self, profiling_config: AttrDict):
      super().__init__()
      self.output_folder = profiling_config.OUTPUT_FOLDER
      self.start_iteration = (
          profiling_config.START_ITERATION
          + profiling_config.WARMUP_ITERATIONS
      )
      self.end_iteration = (
          self.start_iteration + profiling_config.NUM_ITERATIONS
      )
      self.interrupt_training = (
          profiling_config.STOP_TRAINING_AFTER_PROFILING
      )
      self.dist_rank = get_machine_local_and_dist_rank()[1]
      self.is_profiling_rank = (
          self.dist_rank in profiling_config.PROFILED_RANKS
      )
      self.profile_runtime = (
          self.is_profiling_rank
          and profiling_config.RUNTIME_PROFILING.USE_PROFILER
      )
      self.runtime_profiler = create_runtime_profiler(
          enabled=self.profile_runtime,
          use_cpu=profiling_config.RUNTIME_PROFILING.PROFILE_CPU,
          use_cuda=profiling_config.RUNTIME_PROFILING.PROFILE_GPU,
          wait=profiling_config.START_ITERATION,
          warmup=profiling_config.WARMUP_ITERATIONS,
          active=profiling_config.NUM_ITERATIONS,
          legacy_profiler=profiling_config.RUNTIME_PROFILING.LEGACY_PROFILER,
      )
      self.profile_by_layer_memory = (
          self.is_profiling_rank
          and profiling_config.MEMORY_PROFILING.TRACK_BY_LAYER_MEMORY
      )
      if self.profile_by_layer_memory:
          logging.info(
              f"Setting up memory tracker for rank {self.dist_rank}..."
          )
          self.layer_memory_tracker = LayerwiseMemoryTracker()
  
imports: import logging
  import os
  import torch
  import torch.nn
  from classy_vision import tasks
  from classy_vision.hooks.classy_hook import ClassyHook
  from fairscale.nn import FullyShardedDataParallel
  from fairscale.nn.misc import FlattenParamsWrapper
  from torch.nn import SyncBatchNorm
  from vissl.config.attr_dict import AttrDict
  from vissl.utils.env import get_machine_local_and_dist_rank
  from vissl.utils.layer_memory_tracking import LayerwiseMemoryTracker
  from vissl.utils.profiler import create_runtime_profiler
label_desc: Use image node_id 2 to create a new ProfilingHook object from inherited base classes: ClassyHook with example: obj = ProfilingHook(profiling_config)