import collections


def count_by_key_impl(sequence):
    """
    Implementation for count_by_key_t
    :param sequence: sequence of (key, value) pairs
    :return: counts by key
    """
    counter = collections.Counter()
    for key, _ in sequence:
        counter[key] += 1
    return counter.items()