def determine_global_offset(index, global_shape):
    """ Determine global offset of specified index based on shape of global
    array.  The result is conceptually equivalent to the offset(in data items)
    of the element at the specified index if it was one contiguous vector of
    elements.

    Parameters
    ----------
    index : list of ints
        Global indices.
    global_shape: list, tuple
        Shape of distributed array.

    Returns
    -------
    global_offset: int
        Offset in number of elements from start of global array.
    """
    if not isinstance(index, list): raise TypeError("index must be a list")
    if len(index) != len(global_shape):
        raise ValueError(
            "number of elements in index and global shape must be equal")

    if len(global_shape) == 1:
        global_offset = index[0]
    else:
        strides = [1]
        for i, stride in enumerate(global_shape[1:]):
            strides.append(strides[i] * stride)

        index.reverse()
        global_offset = 0
        for dim, num in enumerate(index):
            global_offset += num * strides[dim]

    return int(global_offset)