code: def test_maxpool(self):
      # generate flatted images
      maxpoolshps = ((2, 2), (3, 3), (4, 4), (5, 5), (6, 6))
      imval = np.random.rand(4, 5, 10, 10)
  
      images = tensor.dmatrix()
      for maxpoolshp in maxpoolshps:
          # symbolic stuff
          output, outshp = sp.max_pool(
              images, imval.shape[1:], maxpoolshp
          )
          f = function(
              [
                  images,
              ],
              [
                  output,
              ],
          )
          output_val = f(imval.reshape(imval.shape[0], -1))
  
          # numeric verification
          my_output_val = np.zeros(
              (
                  imval.shape[0],
                  imval.shape[1],
                  imval.shape[2] // maxpoolshp[0],
                  imval.shape[3] // maxpoolshp[1],
              )
          )
          assert np.prod(my_output_val.shape[1:]) == np.prod(
              np.r_[imval.shape[1], outshp]
          )
  
          for n in range(imval.shape[0]):
              for k in range(imval.shape[1]):
                  for i in range(imval.shape[2] // maxpoolshp[0]):
                      for j in range(imval.shape[3] // maxpoolshp[1]):
                          ii, jj = i * maxpoolshp[0], j * maxpoolshp[1]
                          patch = imval[
                              n,
                              k,
                              ii : ii + maxpoolshp[0],
                              jj : jj + maxpoolshp[1],
                          ]
                          my_output_val[n, k, i, j] = np.max(patch)
          my_output_val = my_output_val.reshape(imval.shape[0], -1)
          assert np.all(output_val == my_output_val)
  
          def mp(input):
              output, outshp = sp.max_pool(
                  input, imval.shape[1:], maxpoolshp
              )
              return output
  
          utt.verify_grad(mp, [imval.reshape(imval.shape[0], -1)])
  
imports: from __future__ import absolute_import, print_function, division
  from nose.plugins.skip import SkipTest
  import sys
  import time
  import unittest
  import theano.sparse
  import scipy.sparse
  from scipy.signal import convolve2d
  import scipy.sparse
  import numpy
  from six.moves import xrange
  from theano import function, tensor
  import theano
  from theano.compat import next
  from theano.sparse.sandbox import sp
  from theano.sparse.tests.test_basic import random_lil
  from theano.tests import unittest_tools
  from theano.sparse.tests.test_basic import sparse_random_inputs
  from theano.tests.unittest_tools import attr
label_desc: Use image node_id 3 for calling the TestSP obj's underlying member method code with example usage: obj.test_maxpool() and returns: output