def group_clients(clients, num_groups):
    """Collect clients of each group into a list.
    Args:
        clients: List of all client objects.
        num_groups: Number of groups.
    Returns:
        groups: List of clients in each group.
    """
    groups = [[] for _ in range(num_groups)]
    for c in clients:
        groups[c.group].append(c)
    return groups