code: def add_loss_hooks(hooks, loss_cfg, cfg):
      if cfg.LOSS.name == "swav_loss":
          hooks.extend(
              [SwAVUpdateQueueScoresHook(), NormalizePrototypesHook()]
          )
      if cfg.LOSS.name == "swav_momentum_loss":
          hooks.extend(
              [
                  SwAVMomentumHook(
                      cfg.LOSS["swav_momentum_loss"]["momentum"],
                      cfg.LOSS["swav_momentum_loss"][
                          "momentum_eval_mode_iter_start"
                      ],
                      cfg.LOSS["swav_momentum_loss"][
                          "crops_for_assign"
                      ],
                  ),
                  SwAVMomentumNormalizePrototypesHook(),
              ]
          )
      if cfg.LOSS.name in {"dino_loss", "msn_loss"}:
          hooks.append(DINOHook())
      if cfg.LOSS.name in {"ibot_loss"}:
          hooks.append(IBOTHook())
      if cfg.LOSS.name == "deepclusterv2_loss":
          hooks.extend([InitMemoryHook(), ClusterMemoryHook()])
      if cfg.LOSS.name == "moco_loss":
          hooks.extend(
              [
                  MoCoHook(
                      cfg.LOSS["moco_loss"]["momentum"],
                      shuffle_batch=(
                          not cfg.MODEL.SYNC_BN_CONFIG.CONVERT_BN_TO_SYNC_BN
                      ),
                  )
              ]
          )
      return hooks
  
imports: from enum import auto, Enum
  from typing import List
  from classy_vision.hooks.classy_hook import ClassyHook
  from vissl.config import AttrDict
  from vissl.hooks.deepclusterv2_hooks import ClusterMemoryHook, InitMemoryHook
  from vissl.hooks.dino_hooks import DINOHook
  from vissl.hooks.distillation_hooks import DistillationHook
  from vissl.hooks.ema_hooks import EmaHook
  from vissl.hooks.grad_clip_hooks import GradClipHook
  from vissl.hooks.ibot_hooks import IBOTHook
  from vissl.hooks.log_hooks import DumpMemoryOnException, LogGpuMemoryHook, LogGpuStatsHook, LogLossLrEtaHook, LogLossMetricsCheckpointHook, LogPerfTimeMetricsHook
  from vissl.hooks.moco_hooks import MoCoHook
  from vissl.hooks.model_output_mask_hook import ModelOutputMaskHook
  from vissl.hooks.profiling_hook import CudaSynchronizeHook, ProfilingHook
  from vissl.hooks.state_update_hooks import CheckNanLossHook, CheckNanModelOutputHook, FreezeParametersHook, SetDataSamplerEpochHook, SSLModelComplexityHook
  from vissl.hooks.swav_hooks import NormalizePrototypesHook, SwAVUpdateQueueScoresHook
  from vissl.hooks.swav_momentum_hooks import SwAVMomentumHook, SwAVMomentumNormalizePrototypesHook
  from vissl.hooks.tensorboard_hook import SSLTensorboardHook
  from vissl.utils.checkpoint import get_checkpoint_folder
  from vissl.utils.tensorboard import get_tensorboard_hook, is_tensorboard_available
label_desc: Use image node_id 1 for calling a global function with example usage: add_loss_hooks(hooks, loss_cfg, cfg) and returns: hooks