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

    picked = {k: v for k, v in kwargs.items() if k in required_args}

    prefixed = {}
    if prefix:
        prefix = prefix + '__'
        prefixed = {
            _remove_prefix(k, prefix): v
            for k, v in kwargs.items()
            if k.startswith(prefix)
            and _remove_prefix(k, prefix) in required_args
        }

    conflicting_args = [k for k in picked if k in prefixed]
    if conflicting_args:
        raise ValueError(
            'Both prefixed and unprefixed args were specified '
            'for the following parameters: {}'.format(conflicting_args)
        )

    return tz.merge(picked, prefixed)