code: def model_output_has_nan(model_output) -> bool:
      """
      Model output can be:
      - a tensor
      - list of tensors
      - list of list of tensors
      """
      from vissl.losses.cross_entropy_multiple_output_single_target import (
          EnsembleOutput,
      )
  
      if isinstance(model_output, list):
          return any(model_output_has_nan(x) for x in model_output)
      elif isinstance(model_output, EnsembleOutput):
          return not torch.isfinite(model_output.outputs).all()
      else:
          return not torch.isfinite(model_output).all()
  
imports: import logging
  import math
  import warnings
  from enum import Enum
  from typing import Dict, List, Tuple
  import torch
  import torch.distributed
  import torch.nn
  import torch.nn.functional
  from torch.nn.modules.utils import _ntuple
  from torch.utils.checkpoint import checkpoint
  from vissl.data.collators.collator_helper import MultiDimensionalTensor
  from vissl.utils.activation_checkpointing import checkpoint_trunk
  from vissl.utils.env import get_machine_local_and_dist_rank
  from vissl.utils.misc import is_apex_available
label_desc: Use image node_id 2 for calling a global function with example usage: model_output_has_nan(model_output) and returns: any, unknown, unknown