code: def test_multilayer_conv(self):
      # fixed parameters
      bsize = 10  # batch size
      imshp = (5, 5)
      kshp = ((3, 3), (2, 2))
      nkerns = (3, 6)  # per output pixel
      ssizes = (((1, 1), (2, 2)),)
      convmodes = ("full",)  # 'valid',)
  
      # symbolic stuff
      kerns = [dmatrix(), dmatrix()]
      input = dmatrix()
  
      # build actual input images
      img2d = np.arange(bsize * np.prod(imshp)).reshape(
          (bsize,) + imshp
      )
      img1d = img2d.reshape(bsize, -1)
  
      for mode in ("FAST_COMPILE", "FAST_RUN"):
          for conv_mode in convmodes:
              for ss in ssizes:
                  l1hid, l1shp = sp.convolve(
                      kerns[0],
                      kshp[0],
                      nkerns[0],
                      input,
                      imshp,
                      ss[0],
                      mode=conv_mode,
                  )
                  l1propup = function(
                      [kerns[0], input], l1hid, mode=mode
                  )
  
                  l1kernvals = np.arange(
                      nkerns[0] * np.prod(kshp[0])
                  ).reshape(nkerns[0], np.prod(kshp[0]))
                  l1hidval = l1propup(l1kernvals, img1d)
  
                  # actual values
                  l2hid, l2shp = sp.convolve(
                      kerns[1],
                      kshp[1],
                      nkerns[1],
                      l1hid,
                      l1shp,
                      ss[1],
                      mode=conv_mode,
                  )
                  l2propup = function(
                      [kerns[1], l1hid], l2hid, mode=mode
                  )
  
                  l2kernvals = np.arange(
                      nkerns[1] * np.prod(kshp[1]) * nkerns[0]
                  ).reshape(nkerns[1], np.prod(kshp[1]) * nkerns[0])
                  # for debugging, we bring things back to integers
                  l1hidval = np.arange(np.size(l1hidval)).reshape(
                      l1hidval.shape
                  )
  
                  l2propup(l2kernvals, l1hidval)
  
file_path: pytensor/tests/sparse/sandbox/test_sp.py
imports: import time
  import pytest
  import numpy
  from scipy.signal import convolve2d
  from pytensor import function
  from pytensor.sparse.sandbox import sp
  from pytensor.tensor.type import dmatrix, dvector
  from tests import unittest_tools
label_desc: Use image node_id 2 for calling the TestSP obj's underlying member method code with example usage: obj.test_multilayer_conv() without return types