nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/convolution/Convolution.java
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)
                        .sx(sx)
                        .sy(sy)
                        .virtualHeight(virtualHeight)
                        .virtualWidth(virtualWidth)
                        .type(type)
                        .divisor(divisor)
                        .build())
                .build();
        Nd4j.getExecutioner().exec(pooling);
        return out;
    }
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)
                        .sx(sx)
                        .sy(sy)
                        .virtualHeight(virtualHeight)
                        .virtualWidth(virtualWidth)
                        .type(type)
                        .divisor(divisor)
                        .build())
                .build();
        Nd4j.getExecutioner().exec(pooling);
        return out;
    }
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