def get_average_doc(corpus, dim):
    """
    Calculates the mean document vector in the corpus of dimensionality dim
    :param corpus: list of sparse documents
    :return: avg document dense vector
    """
    n_docs = len(corpus)
    avg_z = [0 for _ in range(dim)]
    for doc in corpus:
        for topic in doc:
            avg_z[topic[0]] += topic[1]
    avg_z = [i/n_docs for i in avg_z]

    return avg_z