def _merge_kwargs(system, kwargs):
    """
    Return a copy of `system` with any passed `kwargs` updated in the
    dictionary---this can be used to overwrite or to add new arguments.
    """
    out = system.kwargs.copy()
    out.update(kwargs)
    return system._replace(kwargs=out)