code: def detect_nan(i, node, fn):
      for output in fn.outputs:
          if (
              not isinstance(output[0], np.random.RandomState)
              and np.isnan(output[0]).any()
          ):
              print("*** NaN detected ***")
              theano.printing.debugprint(node)
              print("Inputs : %s" % [input[0] for input in fn.inputs])
              print(
                  "Outputs: %s" % [output[0] for output in fn.outputs]
              )
              break
  
file_path: Theano/theano/compile/monitormode.py
imports: from __future__ import absolute_import, print_function, division
  import numpy
  import theano
  from theano.compile.mode import Mode
label_desc: Use image node_id 1 for calling a global function with example usage: detect_nan(i, node, fn) without return types