code: def test_debugprint():
      A = tensor.matrix(name="A")
      B = tensor.matrix(name="B")
      C = A + B
      C.name = "C"
      D = tensor.matrix(name="D")
      E = tensor.matrix(name="E")
  
      F = D + E
      G = C + F
      mode = theano.compile.get_default_mode().including("fusion")
      g = theano.function([A, B, D, E], G, mode=mode)
  
      # just test that it work
      s = StringIO()
      debugprint(G, file=s)
  
      # test ids=int
      s = StringIO()
      debugprint(G, file=s, ids="int")
      s = s.getvalue()
      # The additional white space are needed!
      reference = (
          "\n".join(
              [
                  "Elemwise{add,no_inplace} [id 0] ''   ",
                  " |Elemwise{add,no_inplace} [id 1] 'C'   ",
                  " | |A [id 2]",
                  " | |B [id 3]",
                  " |Elemwise{add,no_inplace} [id 4] ''   ",
                  "   |D [id 5]",
                  "   |E [id 6]",
              ]
          )
          + "\n"
      )
  
      if s != reference:
          print("--" + s + "--")
          print("--" + reference + "--")
  
      assert s == reference
  
      # test ids=CHAR
      s = StringIO()
      debugprint(G, file=s, ids="CHAR")
      s = s.getvalue()
      # The additional white space are needed!
      reference = (
          "\n".join(
              [
                  "Elemwise{add,no_inplace} [id A] ''   ",
                  " |Elemwise{add,no_inplace} [id B] 'C'   ",
                  " | |A [id C]",
                  " | |B [id D]",
                  " |Elemwise{add,no_inplace} [id E] ''   ",
                  "   |D [id F]",
                  "   |E [id G]",
              ]
          )
          + "\n"
      )
  
      if s != reference:
          print("--" + s + "--")
          print("--" + reference + "--")
  
      assert s == reference
  
      # test ids=CHAR, stop_on_name=True
      s = StringIO()
      debugprint(G, file=s, ids="CHAR", stop_on_name=True)
      s = s.getvalue()
      # The additional white space are needed!
      reference = (
          "\n".join(
              [
                  "Elemwise{add,no_inplace} [id A] ''   ",
                  " |Elemwise{add,no_inplace} [id B] 'C'   ",
                  " |Elemwise{add,no_inplace} [id C] ''   ",
                  "   |D [id D]",
                  "   |E [id E]",
              ]
          )
          + "\n"
      )
  
      if s != reference:
          print("--" + s + "--")
          print("--" + reference + "--")
  
      assert s == reference
  
      # test ids=
      s = StringIO()
      debugprint(G, file=s, ids="")
      s = s.getvalue()
      # The additional white space are needed!
      reference = (
          "\n".join(
              [
                  "Elemwise{add,no_inplace}  ''   ",
                  " |Elemwise{add,no_inplace}  'C'   ",
                  " | |A ",
                  " | |B ",
                  " |Elemwise{add,no_inplace}  ''   ",
                  "   |D ",
                  "   |E ",
              ]
          )
          + "\n"
      )
      if s != reference:
          print("--" + s + "--")
          print("--" + reference + "--")
  
      assert s == reference
  
      # test print_storage=True
      s = StringIO()
      debugprint(g, file=s, ids="", print_storage=True)
      s = s.getvalue()
      # The additional white space are needed!
      reference = (
          "\n".join(
              [
                  "Elemwise{add,no_inplace}  ''   0 [None]",
                  " |A  [None]",
                  " |B  [None]",
                  " |D  [None]",
                  " |E  [None]",
              ]
          )
          + "\n"
      )
      if s != reference:
          print("--" + s + "--")
          print("--" + reference + "--")
  
      assert s == reference
  
      # test clients
      s = StringIO()
      # We must force the mode as otherwise it can change the clients order
      f = theano.function(
          [A, B, D], [A + B, A + B - D], mode="FAST_COMPILE"
      )
      debugprint(f, file=s, print_clients=True)
      s = s.getvalue()
      # The additional white space are needed!
      reference = (
          "\n".join(
              [
                  "Elemwise{add,no_inplace} [id A] ''   0 clients:[('output', ''), ('[id C]', 1)]",
                  " |A [id D]",
                  " |B [id E]",
                  "Elemwise{sub,no_inplace} [id C] ''   1",
                  " |Elemwise{add,no_inplace} [id A] ''   0 clients:[('output', ''), ('[id C]', 1)]",
                  " |D [id F]",
              ]
          )
          + "\n"
      )
      if s != reference:
          print("--" + s + "--")
          print("--" + reference + "--")
  
      assert s == reference
  
imports: from __future__ import absolute_import, print_function, division
  import logging
  from nose.plugins.skip import SkipTest
  import numpy
  from six.moves import StringIO
  import theano
  import theano.tensor
  from theano.printing import min_informative_str, debugprint
label_desc: Use image node_id 6 for calling a global function with example usage: test_debugprint() without return types