from typing import Counter


def document_frequency(bags_of_features):
    """
    Find all the distinct features in many bags of features,
    and how often each occurs (in how many bags each occurs)
    :param bags_of_features: iterable of Counters
    :return: Counter mapping features to their document frequencies
    """
    freq = Counter()
    for bag in bags_of_features:
        freq.update(bag.keys())
    return freq