from typing import Sequence
from typing import Counter
from functools import reduce


def _merge_token_counters(token_counters: Sequence[Counter]) -> Counter:
    """
    A private helper function for combining multiple dictionaries of the shape token_frequency
    into a single token_frequency.

    :param token_counters: a list of the shape [{str: int, ...}, ...]
    :return: a dictionary of the same shape as the above, with all key: value pairs merged.

    >>> test_1 = Counter({'good': 1, 'bad': 1, 'ugly': 1})
    >>> test_2 = Counter({'good': 3, 'bad': 0, 'weird': 2})
    >>> test_3 = Counter({'good': 2, 'bad': 4, 'weird': 0, 'ugly': 2})
    >>> merged_token_frequency = _merge_token_counters([test_1, test_2, test_3])
    >>> merged_token_frequency
    Counter({'good': 6, 'bad': 5, 'ugly': 3, 'weird': 2})
    """

    return reduce(lambda token_counter, total: token_counter + total, token_counters)