code: def test_pooling(self):
      x_shape = [2, 1, 3, 3]
      x = singa_wrap.Tensor(x_shape)
      x.CopyFloatDataFromHostPtr(
          [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]
      )
  
      y_shape = [2, 1, 2, 2]
      dy = singa_wrap.Tensor(y_shape)
      dy.CopyFloatDataFromHostPtr(
          [0.1, 0.2, 0.3, 0.4, 0.1, 0.2, 0.3, 0.4]
      )
  
      k_dim = [2, 2]
      s_dim = [1, 1]
      p_dim = [0, 0]
  
      # max pooling
      handle = singa_wrap.PoolingHandle(x, k_dim, s_dim, p_dim, True)
      y = singa_wrap.CpuPoolingForward(handle, x)
      self.assertListEqual([2, 1, 2, 2], list(y.shape()))
      dx = singa_wrap.CpuPoolingBackward(handle, dy, x, y)
      self.assertListEqual([2, 1, 3, 3], list(dx.shape()))
  
      # avg pooling
      handle = singa_wrap.PoolingHandle(x, k_dim, s_dim, p_dim, False)
      y = singa_wrap.CpuPoolingForward(handle, x)
      self.assertListEqual([2, 1, 2, 2], list(y.shape()))
      dx = singa_wrap.CpuPoolingBackward(handle, dy, x, y)
      self.assertListEqual([2, 1, 3, 3], list(dx.shape()))
  
imports: import unittest
  from singa import singa_wrap
label_desc: Use image node_id 2 for calling the TestPythonOperation obj's underlying member method code with example usage: obj.test_pooling() without return types