code: public static long lengthPerSlice(INDArray arr, int... dimension) {
          long[] remove = ArrayUtil.removeIndex(arr.shape(), dimension);
          return ArrayUtil.prodLong(remove);
      }
docs: The number of elements in a slice
  along a set of dimensions
  @param arr the array
  to calculate the length per slice for
  @param dimension the dimensions to do the calculations along
  @return the number of elements in a slice along
  arbitrary dimensions