o
    ?e                     @   s   d Z ddlZddl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l
mZ ddlmZ ddlmZ e Zd	d
 Zdd Zdd Z	dddZdd Zdd ZdS )z6Core conversion logic, serves as main point of access.    N)config)cache)inspect_utils)
ag_logging)tf_method_target)
tf_inspectc                    s>   t j|d }|d u rdS t fdd|j D rdS dS )NFc                 3   s     | ]} |u r|d uV  qd S N ).0vfr	   l/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/tensorflow/python/autograph/impl/conversion.py	<genexpr>%   s    z-_is_of_known_loaded_module.<locals>.<genexpr>T)sysmodulesgetany__dict__values)r   module_namemodr	   r   r   _is_of_known_loaded_module!   s   r   c                 C   sZ   |t jvstt j| |sdS tt j| |}t| |rdS t| r+t| j|r+dS dS )zDTests whether the function or method is an instance of a known type.FT)r   r   hasattrgetattr
isinstanceinspectismethod__func__)r   r   entity_nameZtype_entityr	   r	   r   _is_known_loaded_type*   s   


	r    c                    s   t  ddst  ddrtd  tdd  dS t  dd	r,tdd
  dS t r:tdd  dS t fdddD rNtdd  dS t drbt j	drbtdd  dS dS )z:Checks whether an entity is supported by AutoGraph at all.ZwraptZFunctionWrapperZBoundFunctionWrapperz{} appears to be decorated by wrapt, which is not yet supported by AutoGraph. The function will run as-is. You may still apply AutoGraph before the wrapt decorator.   z(Permanently allowed: %s: wrapt decoratedT	functools_lru_cache_wrapperz"Permanently allowed: %s: lru_cachez$Permanently allowed: %s: constructorc                 3   s    | ]}t  |V  qd S r   )r   )r
   mor	   r   r   _   s
    
z!is_unsupported.<locals>.<genexpr>)collectionspdbcopyr   rez/Permanently allowed: %s: part of builtin module
__module__Z_IS_TENSORFLOW_PLUGINz*Permanently allowed: %s: TensorFlow pluginF)
r    loggingwarningformatlogr   Zisconstructorr   r   r+   r%   r	   r%   r   is_unsupportedE   s4   



r0   TFc                 C   s  t | tjr	t}nt| }t|dr@tjD ])}||}|tj	j
kr.tdd| |  dS |tj	jkr?tdd| |  dS qt| drSt| rStdd|  dS |rvt| svt| d	rvt| t| jkrvt| jrvtdd
|  dS d}t| rt| }|tju r| jj}|durt|tjrtdd|  dS t| |}t|dddrtdd| | dS t| r|rtdd | j D stdd|  dS n	tdd|  dS tdd|  dS )a  Checks whether an entity is allowed for use in graph mode.

  Examples of allowed entities include all members of the tensorflow
  package.

  Args:
    o: A Python entity.
    check_call_override: Reserved for internal use. When set to `False`, it
      disables the rule according to which classes are allowed if their
      __call__ method is allowed.
    allow_namedtuple_subclass: Reserved for internal use. When `True`,
      namedtuple subclasses are not allowed.

  Returns:
    Boolean
  __name__r!   zNot allowed: %s: %sFzAllowlisted: %s: %sT__code__z6Allowlisted: %s: generator functions are not converted__call__z(Allowlisted: %s: object __call__ allowedNz,Allowlisted: %s: method of TestCase subclass)check_call_overrideallow_namedtuple_subclassz$Allowlisted: %s: owner is allowed %sc                 s   s    | ]}t |V  qd S r   )r   isnamedtuple)r
   baser	   r	   r   r      s    z!is_allowlisted.<locals>.<genexpr>zAllowlisted: %s: named tuplez(Allowlisted: %s: named tuple or subclasszNot allowed: %s: default rule)!r   r"   partialr   	getmoduler   r   ZCONVERSION_RULESZ
get_actionActionZCONVERTr,   r/   ZDO_NOT_CONVERTisgeneratorfunctionisclasstyper3   is_allowlistedr   r   Zgetmethodclassr   ZTfMethodTarget__self__Ztarget_class
issubclassunittestZTestCaseZgetdefiningclassr6   r   	__bases__)r&   r4   r5   r$   ruleactionZowner_classr	   r	   r   r>   p   sf   








r>   c                 C   s$   zt | |W S  ty   Y dS w )NF)_ALLOWLIST_CACHEhas	TypeErrorentityoptionsr	   r	   r   is_in_allowlist_cache   s
   rK   c                 C   s(   z	dt |  |< W d S  ty   Y d S w )NT)rE   rG   rH   r	   r	   r   cache_allowlisted   s
   rL   )TF)__doc__r"   r   r   rA   Z tensorflow.python.autograph.corer   Z tensorflow.python.autograph.pyctr   r   Z!tensorflow.python.autograph.utilsr   r,   Z,tensorflow.python.eager.polymorphic_functionr   Ztensorflow.python.utilr   ZUnboundInstanceCacherE   r   r    r0   r>   rK   rL   r	   r	   r	   r   <module>   s&   	,
f