human
Complete this python program:
def get_group_index(labels, shape, sort, xnull):
assistant
#Here is the Python code you requested.

    """For the particular label_list, gets the offsets into the hypothetical list
    representing the totally ordered cartesian product of all possible label
    combinations, *as long as* this space fits within int64 bounds;
    otherwise, though group indices identify unique combinations of
    labels, they cannot be deconstructed.
    - If `sort`, rank of returned ids preserve lexical ranks of labels.
    i.e. returned id\s can be used to do lexical sort on labels;
    - If `xnull` nulls (-1 labels) are passed through.
    Parameters
    labels: sequence of arrays
    Integers identifying levels at each location
    shape: sequence of ints same length as labels
    Number of unique levels at each location
    sort: boolean
    If the ranks of returned ids should match lexical ranks of labels
    xnull: boolean
    If true nulls are excluded. i.e. -1 values in the labels are
    passed through
    Returns
    An array of type int64 where two elements are equal if their corresponding
    labels are equal at all location.
    """
    def _int64_cut_off(shape):
        acc = long(1)
        for (i, mul) in enumerate(shape):
            acc *= long(mul)
            if (not (acc < _INT64_MAX)):
                return i
        return len(shape)
    def loop(labels, shape):
        nlev = _int64_cut_off(shape)
        stride = np.prod(shape[1:nlev], dtype='i8')
        out = (stride * labels[0].astype('i8', subok=False, copy=False))
        for i in range(1, nlev):
            if (shape[i] == 0):
                stride = 0
            else:
                stride //= shape[i]
            out += (labels[i] * stride)
        if xnull:
            mask = (labels[0] == (-1))
            for lab in labels[1:nlev]:
                mask |= (lab == (-1))
            out[mask] = (-1)
        if (nlev == len(shape)):
            return out
        (comp_ids, obs_ids) = compress_group_index(out, sort=sort)
        labels = ([comp_ids] + labels[nlev:])
        shape = ([len(obs_ids)] + shape[nlev:])
        return loop(labels, shape)
    def maybe_lift(lab, size):
        return (((lab + 1), (size + 1)) if (lab == (-1)).any() else (lab, size))
    labels = map(_ensure_int64, labels)
    if (not xnull):
        (labels, shape) = map(list, zip(*map(maybe_lift, labels, shape)))
    return loop(list(labels), list(shape))