code: private static int[] getStrides(int[] dims) {
          int rightmost = dims.length - 1;
          int[] strides = new int[dims.length];
          if (dims.length > 0) {          
              strides[rightmost] = 1;
              for (int i=rightmost-1; i >= 0; i--) {
                  strides[i] = dims[i+1]*strides[i+1];
              }
          }
          return strides;
      }
docs: Gets the strides for the given dimensions. The stride for dimension i
  (stride[i]) denotes the step forward in values array necessary to
  increase the index for that dimension by 1.