human
Complete this python program:
def classify_saves(saves, period_start):
assistant
#Here is the Python program you requested.

    """For each (utc, id) in saves, yield (True, (utc, id)) if the save
    should be kept and (False, (utc, id)) if the save should be removed.
    The ids are binary hashes.
    """
    def retain_newest_in_region(region):
        for save in region[0:1]:
            (yield (True, save))
        for save in region[1:]:
            (yield (False, save))
    (matches, rest) = partition((lambda s: (s[0] >= period_start['all'])), saves)
    for save in matches:
        (yield (True, save))
    tm_ranges = ((period_start['dailies'], (lambda s: localtime(s[0]).tm_yday)), (period_start['monthlies'], (lambda s: localtime(s[0]).tm_mon)), (period_start['yearlies'], (lambda s: localtime(s[0]).tm_year)))
    for (pstart, time_region_id) in tm_ranges:
        (matches, rest) = partition((lambda s: (s[0] >= pstart)), rest)
        for (region_id, region_saves) in groupby(matches, time_region_id):
            for action in retain_newest_in_region(list(region_saves)):
                (yield action)
    for save in rest:
        (yield (False, save))