code: public static int mapIndexOntoTensor(int index, INDArray arr, int... rank) {
          int ret = index * ArrayUtil.prod(ArrayUtil.removeIndex(arr.shape(), rank));
          return ret;
      }
docs: This maps an index of a vector
  on to a vector in the matrix that can be used
  for indexing in to a tensor
  @param index the index to map
  @param arr the array to use
  for indexing
  @param rank the dimensions to compute a slice for
  @return the mapped index