def METHOD_NAME(pairs, collection_id):
    left = aliased(EntitySetItem)
    right = aliased(EntitySetItem)
    q = db.session.query(left, right)
    q = q.filter(left.deleted_at == None, right.deleted_at == None)  # noqa
    q = q.filter(EntitySet.collection_id == collection_id)
    q = q.filter(EntitySet.type == EntitySet.PROFILE)
    q = q.filter(EntitySet.id == left.entityset_id)
    q = q.filter(EntitySet.id == right.entityset_id)
    q = q.filter(
        or_(left.judgement == Judgement.POSITIVE, right.judgement == Judgement.POSITIVE)
    )
    q = q.filter(db.tuple_(left.entity_id, right.entity_id).in_(pairs))
    judgements = {}
    for left, right in pairs:
        judgements[(left, right)] = Judgement.NO_JUDGEMENT
        judgements[(right, left)] = Judgement.NO_JUDGEMENT
    for left, right in q.all():
        judgement = left.judgement + right.judgement
        judgements[(left.entity_id, right.entity_id)] = judgement
        judgements[(right.entity_id, left.entity_id)] = judgement
    return judgements