@Override
    public INDArray average(INDArray target, INDArray[] arrays) {
        if (arrays == null || arrays.length == 0)
            throw new RuntimeException("Input arrays are missing");

        if (arrays.length == 1) {
            //Edge case - average 1 array - no op
            if(target == null){
                return null;
            }
            return target.assign(arrays[0]);
        }

        long len = target != null ? target.lengthLong() : arrays[0].length();

        PointerPointer dataPointers = new PointerPointer(arrays.length);
        val firstType = arrays[0].dataType();

        for (int i = 0; i < arrays.length; i++) {
            Nd4j.getCompressor().autoDecompress(arrays[i]);

            Preconditions.checkArgument(arrays[i].dataType() == firstType, "All arrays must have the same data type");

            if (arrays[i].elementWiseStride() != 1)
                throw new ND4JIllegalStateException("Native averaging is applicable only to continuous INDArrays");

            if (arrays[i].lengthLong() != len)
                throw new ND4JIllegalStateException("All arrays should have equal length for averaging");

            dataPointers.put(i, arrays[i].data().addressPointer());
        }


        nativeOps.average(null,
                dataPointers, (LongPointer) arrays[0].shapeInfoDataBuffer().addressPointer(),
                null, null,
                target == null ? null : target.data().addressPointer(), target == null ? null : (LongPointer) target.shapeInfoDataBuffer().addressPointer(),
                null, null,
                arrays.length,
                    len,
                true);

        return target;
    }
@ Override public INDArray average ( INDArray target , INDArray [ ] arrays ) { if ( arrays == null || arrays . length == 0 ) throw new RuntimeException ( "Input arrays are missing" ) ; if ( arrays . length == 1 ) { if ( target == null ) { return null ; } return target . assign ( arrays [ 0 ] ) ; } long len = target != null ? target . lengthLong ( ) : arrays [ 0 ] . length ( ) ; PointerPointer dataPointers = new PointerPointer ( arrays . length ) ; val firstType = arrays [ 0 ] . dataType ( ) ; for ( int i = 0 ; i < arrays . length ; i ++ ) { Nd4j . getCompressor ( ) . autoDecompress ( arrays [ i ] ) ; Preconditions . checkArgument ( arrays [ i ] . dataType ( ) == firstType , "All arrays must have the same data type" ) ; if ( arrays [ i ] . elementWiseStride ( ) != 1 ) throw new ND4JIllegalStateException ( "Native averaging is applicable only to continuous INDArrays" ) ; if ( arrays [ i ] . lengthLong ( ) != len ) throw new ND4JIllegalStateException ( "All arrays should have equal length for averaging" ) ; dataPointers . put ( i , arrays [ i ] . data ( ) . addressPointer ( ) ) ; } nativeOps . average ( null , dataPointers , ( LongPointer ) arrays [ 0 ] . shapeInfoDataBuffer ( ) . addressPointer ( ) , null , null , target == null ? null : target . data ( ) . addressPointer ( ) , target == null ? null : ( LongPointer ) target . shapeInfoDataBuffer ( ) . addressPointer ( ) , null , null , arrays . length , len , true ) ; return target ; }
This method averages input arrays, and returns averaged array

@param target
@param arrays
@return