def assert_and_retrieve_kwarg(kwargs, arg_name):
    """Retrieve an argument from kwargs.
    
    Args:
        kwargs (dict): Keyword arguments.
        arg_name (str): Name of argument which should exist.
    Returns:
        value: The value associated with the keyword argument.
    """
    try:
        value = kwargs[arg_name]
    except KeyError:
        raise AttributeError(f'{arg_name} must be a named argument.')
    return value