class_docstr: This hook is used when config.METERS:.model_output_mask=True. It is used to ignore
  certain classes during test-time and is used for Imagenet out-of-domain datasets
  (e.g. objectnet and imagenet_r).
  
  The logic is as follows:
  
  1. Find all unique label indexes in the test set.
  2. During testing, set model output to -inf when the label index is not present, leave it
  unchanged otherwise.
  3. Feed model output into the respective meters. For classification with logit outputs,
  this has the effect of ignoring the classes that are not present in the
  top-1/top-5 calculations.
code: def on_forward(self, task: tasks.ClassyTask) -> None:
      assert (
          task.config.METERS.model_output_mask
      ), "This hook should only be run when using a model_output_mask"
  
      if task.train:
          # Hook will do nothing when training.
          return
  
      assert (
          "test" in task.datasets
      ), "Task must have test dataset in order to use the ModelOutputMaskHook."
  
      if self.unique_labels is None:
          self.unique_labels = self._get_unique_labels(task)
  
      # Get the model output(s)
      model_outputs = task.last_batch.model_output
      if not isinstance(model_outputs, list):
          model_outputs = [model_outputs]
  
      # Mask the model output in-place.
      model_output_masks = self._create_model_output_masks(
          model_outputs
      )
      for out, mask in zip(model_outputs, model_output_masks):
          out.masked_fill_(mask, -math.inf)
  
file_path: vissl/vissl/hooks/model_output_mask_hook.py
imports: import math
  from typing import List, Union
  import torch
  from classy_vision import tasks
  from classy_vision.hooks.classy_hook import ClassyHook
label_desc: Use image node_id 2 for calling the ModelOutputMaskHook obj's underlying member method code with example usage: obj.on_forward(task) without return types