o
    2h                     @   sp   d 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
   `/var/www/html/chatgem/venv/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>/   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   sl   t | \}} t| r)t| r| jS t| r#d| jjj| j	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   r   	__class____func__strr$   
ValueErrorr   r	   r
   r
   r   get_func_nameS   s"   

r/   c                 C   sj   t | \}} t| r(t| st| r| jS z| j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   __code__r   AttributeErrorr-   r$   r.   r
   r
   r   get_func_codef   s    
r2   c                  C   s*   t d u rt } | jj}d|_|  a t S )NT)#_rewriter_config_optimizer_disabledr   ConfigProtograph_optionsrewrite_optionsdisable_meta_optimizerSerializeToString)configrewriter_configr
   r
   r   get_disabled_rewriter_config}   s   r;   )__doc__r   tensorflow.core.protobufr   tensorflow.python.utilr   r   r   r   r   r&   r/   r2   r3   r;   r
   r
   r
   r   <module>   s   