<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def remove_old_tmp_files(profiles=None, max_lifetime=(7 * 24)):
 """ Removes old temp files that is older than expiration_hours. If profiles is None then will be use all profiles. """

    assert isinstance(profiles, (list, tuple)) or profiles is None
    if profiles is None:
        profiles = dju_settings.DJU_IMG_UPLOAD_PROFILES.keys()
    profiles = set(('default',) + tuple(profiles))
    total = removed = 0
    old_dt = datetime.datetime.utcnow() - datetime.timedelta(hours=max_lifetime)
    for profile in profiles:
        conf = get_profile_configs(profile=profile)
        root_path = os.path.join(settings.MEDIA_ROOT, dju_settings.DJU_IMG_UPLOAD_SUBDIR, conf['PATH'])
        for file_path in get_files_recursive(root_path):
            m = re_tmp.match(os.path.basename(file_path))
            if m is None:
                continue
            total += 1
            fdt = dtstr_to_datetime(m.group('dtstr'))
            if fdt and old_dt > fdt:
                os.remove(file_path)
                removed += 1
    return removed, total