code: def invoke_with(fn, *args, **kwargs):
      """
      Call `fn(*args, **kwargs)`, but only use kwargs that `fn` actually uses.
      """
  
      # if `fn` has `**kwargs` argument, we can just call it directly
      if inspect.getfullargspec(fn).varkw is not None:
          return fn(*args, **kwargs)
  
      sig = inspect.signature(fn)
  
      kwargs = keyfilter(sig.parameters.__contains__, kwargs)
  
      arguments = sig.bind(*args, **kwargs).arguments
      return fn(**arguments)
  
file_path: gluonts/src/gluonts/shell/util.py
imports: import inspect
  import pydoc
  from typing import Type, Union, cast
  from toolz import keyfilter
  from gluonts.model.estimator import Estimator
  from gluonts.model.predictor import Predictor
  from .exceptions import ForecasterNotFound
label_desc: Use image node_id 2 for calling a global function with example usage: invoke_with(fn) and returns: fn, fn