def get_candidates(self, docs=None, split=<NUM_LIT:0>, sort=False):
result = []<EOL>if docs:<EOL><INDENT>docs = docs if isinstance(docs, (list, tuple)) else [docs]<EOL>for candidate_class in self.candidate_classes:<EOL><INDENT>cands = (<EOL>self.session.query(candidate_class)<EOL>.filter(candidate_class.document_id.in_([doc.id for doc in docs]))<EOL>.order_by(candidate_class.id)<EOL>.all()<EOL>)<EOL>if sort:<EOL><INDENT>cands = sorted(<EOL>cands,<EOL>key=lambda x: "<STR_LIT:U+0020>".join(<EOL>[x[i][<NUM_LIT:0>].get_stable_id() for i in range(len(x))]<EOL>),<EOL>)<EOL><DEDENT>result.append(cands)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for candidate_class in self.candidate_classes:<EOL><INDENT>sub_query = (<EOL>self.session.query(Candidate.id)<EOL>.filter(Candidate.split == split)<EOL>.subquery()<EOL>)<EOL>cands = (<EOL>self.session.query(candidate_class)<EOL>.filter(candidate_class.id.in_(sub_query))<EOL>.order_by(candidate_class.id)<EOL>.all()<EOL>)<EOL>if sort:<EOL><INDENT>cands = sorted(<EOL>cands,<EOL>key=lambda x: "<STR_LIT:U+0020>".join(<EOL>[x[i][<NUM_LIT:0>].get_stable_id() for i in range(len(x))]<EOL>),<EOL>)<EOL><DEDENT>result.append(cands)<EOL><DEDENT><DEDENT>return result<EOL>
Return a list of lists of the candidates associated with this extractor.

        Each list of the return will contain the candidates for one of the
        candidate classes associated with the CandidateExtractor.

        :param docs: If provided, return candidates from these documents from
            all splits.
        :type docs: list, tuple of ``Documents``.
        :param split: If docs is None, then return all the candidates from this
            split.
        :type split: int
        :param sort: If sort is True, then return all candidates sorted by stable_id.
        :type sort: bool
        :return: Candidates for each candidate_class.
        :rtype: List of lists of ``Candidates``.