code: public static INDArray pooling2D(INDArray img, int kh, int kw, int sy, int sx, int ph, int pw,
                                       int dh, int dw, boolean isSameMode, Pooling2D.Pooling2DType type, Pooling2D.Divisor divisor,
                                       double extra, int virtualHeight, int virtualWidth, INDArray out) {
          Pooling2D pooling = Pooling2D.builder()
                  .arrayInputs(new INDArray[]{img})
                  .arrayOutputs(new INDArray[]{out})
                  .config(Pooling2DConfig.builder()
                          .dH(dh)
                          .dW(dw)
                          .extra(extra)
                          .kH(kh)
                          .kW(kw)
                          .pH(ph)
                          .pW(pw)
                          .isSameMode(isSameMode)
                          .sH(sy)
                          .sW(sx)
                          .virtualHeight(virtualHeight)
                          .virtualWidth(virtualWidth)
                          .type(type)
                          .divisor(divisor)
                          .build())
                  .build();
          Nd4j.getExecutioner().execAndReturn(pooling);
          return out;
      }
docs: Pooling 2d implementation
  
  @param img
  @param kh
  @param kw
  @param sy
  @param sx
  @param ph
  @param pw
  @param dh
  @param dw
  @param isSameMode
  @param type
  @param extra         optional argument. I.e. used in pnorm pooling.
  @param virtualHeight
  @param virtualWidth
  @param out
  @return