code: def test_debugprint_compiled_fn():
      M = pt.tensor(dtype=np.float64, shape=(20000, 2, 2))
      one = pt.as_tensor(1, dtype=np.int64)
      zero = pt.as_tensor(0, dtype=np.int64)
  
      def no_shared_fn(n, x_tm1, M):
          p = M[n, x_tm1]
          return pt.switch(pt.lt(zero, p[0]), one, zero)
  
      out, updates = pytensor.scan(
          no_shared_fn,
          outputs_info=[{"initial": zero, "taps": [-1]}],
          sequences=[pt.arange(M.shape[0])],
          non_sequences=[M],
          allow_gc=False,
          mode="FAST_RUN",
      )
  
      # In this case, `debugprint` should print the compiled inner-graph
      # (i.e. from `Scan._fn`)
      out = pytensor.function(
          [M], out, updates=updates, mode="FAST_RUN"
      )
  
      expected_output = """Scan{scan_fn, while_loop=False, inplace=all} [id A] 2 (outer_out_sit_sot-0)
       ├─ 20000 [id B] (n_steps)
       ├─ [    0 ... 998 19999] [id C] (outer_in_seqs-0)
       ├─ SetSubtensor{:stop} [id D] 1 (outer_in_sit_sot-0)
       │  ├─ AllocEmpty{dtype='int64'} [id E] 0
       │  │  └─ 20000 [id B]
       │  ├─ [0] [id F]
       │  └─ 1 [id G]
       └─ <Tensor3(float64, shape=(20000, 2, 2))> [id H] (outer_in_non_seqs-0)
  
      Inner graphs:
  
      Scan{scan_fn, while_loop=False, inplace=all} [id A]
       ← Composite{switch(lt(i0, i1), i2, i0)} [id I] (inner_out_sit_sot-0)
          ├─ 0 [id J]
          ├─ Subtensor{i, j, k} [id K]
          │  ├─ *2-<Tensor3(float64, shape=(20000, 2, 2))> [id L] -> [id H] (inner_in_non_seqs-0)
          │  ├─ ScalarFromTensor [id M]
          │  │  └─ *0-<Scalar(int64, shape=())> [id N] -> [id C] (inner_in_seqs-0)
          │  ├─ ScalarFromTensor [id O]
          │  │  └─ *1-<Scalar(int64, shape=())> [id P] -> [id D] (inner_in_sit_sot-0)
          │  └─ 0 [id Q]
          └─ 1 [id R]
  
      Composite{switch(lt(i0, i1), i2, i0)} [id I]
       ← Switch [id S] 'o0'
          ├─ LT [id T]
          │  ├─ i0 [id U]
          │  └─ i1 [id V]
          ├─ i2 [id W]
          └─ i0 [id U]
      """
  
      output_str = debugprint(out, file="str", print_op_info=True)
      lines = output_str.split("\n")
  
      for truth, out in zip(expected_output.split("\n"), lines):
          assert truth.strip() == out.strip()
  
file_path: pytensor/tests/scan/test_printing.py
imports: import numpy
  import pytest
  import pytensor
  import pytensor.tensor
  from pytensor.configdefaults import config
  from pytensor.graph.fg import FunctionGraph
  from pytensor.printing import debugprint, pydot_imported, pydotprint
  from pytensor.tensor.type import dvector, iscalar, scalar, vector
label_desc: Use image node_id 7 for calling a global function with example usage: test_debugprint_compiled_fn() and returns: pt