code: def debugprint(
      obj,
      depth=-1,
      print_type=False,
      file=None,
      ids="CHAR",
      stop_on_name=False,
      done=None,
      print_storage=False,
      print_clients=False,
      used_ids=None,
  ):
      """Print a computation graph as text to stdout or a file.
  
      :type obj: :class:`~theano.gof.Variable`, Apply, or Function instance
      :param obj: symbolic thing to print
      :type depth: integer
      :param depth: print graph to this depth (-1 for unlimited)
      :type print_type: boolean
      :param print_type: whether to print the type of printed objects
      :type file: None, 'str', or file-like object
      :param file: print to this file ('str' means to return a string)
      :type ids: str
      :param ids: How do we print the identifier of the variable
                  id - print the python id value
                  int - print integer character
                  CHAR - print capital character
                  "" - don't print an identifier
      :param stop_on_name: When True, if a node in the graph has a name,
                           we don't print anything below it.
      :type done: None or dict
      :param done: A dict where we store the ids of printed node.
          Useful to have multiple call to debugprint share the same ids.
      :type print_storage: bool
      :param print_storage: If True, this will print the storage map
          for Theano functions. Combined with allow_gc=False, after the
          execution of a Theano function, we see the intermediate result.
      :type print_clients: bool
      :param print_clients: If True, this will print for Apply node that
           have more then 1 clients its clients. This help find who use
           an Apply node.
      :type used_ids: dict or None
      :param used_ids: the id to use for some object, but maybe we only
           referred to it yet.
  
      :returns: string if `file` == 'str', else file arg
  
      Each line printed represents a Variable in the graph.
      The indentation of lines corresponds to its depth in the symbolic graph.
      The first part of the text identifies whether it is an input
      (if a name or type is printed) or the output of some Apply (in which case
      the Op is printed).
      The second part of the text is an identifier of the Variable.
      If print_type is True, we add a part containing the type of the Variable
  
      If a Variable is encountered multiple times in the depth-first search,
      it is only printed recursively the first time. Later, just the Variable
      identifier is printed.
  
      If an Apply has multiple outputs, then a '.N' suffix will be appended
      to the Apply's identifier, to indicate which output a line corresponds to.
  
      """
      if not isinstance(depth, integer_types):
          raise Exception("depth parameter must be an int")
      if file == "str":
          _file = StringIO()
      elif file is None:
          _file = sys.stdout
      else:
          _file = file
      if done is None:
          done = dict()
      if used_ids is None:
          used_ids = dict()
      used_ids = dict()
      results_to_print = []
      profile_list = []
      order = []  # Toposort
      smap = []  # storage_map
      if isinstance(obj, (list, tuple, set)):
          lobj = obj
      else:
          lobj = [obj]
      for obj in lobj:
          if isinstance(obj, gof.Variable):
              results_to_print.append(obj)
              profile_list.append(None)
              smap.append(None)
              order.append(None)
          elif isinstance(obj, gof.Apply):
              results_to_print.extend(obj.outputs)
              profile_list.extend([None for item in obj.outputs])
              smap.extend([None for item in obj.outputs])
              order.extend([None for item in obj.outputs])
          elif isinstance(obj, Function):
              results_to_print.extend(obj.maker.fgraph.outputs)
              profile_list.extend(
                  [obj.profile for item in obj.maker.fgraph.outputs]
              )
              if print_storage:
                  smap.extend(
                      [
                          obj.fn.storage_map
                          for item in obj.maker.fgraph.outputs
                      ]
                  )
              else:
                  smap.extend(
                      [None for item in obj.maker.fgraph.outputs]
                  )
              topo = obj.maker.fgraph.toposort()
              order.extend([topo for item in obj.maker.fgraph.outputs])
          elif isinstance(obj, gof.FunctionGraph):
              results_to_print.extend(obj.outputs)
              profile_list.extend(
                  [
                      getattr(obj, "profile", None)
                      for item in obj.outputs
                  ]
              )
              smap.extend(
                  [
                      getattr(obj, "storage_map", None)
                      for item in obj.outputs
                  ]
              )
              topo = obj.toposort()
              order.extend([topo for item in obj.outputs])
          elif isinstance(obj, (integer_types, float, np.ndarray)):
              print(obj, file=_file)
          elif isinstance(obj, (theano.In, theano.Out)):
              results_to_print.append(obj.variable)
              profile_list.append(None)
              smap.append(None)
              order.append(None)
          else:
              raise TypeError(
                  "debugprint cannot print an object of this type", obj
              )
  
      scan_ops = []
      if any(
          [
              p
              for p in profile_list
              if p is not None and p.fct_callcount > 0
          ]
      ):
          print(
              """
  Timing Info
  -----------
  --> <time> <% time> - <total time> <% total time>'
  
  <time>         computation time for this node
  <% time>       fraction of total computation time for this node
  <total time>   time for this node + total times for this node's ancestors
  <% total time> total time for this node over total computation time
  
  N.B.:
  * Times include the node time and the function overhead.
  * <total time> and <% total time> may over-count computation times
    if inputs to a node share a common ancestor and should be viewed as a
    loose upper bound. Their intended use is to help rule out potential nodes
    to remove when optimizing a graph because their <total time> is very low.
  """,
              file=_file,
          )
  
      for r, p, s, o in zip(
          results_to_print, profile_list, smap, order
      ):
          # Add the parent scan op to the list as well
          if hasattr(r.owner, "op") and isinstance(
              r.owner.op, theano.scan_module.scan_op.Scan
          ):
              scan_ops.append(r)
  
          debugmode.debugprint(
              r,
              depth=depth,
              done=done,
              print_type=print_type,
              file=_file,
              order=o,
              ids=ids,
              scan_ops=scan_ops,
              stop_on_name=stop_on_name,
              profile=p,
              smap=s,
              used_ids=used_ids,
              print_clients=print_clients,
          )
  
      if len(scan_ops) > 0:
          print("", file=_file)
          new_prefix = " >"
          new_prefix_child = " >"
          print("Inner graphs of the scan ops:", file=_file)
  
          for s in scan_ops:
              # prepare a dict which maps the scan op's inner inputs
              # to its outer inputs.
              if hasattr(s.owner.op, "fn"):
                  # If the op was compiled, print the optimized version.
                  inner_inputs = s.owner.op.fn.maker.fgraph.inputs
              else:
                  inner_inputs = s.owner.op.inputs
              outer_inputs = s.owner.inputs
              inner_to_outer_inputs = dict(
                  [
                      (inner_inputs[i], outer_inputs[o])
                      for i, o in s.owner.op.var_mappings[
                          "outer_inp_from_inner_inp"
                      ].items()
                  ]
              )
  
              print("", file=_file)
              debugmode.debugprint(
                  s,
                  depth=depth,
                  done=done,
                  print_type=print_type,
                  file=_file,
                  ids=ids,
                  scan_ops=scan_ops,
                  stop_on_name=stop_on_name,
                  scan_inner_to_outer_inputs=inner_to_outer_inputs,
                  print_clients=print_clients,
                  used_ids=used_ids,
              )
              if hasattr(s.owner.op, "fn"):
                  # If the op was compiled, print the optimized version.
                  outputs = s.owner.op.fn.maker.fgraph.outputs
              else:
                  outputs = s.owner.op.outputs
              for idx, i in enumerate(outputs):
                  if hasattr(i, "owner") and hasattr(i.owner, "op"):
                      if isinstance(
                          i.owner.op, theano.scan_module.scan_op.Scan
                      ):
                          scan_ops.append(i)
  
                  debugmode.debugprint(
                      r=i,
                      prefix=new_prefix,
                      depth=depth,
                      done=done,
                      print_type=print_type,
                      file=_file,
                      ids=ids,
                      stop_on_name=stop_on_name,
                      prefix_child=new_prefix_child,
                      scan_ops=scan_ops,
                      scan_inner_to_outer_inputs=inner_to_outer_inputs,
                      print_clients=print_clients,
                      used_ids=used_ids,
                  )
  
      if file is _file:
          return file
      elif file == "str":
          return _file.getvalue()
      else:
          _file.flush()
  
imports: from __future__ import absolute_import, print_function, division
  from copy import copy
  import logging
  import os
  import sys
  import hashlib
  import numpy
  from six import string_types, integer_types, iteritems
  from six.moves import StringIO, reduce
  import theano
  from theano import gof
  from theano import config
  from theano.gof import Op, Apply
  from theano.compile import Function, debugmode, SharedVariable
label_desc: Use image node_id 1 for calling a global function with example usage: debugprint(obj, depth, print_type, file, ids, stop_on_name, done, print_storage, print_clients, used_ids) and returns: file, _file