code: def labeled_accumulate(sequence, keygetter=operator.itemgetter(0), valuegetter=operator.itemgetter(1), accumulator=operator.add):
      
      return izip((keygetter(item) for item in sequence),
                  accumulate((valuegetter(item) for item in sequence), accumulator))
docs: Accumulates input elements according to accumulate(), but keeping certain data (per element, from the original
        sequence/iterable) in the target elements, like behaving as keys or legends.
      :param sequence:
      :param keygetter:
      :param valuegetter:
      :return: