from collections import defaultdict


def remove_infrequent(texts, n_times) :
    """
    remove words that appear fewer than n_times.
    """
    frequency = defaultdict(int)
    for text in texts:
        for token in text:
            frequency[token] += 1
            
    texts = [[token for token in text if frequency[token] > n_times]
             for text in texts]
    return texts