class_docstr: After every loss computation, verify the loss is not infinite.
  Called for both training/test phase.
class_docstr_tok: ["After","every","loss","computation",",","verify","the","loss","is","not","infinite",".","Called","for","both","training\/test","phase","."]
docstr: Called each time a loss has been computed and checks that loss is
  not None.
docstr_tok: ["Called","each","time","a","loss","has","been","computed","and","checks","that","loss","is","not","None","."]
code: def on_loss_and_meter(self, task: "tasks.ClassyTask") -> None:
      """
      Called each time a loss has been computed and checks that loss is
      not None.
      """
      # check the loss is not NaN. The loss is already all_reduced
      loss_val = task.last_batch.loss.data.cpu()
      if not torch.isfinite(loss_val).all():
          raise FloatingPointError(
              f"Infinite Loss or NaN at iteration={task.iteration}. Loss value: {loss_val}"
          )
  
imports: import logging
  import time
  import torch
  from classy_vision import tasks
  from classy_vision.generic.profiler import compute_activations, compute_flops, count_params
  from classy_vision.hooks.classy_hook import ClassyHook
  from fvcore.common.file_io import PathManager
  from vissl.data import AirstoreDataset, GenericSSLDataset
  from vissl.models.model_helpers import model_output_has_nan
  from vissl.utils.env import get_machine_local_and_dist_rank
label_desc: Use image node_id 1 for calling the CheckNanLossHook obj's underlying member method code with example usage: obj.on_loss_and_meter(task) without return types