code: def torch_isnan(x):
      """
      A convenient function to check if a Tensor contains any nan; also works with numbers
      """
      if isinstance(x, numbers.Number):
          return x != x
      return torch.isnan(x).any()
  
imports: import functools
  import math
  import numbers
  import random
  import sys
  import timeit
  import warnings
  from collections import defaultdict
  from contextlib import contextmanager
  from itertools import zip_longest
  import numpy
  import torch
  from pyro.poutine.util import site_is_subsample
label_desc: Use image node_id 4 for calling a global function with example usage: torch_isnan(x) and returns: torch, unknown