B
    лd                 @   sx   d Z ddlZddlZddlmZ ddlmZ ddlmZ dd Zdd	 Z	d
d Z
dd Zdd Zdd Zdadd ZdS )z"Utility to retrieve function args.    N)
config_pb2)tf_decorator)
tf_inspectc             C   s"   t | \}} t| o | jd k	S )N)r   unwrapr   ismethod__self__)fn_ r
   W/var/www/html/venv/lib/python3.7/site-packages/tensorflow/python/util/function_utils.py_is_bound_method   s    r   c             C   s   t | dot| jS )N__call__)hasattrr   r   r   )objr
   r
   r   _is_callable_object   s    r   c                sp   t  tjr8t j} fdd|t jd D }n0t rF j t	
 j}t rh|rh|d t|S )a  Get argument names for function-like object.

  Args:
    fn: Function, or function-like object (e.g., result of `functools.partial`).

  Returns:
    `tuple` of string argument names.

  Raises:
    ValueError: if partial function has positionally bound arguments
  c                s   g | ]}| j pg kr|qS r
   )keywords).0a)r   r
   r   
<listcomp>1   s    zfn_args.<locals>.<listcomp>Nr   )
isinstance	functoolspartialfn_argsfunclenargsr   r   r   getfullargspecr   poptuple)r   r   r
   )r   r   r   #   s    
"
r   c             C   sV   t | tjr| j} n2t| r$| j} n"t| sFtd|  dt|  dt	
| jdk	S )a-  Returns whether the passed callable has **kwargs in its signature.

  Args:
    fn: Function, or function-like object (e.g., result of `functools.partial`).

  Returns:
    `bool`: if `fn` has **kwargs in its signature.

  Raises:
     `TypeError`: If fn is not a Function, or function-like object.
  z1Argument `fn` should be a callable. Received: fn=z
 (of type )N)r   r   r   r   r   r   callable	TypeErrortyper   r   varkw)r   r
   r
   r   
has_kwargs>   s    r$   c             C   sz   t | \}} t| r\t| r&| jS t| rNdt| j	jt
| jf S tt| S ntd|  dt|  ddS )z Returns name of passed callable.z%s.%sz2Argument `func` must be a callable. Received func=z
 (of type r   N)r   r   r    r   
isfunction__name__r   sixget_method_self	__class__get_method_functionstrr"   
ValueError)r   r	   r
   r
   r   get_func_nameU   s    

r-   c             C   sv   t | \}} t| rXt| s*t| r4t| S yt| jS  t	k
rT   dS X nt
d|  dt|  ddS )z?Returns func_code of passed callable, or None if not available.Nz2Argument `func` must be a callable. Received func=z
 (of type r   )r   r   r    r   r%   r   r'   get_function_coder   AttributeErrorr,   r"   )r   r	   r
   r
   r   get_func_codef   s    
r0   c              C   s*   t d kr&t } | jj}d|_|  a t S )NT)#_rewriter_config_optimizer_disabledr   ConfigProtograph_optionsrewrite_optionsdisable_meta_optimizerSerializeToString)configZrewriter_configr
   r
   r   get_disabled_rewriter_config}   s    r8   )__doc__r   r'   tensorflow.core.protobufr   tensorflow.python.utilr   r   r   r   r   r$   r-   r0   r1   r8   r
   r
   r
   r   <module>   s   