
    BVh}                         d 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
 dd	l	mZ  G d
 de      Z G d dej                        Zd Zy)zJConverts function definitions and lambdas by adding necessary boilerplate.    N)	converter)anno)parser)
qual_names)	templates)activity)annosc                       e Zd Zd Zy)	_Functionc                     d | _         y N)context_name)selfs    `/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/autograph/converters/functions.py__init__z_Function.__init__   s
    D    N)__name__
__module____qualname__r    r   r   r   r      s    r   r   c                   "    e Zd ZdZd Zd Zd Zy)FunctionTransformerz<Wraps function bodies around autograph-specific boilerplate.c                     |j                   dk(  r | j                  j                  j                  S | j                  j                  j                  j	                         S )z9Returns the options with which to create function scopes.   )levelctxuseroptionscall_options)r   fn_scopes     r   _function_scope_optionsz+FunctionTransformer._function_scope_options%   sA     ~~XX]]"""88==  --//r   c           
         | j                   t           5 }| j                  |      }|j                  dkD  r t	        j
                  d|      cd d d        S t        j                  |t        j                  j                        }| j                  j                  j                  d|j                        }||_        t        j                  |d|       d}t	        j
                  || j!                  |      j#                         |t%        j&                  |d       |j(                        |_        |cd d d        S # 1 sw Y   y xY w)	Nr   zag__.autograph_artifact(l))llscopefunction_context_namezt
        ag__.with_function_scope(
            lambda function_context: body, function_context_name, options)
      kind)r   function_contextr%   body)stater   generic_visitr   r   replace_as_expressionr   getannoStaticSCOPEr   namer
new_symbol
referencedr   setannor!   to_astgastConstantr)   )r   noder    scoper%   templates         r   visit_Lambdaz FunctionTransformer.visit_Lambda1   s   	I	 (%d 
!	..(D2  ll4!2!23e"hhnn778=8H8HJ3h
ll402GH
h 11
..x8??A0 $.C$ Oyydi 3  s   7D9CD99Ec           	         | j                   t           5 }t        j                  |t        j
                  j                        }| j                  j                  j                  d|j                        }||_        t        j                  |d|       | j                  |      }|j                  dk  rg |_        n.|j                  j!                  t#        j$                  d             d }|j&                  rc|j&                  d   }t)        |t*        j,                        r:t)        |j.                  t*        j0                        r|}|j&                  dd  |_        d}t3        j4                  |t+        j0                  |j6                  d       t+        j0                  |d       | j9                  |      j;                         ||j&                  	      }||g|z   }||_        |cd d d        S # 1 sw Y   y xY w)
Nfscoper%   r   zag__.autograph_artifactr      z~
        with ag__.FunctionScope(
            function_name, context_name, options) as function_context:
          body
      r&   )function_namer   r   r(   r)   )r*   r   r   r-   r	   NodeAnno
BODY_SCOPEr   r0   r1   r2   r   r3   r+   r   decorator_listappendr   parse_expressionr)   
isinstancer5   Exprvaluer6   r   replacenamer!   r4   )	r   r7   r    r8   r%   docstring_nodefirst_statementr9   wrapped_bodys	            r   visit_FunctionDefz%FunctionTransformer.visit_FunctionDefM   s   	I	 1(ll4!:!:;e"hhnn778=8H8HJ3h
ll402GH%d	1	 ! 	""##$=>	@ n	))A,		2,,dmm<*.iim$)
h
 &&
diid;}}%:F..x8??A0yyl 
	#&',6dic1 1 1s   GG**G3N)r   r   r   __doc__r!   r:   rL   r   r   r   r   r   "   s    D
082r   r   c                     t        j                  |       } t        j                  | |d       } t        |      j	                  |       S r   )r   resolver   r   visit)r7   r   s     r   	transformrQ      s<    			D	!$			$T	*$	S	!	'	'	--r   )rM   r5    tensorflow.python.autograph.corer    tensorflow.python.autograph.pyctr   r   r   r   0tensorflow.python.autograph.pyct.static_analysisr   r	   objectr   Baser   rQ   r   r   r   <module>rW      sG    Q  6 1 3 7 6 E B ]).. ]@.r   