code: def ref_pooling(
      inp, inp_shape, fshape, padding, strides, be, ncheck=None
  ):
      # given input tensor return the expected polling output for
      # certain batches
      inp_lshape = list(inp_shape)
      bsz = inp.shape[-1]
      if ncheck is None:
          check_inds = np.arange(bsz)
      elif type(ncheck) is int:
          check_inds = np.random.permutation(bsz)
          check_inds = check_inds[0:ncheck]
      else:
          check_inds = ncheck
      check_inds = np.sort(check_inds)
  
      inp_lshape.append(bsz)
      inpa = inp.get().reshape(inp_lshape)
      outshape = (
          inp_lshape[0],
          be.output_dim(
              inp_lshape[1],
              fshape[0],
              padding,
              strides[0],
              pooling=True,
          ),
          be.output_dim(
              inp_lshape[2],
              fshape[1],
              padding,
              strides[1],
              pooling=True,
          ),
          len(check_inds),
      )
  
      if padding > 0:
          padded_shape = (
              inp_lshape[0],
              inp_lshape[1] + 2 * padding,
              inp_lshape[2] + 2 * padding,
              inp_lshape[-1],
          )
          inp_pad = np.zeros(padded_shape)
          inp_pad[:, padding:-padding, padding:-padding, :] = inpa[
              :, 0:, 0:, :
          ]
      else:
          inp_pad = inpa
  
      out_exp = np.zeros(outshape)
      for indC in range(outshape[0]):
          for indh in range(outshape[1]):
              hrng = (indh * strides[0], indh * strides[0] + fshape[0])
              for indw in range(outshape[2]):
                  wrng = (
                      indw * strides[1],
                      indw * strides[1] + fshape[1],
                  )
                  for cnt, indb in enumerate(check_inds):
                      inp_check = inp_pad[
                          indC,
                          hrng[0] : hrng[1],
                          wrng[0] : wrng[1],
                          indb,
                      ]
                      out_exp[indC, indh, indw, cnt] = np.max(inp_check)
      return (out_exp, check_inds)
  
file_path: neon/tests/test_pool_layer.py
imports: import itertools
  import numpy
  from neon import NervanaObject
  from neon.layers.layer import Pooling
  from utils import allclose_with_out
label_desc: Use image node_id 2 for calling a global function with example usage: ref_pooling(inp, inp_shape, fshape, padding, strides, be, ncheck) and returns: out_exp,  check_inds