code: def test_debugprint():
      with pytest.raises(TypeError):
          debugprint("blah")
  
      A = dmatrix(name="A")
      B = dmatrix(name="B")
      C = A + B
      C.name = "C"
      D = dmatrix(name="D")
      E = dmatrix(name="E")
  
      F = D + E
      G = C + F
      mode = pytensor.compile.get_default_mode().including("fusion")
      g = pytensor.function([A, B, D, E], G, mode=mode)
  
      # just test that it work
      s = StringIO()
      debugprint(G, file=s)
  
      s = StringIO()
      debugprint(G, file=s, id_type="int")
      s = s.getvalue()
      reference = dedent(
          r"""
          Add [id 0]
           ├─ Add [id 1] 'C'
           │  ├─ A [id 2]
           │  └─ B [id 3]
           └─ Add [id 4]
              ├─ D [id 5]
              └─ E [id 6]
          """
      ).lstrip()
  
      assert s == reference
  
      s = StringIO()
      debugprint(G, file=s, id_type="CHAR")
      s = s.getvalue()
      # The additional white space are needed!
      reference = dedent(
          r"""
          Add [id A]
           ├─ Add [id B] 'C'
           │  ├─ A [id C]
           │  └─ B [id D]
           └─ Add [id E]
              ├─ D [id F]
              └─ E [id G]
          """
      ).lstrip()
  
      assert s == reference
  
      s = StringIO()
      debugprint(G, file=s, id_type="CHAR", stop_on_name=True)
      s = s.getvalue()
      # The additional white space are needed!
      reference = dedent(
          r"""
          Add [id A]
           ├─ Add [id B] 'C'
           │  └─ ···
           └─ Add [id C]
              ├─ D [id D]
              └─ E [id E]
          """
      ).lstrip()
  
      assert s == reference
  
      s = StringIO()
      debugprint(G, file=s, id_type="")
      s = s.getvalue()
      reference = dedent(
          r"""
          Add
           ├─ Add 'C'
           │  ├─ A
           │  └─ B
           └─ Add
              ├─ D
              └─ E
          """
      ).lstrip()
  
      assert s == reference
  
      s = StringIO()
      debugprint(g, file=s, id_type="", print_storage=True)
      s = s.getvalue()
      reference = dedent(
          r"""
          Add 0 [None]
           ├─ A [None]
           ├─ B [None]
           ├─ D [None]
           └─ E [None]
          """
      ).lstrip()
  
      assert s == reference
  
      # Test the `profile` handling when profile data is missing
      g = pytensor.function([A, B, D, E], G, mode=mode, profile=True)
  
      s = StringIO()
      debugprint(g, file=s, id_type="", print_storage=True)
      s = s.getvalue()
      reference = dedent(
          r"""
          Add 0 [None]
           ├─ A [None]
           ├─ B [None]
           ├─ D [None]
           └─ E [None]
          """
      ).lstrip()
  
      assert s == reference
  
      # Add profile data
      g(np.c_[[1.0]], np.c_[[1.0]], np.c_[[1.0]], np.c_[[1.0]])
  
      s = StringIO()
      debugprint(g, file=s, id_type="", print_storage=True)
      s = s.getvalue()
      reference = dedent(
          r"""
          Add 0 [None]
           ├─ A [None]
           ├─ B [None]
           ├─ D [None]
           └─ E [None]
          """
      ).lstrip()
  
      assert reference in s
  
      A = dmatrix(name="A")
      B = dmatrix(name="B")
      D = dmatrix(name="D")
      J = dvector()
      s = StringIO()
      debugprint(
          pytensor.function(
              [A, B, D, J], A + (B.dot(J) - D), mode="FAST_RUN"
          ),
          file=s,
          id_type="",
          print_destroy_map=True,
          print_view_map=True,
      )
      s = s.getvalue()
      Gemv_op_name = (
          "CGemv" if pytensor.config.blas__ldflags else "Gemv"
      )
      exp_res = dedent(
          r"""
          Composite{(i2 + (i0 - i1))} 4
          ├─ ExpandDims{axis=0} v={0: [0]} 3
          """
          f"        │  └─ {Gemv_op_name}{{inplace}} d={{0: [0]}} 2"
          r"""
          │     ├─ AllocEmpty{dtype='float64'} 1
          │     │  └─ Shape_i{0} 0
          │     │     └─ B
          │     ├─ 1.0
          │     ├─ B
          │     ├─ <Vector(float64, shape=(?,))>
          │     └─ 0.0
          ├─ D
          └─ A
  
          Inner graphs:
  
          Composite{(i2 + (i0 - i1))}
          ← add 'o0'
              ├─ i2
              └─ sub
              ├─ i0
              └─ i1
          """
      ).lstrip()
  
      assert [l.strip() for l in s.split("\n")] == [
          l.strip() for l in exp_res.split("\n")
      ]
  
imports: import logging
  from io import StringIO
  from textwrap import dedent
  import numpy
  import pytest
  import pytensor
  from pytensor.compile.mode import get_mode
  from pytensor.compile.ops import deep_copy_op
  from pytensor.printing import PatternPrinter, PPrinter, Print, debugprint, default_printer, get_node_by_id, min_informative_str, pp, pydot_imported, pydotprint
  from pytensor.tensor import as_tensor_variable
  from pytensor.tensor.type import dmatrix, dvector, matrix
  from tests.graph.utils import MyInnerGraphOp, MyOp, MyVariable
label_desc: Use image node_id 6 for calling a global function with example usage: test_debugprint() without return types