code: def thunk_hook(type, value, trace):
      """
      This function is meant to replace excepthook and do some
      special work if the exception value has a __thunk_trace__
      field.
      In that case, it retrieves the field, which should
      contain a trace as returned by L{traceback.extract_stack},
      and prints it out on L{stderr}.
  
      The normal excepthook is then called.
  
      Parameters:
      ----------
      type
          Exception class
      value
          Exception instance
      trace
          Traceback object
  
      Notes
      -----
      This hook replaced by nosetests, so it does not run in nose tests.
  
      """
      log_thunk_trace(value)
      __excepthook(type, value, trace)
  
imports: from __future__ import absolute_import, print_function, division
  from copy import copy, deepcopy
  from sys import getsizeof
  import sys
  import traceback
  import numpy
  import theano
  from theano.compat import izip
  from six import reraise
  from six.moves import StringIO
  from theano.gof import utils
  from theano.gof import graph
  from theano.gof.type import Type
  from .utils import undef
label_desc: Use image node_id 2 for calling a global function with example usage: thunk_hook(type, value, trace) without return types