code: def run_numpy_pool(op, cpuI, cpuE, dytpe, be_layer):
      # pass in the backend layer for the parameters
  
      dimI = be_layer.dimI
      dimO = be_layer.dimO
      op = be_layer.op
      K = be_layer.K
      N = be_layer.N
      M, P, Q = be_layer.MPQ
      pad_j, pad_d, pad_h, pad_w = be_layer.padding
      str_j, str_d, str_h, str_w = be_layer.strides
  
      # cpu output arrays
      cpuO = np.empty(dimO, dtype=dytpe)
      cpuB = np.zeros(sliceable(dimI, 1), dtype=dytpe)
  
      for i in range(repeat):
          cpuB.fill(0)
          for k in range(K):
              kj = k * str_j - pad_j
  
              for m in range(M):
                  mt = m * str_d - pad_d
  
                  for p in range(P):
                      pr = p * str_h - pad_h
  
                      for q in range(Q):
                          qs = q * str_w - pad_w
  
                          idx = pixel_indices(be_layer, kj, mt, pr, qs)
  
                          if op == "max":
                              cpuO[k, m, p, q, :] = np.max(
                                  cpuI[idx, :], axis=0
                              )
                              b_idx = np.argmax(cpuI[idx, :], axis=0)
                              for n in range(N):
                                  cpuB[idx[b_idx[n]], n] += cpuE[
                                      k, m, p, q, n
                                  ]
                          elif op == "avg":
                              cpuO[k, m, p, q, :] = np.mean(
                                  cpuI[idx, :], axis=0
                              )
                              cpuB[idx, :] += cpuE[k, m, p, q, :] * (
                                  1.0 / len(idx)
                              )
                          elif op == "l2":
                              cpuO[k, m, p, q, :] = np.sqrt(
                                  np.sum(cpuI[idx, :] ** 2, axis=0)
                              )
  
      return cpuO, cpuB
  
file_path: neon/tests/test_backend_pool_layer.py
imports: import itertools
  import numpy
  import pytest
  from neon import logger
  from utils import allclose_with_out
label_desc: Use image node_id 4 for calling a global function with example usage: run_numpy_pool(op, cpuI, cpuE, dytpe, be_layer) and returns: cpuO,  cpuB