code: def _check_nan_inf(x, dtype, neg=None):
      if dtype.char in "FD":
          dtype = cupy.dtype(dtype.char.lower())
      if dtype.char not in "efd":
          x = 0
      elif x is None and neg is not None:
          x = cupy.finfo(dtype).min if neg else cupy.finfo(dtype).max
      elif cupy.isnan(x):
          x = cupy.nan
      elif cupy.isinf(x):
          x = cupy.inf * (-1) ** (x < 0)
      return cupy.asanyarray(x, dtype)
  
file_path: cupy/cupy/_math/misc.py
imports: import cupy
  import cupyx.scipy.fft
  from cupy import _core
  from cupy._core import _routines_math
  from cupy._core import fusion
  from cupy.lib import stride_tricks
  import numpy
label_desc: Use image node_id 7 for calling a global function with example usage: _check_nan_inf(x, dtype, neg) and returns: cupy