<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_fn_args(fn, kwargs: dict, prefix: str = None):
 """ Given function and a dict of kwargs return a dict containing only the args used by the function. If prefix is specified, also search for args that begin with '{prefix}__'. Removes prefix in returned dict. Raises ValueError if a required arg is missing from the kwargs. Raises ValueError if both prefixed and unprefixed arg are given in kwargs. {'a': 1, 'b': 2} {'a': 1, 'b': 2, 'd': 4} Traceback (most recent call last):
 ValueError: The following args are missing for the function bar: ['d'] """

    all_args = get_all_args(fn)
    required_args = get_required_args(fn)
    fn_kwargs = pick_kwargs(kwargs, all_args, prefix)

    missing_args = [arg for arg in required_args if arg not in fn_kwargs]
    if missing_args:
        raise ValueError(
            'The following args are missing for the function '
            '{}: {}.'.format(fn.__name__, missing_args)
        )

    return fn_kwargs