public static final long[] computeIndexOffsets(int[] sizes) {
    long[] indexOffsets = new long[sizes.length];
    for (int i = sizes.length - 1; i >= 0; i--) {
      if (i == sizes.length - 1) {
        indexOffsets[i] = 1;
      } else {
        indexOffsets[i] = indexOffsets[i + 1] * ((long) sizes[i + 1]);
      }
    }
    return indexOffsets;
  }
public static final long [ ] computeIndexOffsets ( int [ ] sizes ) { long [ ] indexOffsets = new long [ sizes . length ] ; for ( int i = sizes . length - 1 ; i >= 0 ; i -- ) { if ( i == sizes . length - 1 ) { indexOffsets [ i ] = 1 ; } else { indexOffsets [ i ] = indexOffsets [ i + 1 ] * ( ( long ) sizes [ i + 1 ] ) ; } } return indexOffsets ; }
Computes an array of index offsets (multipliers) from a set of
dimension sizes. The returned array is used to convert int[]
tensor keys to longs (and vice versa).

@param sizes