Plot a heatmap for a topic-word distribution `topic_word_distrib` to a matplotlib Figure `fig` and Axes `ax`
    using `vocab` as vocabulary on the x-axis and topics from 1 to `n_topics=doc_topic_distrib.shape[1]` on
    the y-axis.
    A subset of words from `vocab` can be specified either directly with a sequence `which_words` or
    `which_document_indices` containing a sequence of word indices in `vocab`.
    A subset of topics can be specified either with a sequence `which_topics` containing sequence of numbers between
    [1, n_topics] or `which_topic_indices` which is a number between [0, n_topics-1]
    Additional arguments can be passed via `kwargs` to `plot_heatmap`.

    Please note that it is almost always necessary to select a subset of your topic-word distribution with the
    `which_words` or `which_topics` parameters, as otherwise the amount of data to be plotted will be too high
    to give a reasonable picture.

def plot_topic_word_heatmap(fig, ax, topic_word_distrib, vocab,
                            which_topics=None, which_topic_indices=None,
                            which_words=None, which_word_indices=None,
                            xaxislabel=None, yaxislabel=None,
                            **kwargs):
    """
    Plot a heatmap for a topic-word distribution `topic_word_distrib` to a matplotlib Figure `fig` and Axes `ax`
    using `vocab` as vocabulary on the x-axis and topics from 1 to `n_topics=doc_topic_distrib.shape[1]` on
    the y-axis.
    A subset of words from `vocab` can be specified either directly with a sequence `which_words` or
    `which_document_indices` containing a sequence of word indices in `vocab`.
    A subset of topics can be specified either with a sequence `which_topics` containing sequence of numbers between
    [1, n_topics] or `which_topic_indices` which is a number between [0, n_topics-1]
    Additional arguments can be passed via `kwargs` to `plot_heatmap`.

    Please note that it is almost always necessary to select a subset of your topic-word distribution with the
    `which_words` or `which_topics` parameters, as otherwise the amount of data to be plotted will be too high
    to give a reasonable picture.
    """
    if which_topics is not None and which_topic_indices is not None:
        raise ValueError('only `which_topics` or `which_topic_indices` can be set, not both')

    if which_words is not None and which_word_indices is not None:
        raise ValueError('only `which_words` or `which_word_indices` can be set, not both')

    if which_topics is not None:
        which_topic_indices = np.array(which_topics) - 1

    if which_words is not None:
        which_word_indices = np.where(np.isin(vocab, which_words))[0]

    select_distrib_subset = False
    topic_labels = np.array(range(1, topic_word_distrib.shape[0]+1))

    if which_topic_indices is not None:
        select_distrib_subset = True
        topic_labels = topic_labels[which_topic_indices]

    if which_word_indices is not None:
        select_distrib_subset = True
        vocab = np.array(vocab)[which_word_indices]

    if select_distrib_subset:
        topic_word_distrib = mat2d_window_from_indices(topic_word_distrib, which_topic_indices, which_word_indices)

    return plot_heatmap(fig, ax, topic_word_distrib,
                        xaxislabel=xaxislabel or 'vocab',
                        yaxislabel=yaxislabel or 'topic',
                        xticklabels=vocab,
                        yticklabels=topic_labels,
                        **kwargs)