def _extract_kwds(kwds: dict, **defaults) -> dict:
    """Take keys in defaults and pop from kwds, return as a dict"""
    extracted = {}
    for key, value in defaults.items():
        extracted[key] = kwds.pop(key, value)
    return extracted