code: def get_mentions(self, docs=None, sort=False):
          result = []
          if docs:
              docs = docs if isinstance(docs, (list, tuple)) else [docs]
              for mention_class in self.mention_classes:
                  mentions = (
                      self.session.query(mention_class)
                      .filter(mention_class.document_id.in_([doc.id for doc in docs]))
                      .order_by(mention_class.id)
                      .all()
                  )
                  if sort:
                      mentions = sorted(mentions, key=lambda x: x[0].get_stable_id())
                  result.append(mentions)
          else:
              for mention_class in self.mention_classes:
                  mentions = (
                      self.session.query(mention_class).order_by(mention_class.id).all()
                  )
                  if sort:
                      mentions = sorted(mentions, key=lambda x: x[0].get_stable_id())
                  result.append(mentions)
          return result