parameters: (func)
docstring: Extracts signature information from a function or functools.partial object.
  
    For functions, uses `tf_inspect.getargspec`. For `functools.partial` objects,
    corrects the signature of the underlying function to take into account the
    removed arguments.
  
    Args:
      func: A function whose signature to extract.
  
    Returns:
      An `ArgSpec` namedtuple `(args, varargs, keywords, defaults)`, as returned
      by `tf_inspect.getargspec`.
docstring_summary: Extracts signature information from a function or functools.partial object.
docstring_tokens: Extracts signature information from a function or functools . partial object .
function: def _get_arg_spec(func):
    """Extracts signature information from a function or functools.partial object.
  
    For functions, uses `tf_inspect.getargspec`. For `functools.partial` objects,
    corrects the signature of the underlying function to take into account the
    removed arguments.
  
    Args:
      func: A function whose signature to extract.
  
    Returns:
      An `ArgSpec` namedtuple `(args, varargs, keywords, defaults)`, as returned
      by `tf_inspect.getargspec`.
    """
    # getargspec does not work for functools.partial objects directly.
    if isinstance(func, functools.partial):
      argspec = tf_inspect.getargspec(func.func)
      # Remove the args from the original function that have been used up.
      first_default_arg = (
          len(argspec.args or []) - len(argspec.defaults or []))
      partial_args = len(func.args)
      argspec_args = []
  
      if argspec.args:
        argspec_args = list(argspec.args[partial_args:])
  
      argspec_defaults = list(argspec.defaults or ())
      if argspec.defaults and partial_args > first_default_arg:
        argspec_defaults = list(argspec.defaults[partial_args-first_default_arg:])
  
      first_default_arg = max(0, first_default_arg - partial_args)
      for kwarg in (func.keywords or []):
        if kwarg in (argspec.args or []):
          i = argspec_args.index(kwarg)
          argspec_args.pop(i)
          if i >= first_default_arg:
            argspec_defaults.pop(i-first_default_arg)
          else:
            first_default_arg -= 1
      return tf_inspect.ArgSpec(args=argspec_args,
                                varargs=argspec.varargs,
                                keywords=argspec.keywords,
                                defaults=tuple(argspec_defaults))
    else:  # Regular function or method, getargspec will work fine.
      return tf_inspect.getargspec(func)
function_tokens: def _get_arg_spec ( func ) : # getargspec does not work for functools.partial objects directly. if isinstance ( func , functools . partial ) : argspec = tf_inspect . getargspec ( func . func ) # Remove the args from the original function that have been used up. first_default_arg = ( len ( argspec . args or [ ] ) - len ( argspec . defaults or [ ] ) ) partial_args = len ( func . args ) argspec_args = [ ] if argspec . args : argspec_args = list ( argspec . args [ partial_args : ] ) argspec_defaults = list ( argspec . defaults or ( ) ) if argspec . defaults and partial_args > first_default_arg : argspec_defaults = list ( argspec . defaults [ partial_args - first_default_arg : ] ) first_default_arg = max ( 0 , first_default_arg - partial_args ) for kwarg in ( func . keywords or [ ] ) : if kwarg in ( argspec . args or [ ] ) : i = argspec_args . index ( kwarg ) argspec_args . pop ( i ) if i >= first_default_arg : argspec_defaults . pop ( i - first_default_arg ) else : first_default_arg -= 1 return tf_inspect . ArgSpec ( args = argspec_args , varargs = argspec . varargs , keywords = argspec . keywords , defaults = tuple ( argspec_defaults ) ) else : # Regular function or method, getargspec will work fine. return tf_inspect . getargspec ( func )