def METHOD_NAME(self, order):
    num_kgrams_with_count = Counter(
        value for value in order.values() if value <= 4)
    discounts = self._calc_discounts(num_kgrams_with_count)
    prefix_sums = defaultdict(int)
    backoffs = defaultdict(int)
    for key in order.keys():
        prefix = key[:-1]
        count = order[key]
        prefix_sums[prefix] += count
        discount = self._get_discount(discounts, count)
        order[key] -= discount
        backoffs[prefix] += discount
    for key in order.keys():
        prefix = key[:-1]
        order[key] = math.log(order[key]/prefix_sums[prefix])
    for prefix in backoffs.keys():
        backoffs[prefix] = math.log(backoffs[prefix]/prefix_sums[prefix])
    return backoffs