code: def pooling_3d(
      x,
      mode,
      kernel,
      stride,
      pad,
      ignore_border=True,
      including_pad=True,
      dtype=np.float32,
  ):
      """ """
      assert mode in ["average", "sum", "max"]
  
      C, Z, H, W = x.shape
      Zo = get_pool_out_size(
          Z, kernel[0], pad[0], stride[0], ignore_border
      )
      Ho = get_pool_out_size(
          H, kernel[1], pad[1], stride[1], ignore_border
      )
      Wo = get_pool_out_size(
          W, kernel[2], pad[2], stride[2], ignore_border
      )
      Zi = Z + pad[0] + (pad[0] if ignore_border else kernel[0] - 1)
      Hi = H + pad[1] + (pad[1] if ignore_border else kernel[1] - 1)
      Wi = W + pad[2] + (pad[2] if ignore_border else kernel[2] - 1)
  
      x_pad = np.ones((C, Zi, Hi, Wi), dtype=dtype)
      x_pad *= x.min() if mode == "max" else 0
      x_pad[
          :,
          pad[0] : pad[0] + Z,
          pad[1] : pad[1] + H,
          pad[2] : pad[2] + W,
      ] = x
  
      if mode == "average":
          b_pad = np.zeros((C, Zi, Hi, Wi), dtype=np.uint)
          z_beg = int(not including_pad) * pad[0]
          h_beg = int(not including_pad) * pad[1]
          w_beg = int(not including_pad) * pad[2]
          z_end = Z + (1 + int(including_pad)) * pad[0]
          h_end = H + (1 + int(including_pad)) * pad[1]
          w_end = W + (1 + int(including_pad)) * pad[2]
          b_pad[:, z_beg:z_end, h_beg:h_end, w_beg:w_end] = 1
          # b_pad[:, pad[0]:pad[0] + Z, pad[1]:pad[1] + H, pad[2]:pad[2] + W] = 1
  
      y = np.zeros((C, Zo, Ho, Wo), dtype=dtype)
  
      for c in range(C):
          for zo in range(Zo):
              for ho in range(Ho):
                  for wo in range(Wo):
                      zi = zo * stride[0] + np.arange(0, kernel[0])
                      hi = ho * stride[1] + np.arange(0, kernel[1])
                      wi = wo * stride[2] + np.arange(0, kernel[2])
                      yy = y[c]
                      xx = x_pad[c]
                      if mode == "max":
                          yy[zo, ho, wo] = xx[np.ix_(zi, hi, wi)].max()
                      elif mode == "sum":
                          yy[zo, ho, wo] = xx[np.ix_(zi, hi, wi)].sum()
                      elif mode == "average":
                          pool_sum = xx[np.ix_(zi, hi, wi)].sum()
                          pool_cnt = b_pad[c][np.ix_(zi, hi, wi)].sum()
                          yy[zo, ho, wo] = pool_sum / pool_cnt
      return y
  
imports: from __future__ import division
  from six.moves import range
  import itertools
  import numpy
label_desc: Use image node_id 11 for calling a global function with example usage: pooling_3d(x, mode, kernel, stride, pad, ignore_border, including_pad, dtype) and returns: y