o
    ?e                     @   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 uS )N)r   unwrapr   ismethod__self__)fn_ r
   f/home/www/facesmatcher.com/pyenv/lib/python3.10/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                    sv   t  tjrt j} fdd|t jd D }t|S t r& j t	
 j}t r7|r7|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 v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} nt| r| j} nt| s#td|  dt|  dt	
| jdu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=
 (of type )N)r   r   r   r   r   r   callable	TypeErrortyper   r   varkwr   r
   r
   r   
has_kwargs>   s   r&   c                 C   st   t | \}} t| r-t| r| jS t| r'dt| j	jt
| jf S tt| S td|  dt|  d)z Returns name of passed callable.z%s.%s2Argument `func` must be a callable. Received func=r    r!   )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    


r1   c                 C   sr   t | \}} t| r,t| st| rt| S zt| jW S  t	y+   Y dS w t
d|  dt|  d)z?Returns func_code of passed callable, or None if not available.Nr'   r    r!   )r   r   r"   r   r(   r   r*   get_function_coder   AttributeErrorr/   r$   r0   r
   r
   r   get_func_codef   s    
r4   c                  C   s*   t d u rt } | jj}d|_|  a t S )NT)#_rewriter_config_optimizer_disabledr   ZConfigProtoZgraph_optionsZrewrite_optionsZdisable_meta_optimizerZSerializeToString)configZrewriter_configr
   r
   r   get_disabled_rewriter_config}   s   r7   )__doc__r   r*   Ztensorflow.core.protobufr   Ztensorflow.python.utilr   r   r   r   r   r&   r1   r4   r5   r7   r
   r
   r
   r   <module>   s   