class_docstr: Hook executed on a backward pass that clips gradients such that their
  norm does not exceed a specific value. Dosovitskiy et al. found it
  to be critical for training vision transformers
  (https://arxiv.org/abs/2010.11929), but subsequent studies have been less
  clear about its importance. Gradient clipping configuration is set in
  config.MODEL.GRAD_CLIP
code: def on_backward(self, task: tasks.ClassyTask) -> None:
      if task.amp_type == AmpType.PYTORCH:
          task.amp_grad_scaler.unscale_(task.optimizer)
  
      if isinstance(task.model, FullyShardedDataParallel):
          task.model.clip_grad_norm_(
              max_norm=self.max_norm, norm_type=self.norm_type
          )
      else:
          utils.clip_grad_norm_(
              task.model.parameters(),
              max_norm=self.max_norm,
              norm_type=self.norm_type,
          )
  
file_path: vissl/vissl/hooks/grad_clip_hooks.py
imports: from typing import Union
  import torch.nn.utils
  from classy_vision import tasks
  from classy_vision.hooks.classy_hook import ClassyHook
  from classy_vision.tasks.classification_task import AmpType
  from fairscale.nn import FullyShardedDataParallel
label_desc: Use image node_id 2 for calling the GradClipHook obj's underlying member method code with example usage: obj.on_backward(task) without return types