code: def is_img_id_valid(img_id):
      
      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
docs: Checks if img_id is valid.