(
        self,
        doc_topic_matrix: np.ndarray,
        *,
        topics: int | Sequence[int] = -1,
        top_n: int = 10,
        weights: bool = False,
    )
Get the top ``top_n`` docs by weight per topic in ``doc_topic_matrix``.

        Args:
            doc_topic_matrix: Document-topic matrix with shape (n_docs, n_topics),
                the result of calling :meth:`TopicModel.get_doc_topic_matrix()`
            topics: Topic(s) for which to return top docs;
                if -1, all topics' docs are returned.
            top_n: Number of top docs to return per topic.
            weights: If True, docs are returned with their corresponding (normalized)
                topic weights; otherwise, docs are returned without weights.

        Yields:
            Next tuple corresponding to a topic; the first element is the topic's
            index; if ``weights`` is False, the second element is a tuple of ints
            representing the top ``top_n`` related docs; otherwise, the second
            is a tuple of (int, float) pairs representing the top ``top_n``
            related docs and their associated weights wrt the topic; for example::

                >>> list(TopicModel.top_doc_terms(dtm, topics=(0, 1), top_n=2, weights=False))
                [(0, (4, 2)), (1, (1, 3))]
                >>> list(TopicModel.top_doc_terms(dtm, topics=0, top_n=2, weights=True))
                [(0, ((4, 0.3217), (2, 0.2154)))]
Get the top ``top_n`` docs by weight per topic in ``doc_topic_matrix``.
Get the top top_n docs by weight per topic in doc_topic_matrix .
def top_topic_docs(
        self,
        doc_topic_matrix: np.ndarray,
        *,
        topics: int | Sequence[int] = -1,
        top_n: int = 10,
        weights: bool = False,
    ) -> Iterable[Tuple[int, Tuple[int, ...]]] | Iterable[
        Tuple[int, Tuple[Tuple[int, float], ...]]
    ]:
        """
        Get the top ``top_n`` docs by weight per topic in ``doc_topic_matrix``.

        Args:
            doc_topic_matrix: Document-topic matrix with shape (n_docs, n_topics),
                the result of calling :meth:`TopicModel.get_doc_topic_matrix()`
            topics: Topic(s) for which to return top docs;
                if -1, all topics' docs are returned.
            top_n: Number of top docs to return per topic.
            weights: If True, docs are returned with their corresponding (normalized)
                topic weights; otherwise, docs are returned without weights.

        Yields:
            Next tuple corresponding to a topic; the first element is the topic's
            index; if ``weights`` is False, the second element is a tuple of ints
            representing the top ``top_n`` related docs; otherwise, the second
            is a tuple of (int, float) pairs representing the top ``top_n``
            related docs and their associated weights wrt the topic; for example::

                >>> list(TopicModel.top_doc_terms(dtm, topics=(0, 1), top_n=2, weights=False))
                [(0, (4, 2)), (1, (1, 3))]
                >>> list(TopicModel.top_doc_terms(dtm, topics=0, top_n=2, weights=True))
                [(0, ((4, 0.3217), (2, 0.2154)))]
        """
        if topics == -1:
            topics = range(self.n_topics)
        elif isinstance(topics, int):
            topics = (topics,)

        for topic_idx in topics:
            top_doc_idxs = np.argsort(doc_topic_matrix[:, topic_idx])[: -top_n - 1 : -1]
            if weights is False:
                yield (topic_idx, tuple(doc_idx for doc_idx in top_doc_idxs))
            else:
                yield (
                    topic_idx,
                    tuple(
                        (doc_idx, doc_topic_matrix[doc_idx, topic_idx])
                        for doc_idx in top_doc_idxs
                    ),
                )
def top_topic_docs ( self , doc_topic_matrix : np . ndarray , * , topics : int | Sequence [ int ] = - 1 , top_n : int = 10 , weights : bool = False , ) -> Iterable [ Tuple [ int , Tuple [ int , ... ] ] ] | Iterable [ Tuple [ int , Tuple [ Tuple [ int , float ] , ... ] ] ] : if topics == - 1 : topics = range ( self . n_topics ) elif isinstance ( topics , int ) : topics = ( topics , ) for topic_idx in topics : top_doc_idxs = np . argsort ( doc_topic_matrix [ : , topic_idx ] ) [ : - top_n - 1 : - 1 ] if weights is False : yield ( topic_idx , tuple ( doc_idx for doc_idx in top_doc_idxs ) ) else : yield ( topic_idx , tuple ( ( doc_idx , doc_topic_matrix [ doc_idx , topic_idx ] ) for doc_idx in top_doc_idxs ) , )