def unravel_index(i, shape, order='C'):
    """Rewrite of np.unravel_index that allows shape to have more than 32
    dimensions.

    numpy arrays cannot be of dimension larger than 32. to avoid issues and
    unecessary dependencies we just cut out numpy entirely
    """
    cumulative_sizes = []
    j = 1
    for size in shape[::-1]:
        j *= int(size)
        cumulative_sizes.append(j)
    if cumulative_sizes[-1] <= i:
        raise ValueError('Requested index outside of range.')
    cumulative_sizes = cumulative_sizes[::-1]
    indexes = []
    j = i
    for size in cumulative_sizes[1:]:
        indexes.append(j // size)
        j = j % size
    indexes.append(j)
    if order == 'C':
        pass
    elif order == 'F':
        indexes = indexes[::-1]
    else:
        raise ValueError('Expected "C" or "F" for "order" kwarg.')
    return indexes
