def count_words(tokens, n_words = 20):
    """
    Count the number of comments containing each entry

    Parameters
    ----------
    tokens: list
        a nested list containing lists of tokens or a list of spacy docs
    n: int
        The number of words to return. Defaults to 20, i.e. the top 20 words

    Returns
    -------
    word_freq(most_common(n)): a list of tuples
        a list of tuples containing words and frequencies

    """

    # Flatten list and set to lower case
    bag_of_words = [word.lower() for comment in tokens for word in comment]
    unique_words = set(bag_of_words)

    word_counts = []

    for word in unique_words:
        n = 0
        for doc in tokens:
            if word in doc:
                n += 1
        word_counts.append((word, n))

    word_counts.sort(key = lambda x: x[1], reverse = True)

    return word_counts[0:n_words]