<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def cleaned_date(day, keep_datetime=False):
 """ Return a "clean" date type. * keep a `date` unchanged * convert a datetime into a date, * convert any "duck date" type into a date using its `date()` method. """

    if not isinstance(day, (date, datetime)):
        raise UnsupportedDateType(
            "`{}` is of unsupported type ({})".format(day, type(day)))
    if not keep_datetime:
        if hasattr(day, 'date') and callable(day.date):
            day = day.date()
    return day