def get_lda_topics(lda, top_n=30):
    """Wrapper function to extract topics from trained tomotopy LDA model (adapted from
        @ecoronado's get_hdp_topics() method)

    ** Inputs **
    lda:obj -> LDAModel trained model
    top_n: int -> top n words in topic based on frequencies

    ** Returns **
    topics: dict -> per topic, an array with top words and associated frequencies
    """

    # Get most important topics by # of times they were assigned (i.e. counts)
    sorted_topics = [k for k, v in sorted(enumerate(lda.get_count_by_topics()), key=lambda x: x[1], reverse=True)]

    topics = dict()

    # For topics found, extract only those that are still assigned
    for k in sorted_topics:
        topic_wp = []
        for word, prob in lda.get_topic_words(k, top_n=top_n):
            topic_wp.append((word, prob))

        topics[k] = topic_wp  # store topic word/frequency array

    return topics