'This method will reset reference counts for aliases so that they match
the value passed in :param to_counts:.'

def reset_refcounts(self, to_counts):

    for (alias, cur_refcount) in self.alias_refcount.copy().items():
        unref_amount = (cur_refcount - to_counts.get(alias, 0))
        self.unref_alias(alias, unref_amount)
