<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def safe_args(fn, args):
 """Check if ``args`` as a dictionary has the required parameters of ``fn`` function and filter any waste parameters so ``fn`` can be safely called with them. :param fn: function object :type fn: Callable :param args: dictionary of parameters :type args: dict :return: dictionary to be used as named params for the ``fn`` :rtype: dict """

    fn_args = inspect.getargspec(fn)

    if fn_args.defaults:
        required_params(args, fn_args.args[:-len(fn_args.defaults)])
    else:
        required_params(args, fn_args)

    if not fn_args.keywords:
        return {key: value for key, value in viewitems(args) if key in fn_args.args}
    else:
        return args