def compress_group_index(group_index, sort=True):
size_hint = min(len(group_index), hashtable._SIZE_HINT_LIMIT)<EOL>table = hashtable.Int64HashTable(size_hint)<EOL>group_index = ensure_int64(group_index)<EOL>comp_ids, obs_group_ids = table.get_labels_groupby(group_index)<EOL>if sort and len(obs_group_ids) > <NUM_LIT:0>:<EOL><INDENT>obs_group_ids, comp_ids = _reorder_by_uniques(obs_group_ids, comp_ids)<EOL><DEDENT>return comp_ids, obs_group_ids<EOL>
Group_index is offsets into cartesian product of all possible labels. This
space can be huge, so this function compresses it, by computing offsets
(comp_ids) into the list of unique labels (obs_group_ids).