qid_intents = {qid: list(intents) for qid, intents
                in groupby(intentsets, key=lambda x: x.qid)}