code: def apply_kwargs(func, **kwargs):
      
      new_kwargs = {}
      params = signature(func).parameters
      for param_name in params.keys():
          if param_name in kwargs:
              new_kwargs[param_name] = kwargs[param_name]
      return func(**new_kwargs)
docs: Call *func* with kwargs, but only those kwargs that it accepts.