code: def test_scan_debugprint3():
      coefficients = theano.tensor.dvector("coefficients")
      max_coefficients_supported = 10
  
      k = tensor.iscalar("k")
      A = tensor.dvector("A")
  
      # compute A**k
      def compute_A_k(A, k):
          # Symbolic description of the result
          result, updates = theano.scan(
              fn=lambda prior_result, A: prior_result * A,
              outputs_info=tensor.ones_like(A),
              non_sequences=A,
              n_steps=k,
          )
  
          A_k = result[-1]
  
          return A_k
  
      # Generate the components of the polynomial
      components, updates = theano.scan(
          fn=lambda coefficient, power, some_A, some_k: coefficient
          * (compute_A_k(some_A, some_k) ** power),
          outputs_info=None,
          sequences=[
              coefficients,
              theano.tensor.arange(max_coefficients_supported),
          ],
          non_sequences=[A, k],
      )
      # Sum them up
      polynomial = components.sum()
  
      final_result = polynomial
  
      output_str = theano.printing.debugprint(final_result, file="str")
      lines = output_str.split("\n")
  
      expected_output = """Sum{acc_dtype=float64} [id A] ''
       |for{cpu,scan_fn} [id B] ''
         |Elemwise{minimum,no_inplace} [id C] ''
         | |Subtensor{int64} [id D] ''
         | | |Shape [id E] ''
         | | | |Subtensor{int64::} [id F] 'coefficients[0:]'
         | | |   |coefficients [id G]
         | | |   |Constant{0} [id H]
         | | |Constant{0} [id I]
         | |Subtensor{int64} [id J] ''
         |   |Shape [id K] ''
         |   | |Subtensor{int64::} [id L] ''
         |   |   |ARange{dtype='int64'} [id M] ''
         |   |   | |TensorConstant{0} [id N]
         |   |   | |TensorConstant{10} [id O]
         |   |   | |TensorConstant{1} [id P]
         |   |   |Constant{0} [id Q]
         |   |Constant{0} [id R]
         |Subtensor{:int64:} [id S] ''
         | |Subtensor{int64::} [id F] 'coefficients[0:]'
         | |ScalarFromTensor [id T] ''
         |   |Elemwise{minimum,no_inplace} [id C] ''
         |Subtensor{:int64:} [id U] ''
         | |Subtensor{int64::} [id L] ''
         | |ScalarFromTensor [id V] ''
         |   |Elemwise{minimum,no_inplace} [id C] ''
         |Elemwise{minimum,no_inplace} [id C] ''
         |A [id W]
         |k [id X]
  
      Inner graphs of the scan ops:
  
      for{cpu,scan_fn} [id B] ''
       >Elemwise{mul,no_inplace} [id Y] ''
       > |InplaceDimShuffle{x} [id Z] ''
       > | |coefficients[t] [id BA] -> [id S]
       > |Elemwise{pow,no_inplace} [id BB] ''
       >   |Subtensor{int64} [id BC] ''
       >   | |Subtensor{int64::} [id BD] ''
       >   | | |for{cpu,scan_fn} [id BE] ''
       >   | | | |k_copy [id BF] -> [id X]
       >   | | | |IncSubtensor{Set;:int64:} [id BG] ''
       >   | | | | |AllocEmpty{dtype='float64'} [id BH] ''
       >   | | | | | |Elemwise{add,no_inplace} [id BI] ''
       >   | | | | | | |k_copy [id BF] -> [id X]
       >   | | | | | | |Subtensor{int64} [id BJ] ''
       >   | | | | | |   |Shape [id BK] ''
       >   | | | | | |   | |Rebroadcast{0} [id BL] ''
       >   | | | | | |   |   |InplaceDimShuffle{x,0} [id BM] ''
       >   | | | | | |   |     |Elemwise{second,no_inplace} [id BN] ''
       >   | | | | | |   |       |A_copy [id BO] -> [id W]
       >   | | | | | |   |       |InplaceDimShuffle{x} [id BP] ''
       >   | | | | | |   |         |TensorConstant{1.0} [id BQ]
       >   | | | | | |   |Constant{0} [id BR]
       >   | | | | | |Subtensor{int64} [id BS] ''
       >   | | | | |   |Shape [id BT] ''
       >   | | | | |   | |Rebroadcast{0} [id BL] ''
       >   | | | | |   |Constant{1} [id BU]
       >   | | | | |Rebroadcast{0} [id BL] ''
       >   | | | | |ScalarFromTensor [id BV] ''
       >   | | | |   |Subtensor{int64} [id BJ] ''
       >   | | | |A_copy [id BO] -> [id W]
       >   | | |Constant{1} [id BW]
       >   | |Constant{-1} [id BX]
       >   |InplaceDimShuffle{x} [id BY] ''
       >     |<TensorType(int64, scalar)> [id BZ] -> [id U]
  
      for{cpu,scan_fn} [id BE] ''
       >Elemwise{mul,no_inplace} [id CA] ''
       > |<TensorType(float64, vector)> [id CB] -> [id BG]
       > |A_copy [id CC] -> [id BO]"""
  
      for truth, out in zip(expected_output.split("\n"), lines):
          assert truth.strip() == out.strip()
  
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 9 for calling a global function with example usage: test_scan_debugprint3() and returns: A_k