def _get_top_words_for_topic(fitted_model, topic_index, vocabulary, n_top_words=None):
    """
    For a given LDA model (trained) and a topic index, return the N most important
    words for that topic.

    :param model: topic model such as sklearn.decomposition.LatentDirichletAllocation
    :param topic_index: 0-indexed integer
    :param vocabulary: list of words in the vocabulary (e.g. call get_feature_names() on a trained
        sklearn.feature_extraction.text.CountVectorizer)
    :param n_top_words: number of words to return. by default, return all
    :return: list of the top words
    """

    topic = fitted_model.components_[topic_index]

    if n_top_words is not None:
        words = [vocabulary[i] for i in topic.argsort()[:-n_top_words - 1:-1]]
    else:
        words = [vocabulary[i] for i in topic.argsort()]

    return words