<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def query_associations(self, subjects=None, infer_subjects=True, include_xrefs=True):
 """ Query for a set of associations. Note: only a minimal association model is stored, so all results are returned as (subject_id,class_id) tuples Arguments: subjects: list list of subjects (e.g. genes, diseases) used to query associations. Any association to one of these subjects or a descendant of these subjects (assuming infer_subjects=True) are returned. infer_subjects: boolean (default true) See above include_xrefs: boolean (default true) If true, then expand inferred subject set to include all xrefs of those subjects. Example: if a high level disease node (e.g. DOID:14330 Parkinson disease) is specified, then the default behavior (infer_subjects=True, include_xrefs=True) and the ontology includes DO, results will include associations from both descendant DOID classes, and all xrefs (e.g. OMIM) """

        if subjects is None:
            subjects = []
        mset = set()
        if infer_subjects:
            for subj in subjects:
                mset.update(self.ontology.descendants(subj))
        mset.update(set(subjects))
        if include_xrefs:
            xset = set()
            for m in mset:
                xrefs = self.ontology.xrefs(m, bidirectional=True)
                if xrefs is not None:
                    xset.update(xrefs)
            mset.update(xset)
        logging.debug("Matching subjects: {}".format(mset))
        mset = mset.intersection(self.subjects)
        logging.debug("Matching subjects with anns: {}".format(mset))
        amap = self.association_map
        results = []
        for m in mset:
            if m in amap:
                for t in amap[m]:
                    results.append( (m,t) )
        return results