<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def is_img_id_valid(img_id):
 """ Checks if img_id is valid. """

    t = re.sub(r'[^a-z0-9_:\-\.]', '', img_id, re.IGNORECASE)
    t = re.sub(r'\.+', '.', t)
    if img_id != t or img_id.count(':') != 1:
        return False
    profile, base_name = img_id.split(':', 1)
    if not profile or not base_name:
        return False
    try:
        get_profile_configs(profile)
    except ValueError:
        return False
    return True