code: def call_function_with_redundant_kwargs(fn, kwargs):
      """Calls a function and returns the results.
  
      Only those keyword arguments in :attr:`kwargs` that are included in the
      function's argument list are used to call the function.
  
      Args:
          fn (function): A callable. If :attr:`fn` is not a python function,
              :attr:`fn.__call__` is called.
          kwargs (dict): A `dict` of arguments for the callable. It
              may include invalid arguments which will be ignored.
  
      Returns:
          The returned results by calling :attr:`fn`.
      """
      try:
          fn_args = set(get_args(fn))
      except TypeError:
          fn_args = set(get_args(fn.__cal__))
  
      if kwargs is None:
          kwargs = {}
  
      # Select valid arguments
      selected_kwargs = {}
      for key, value in kwargs.items():
          if key in fn_args:
              selected_kwargs[key] = value
  
      return fn(**selected_kwargs)
  
imports: from typing import List, Union
  import inspect
  import funcsigs
  from pydoc import locate
  import copy
  import collections
  import numpy
  import tensorflow
  from texar.tf.hyperparams import HParams
  from texar.tf.utils.dtypes import is_str, is_callable, compat_as_text, _maybe_list_to_array
label_desc: Use image node_id 12 for calling a global function with example usage: call_function_with_redundant_kwargs(fn, kwargs) and returns: fn