(
        self,
        doc_topic_matrix: np.ndarray,
        *,
        docs: int | Sequence[int] = -1,
        top_n: int = 3,
        weights: bool = False,
    )
Get the top ``top_n`` topics by weight per doc for ``docs`` 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()` .
            docs: Docs for which to return top topics;
                if -1, all docs' top topics are returned.
            top_n: Number of top topics to return per doc.
            weights If True, docs are returned with their corresponding (normalized)
                topic weights; otherwise, docs are returned without weights.

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

                >>> list(TopicModel.top_doc_topics(dtm, docs=(0, 1), top_n=2, weights=False))
                [(0, (1, 4)), (1, (3, 2))]
                >>> list(TopicModel.top_doc_topics(dtm, docs=0, top_n=2, weights=True))
                [(0, ((1, 0.2855), (4, 0.2412)))]
Get the top ``top_n`` topics by weight per doc for ``docs`` in ``doc_topic_matrix``.
Get the top top_n topics by weight per doc for docs in doc_topic_matrix .
def top_doc_topics(
        self,
        doc_topic_matrix: np.ndarray,
        *,
        docs: int | Sequence[int] = -1,
        top_n: int = 3,
        weights: bool = False,
    ) -> Iterable[Tuple[int, Tuple[int, ...]]] | Iterable[
        Tuple[int, Tuple[Tuple[int, float], ...]]
    ]:
        """
        Get the top ``top_n`` topics by weight per doc for ``docs`` 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()` .
            docs: Docs for which to return top topics;
                if -1, all docs' top topics are returned.
            top_n: Number of top topics to return per doc.
            weights If True, docs are returned with their corresponding (normalized)
                topic weights; otherwise, docs are returned without weights.

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

                >>> list(TopicModel.top_doc_topics(dtm, docs=(0, 1), top_n=2, weights=False))
                [(0, (1, 4)), (1, (3, 2))]
                >>> list(TopicModel.top_doc_topics(dtm, docs=0, top_n=2, weights=True))
                [(0, ((1, 0.2855), (4, 0.2412)))]
        """
        if docs == -1:
            docs = range(doc_topic_matrix.shape[0])
        elif isinstance(docs, int):
            docs = (docs,)

        for doc_idx in docs:
            top_topic_idxs = np.argsort(doc_topic_matrix[doc_idx, :])[: -top_n - 1 : -1]
            if weights is False:
                yield (doc_idx, tuple(topic_idx for topic_idx in top_topic_idxs))
            else:
                yield (
                    doc_idx,
                    tuple(
                        (topic_idx, doc_topic_matrix[doc_idx, topic_idx])
                        for topic_idx in top_topic_idxs
                    ),
                )
def top_doc_topics ( self , doc_topic_matrix : np . ndarray , * , docs : int | Sequence [ int ] = - 1 , top_n : int = 3 , weights : bool = False , ) -> Iterable [ Tuple [ int , Tuple [ int , ... ] ] ] | Iterable [ Tuple [ int , Tuple [ Tuple [ int , float ] , ... ] ] ] : if docs == - 1 : docs = range ( doc_topic_matrix . shape [ 0 ] ) elif isinstance ( docs , int ) : docs = ( docs , ) for doc_idx in docs : top_topic_idxs = np . argsort ( doc_topic_matrix [ doc_idx , : ] ) [ : - top_n - 1 : - 1 ] if weights is False : yield ( doc_idx , tuple ( topic_idx for topic_idx in top_topic_idxs ) ) else : yield ( doc_idx , tuple ( ( topic_idx , doc_topic_matrix [ doc_idx , topic_idx ] ) for topic_idx in top_topic_idxs ) , )