nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/factory/BaseNDArrayFactory.java
protected static void validateConcat(int dimension, INDArray... arrs) {
        if (arrs[0].isScalar()) {
            for (int i = 1; i < arrs.length; i++)
                if (!arrs[i].isScalar())
                    throw new IllegalArgumentException("All arrays must have same dimensions");
        } else {
            int dims = arrs[0].shape().length;
            long[] shape = ArrayUtil.removeIndex(arrs[0].shape(), dimension);
            for (int i = 1; i < arrs.length; i++) {
                assert Arrays.equals(shape, ArrayUtil.removeIndex(arrs[i].shape(), dimension));
                assert arrs[i].shape().length == dims;
            }
        }


    }
protected static void validateConcat(int dimension, INDArray... arrs) {
        if (arrs[0].isScalar()) {
            for (int i = 1; i < arrs.length; i++)
                if (!arrs[i].isScalar())
                    throw new IllegalArgumentException("All arrays must have same dimensions");
        } else {
            int dims = arrs[0].shape().length;
            long[] shape = ArrayUtil.removeIndex(arrs[0].shape(), dimension);
            for (int i = 1; i < arrs.length; i++) {
                assert Arrays.equals(shape, ArrayUtil.removeIndex(arrs[i].shape(), dimension));
                assert arrs[i].shape().length == dims;
            }
        }


    }
input arrays must have same number of dimensions