
    ϑiM-                       S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	r	S SK
JrJrJr  S SKrS SKJr  SSKJrJrJrJrJr  SSKJr  SSKJrJrJr  SS	KJrJrJ r J!r!  \(       a  S S
K"J#r#  / r$\" 5       r%S r&\&" 5       q'SS jr(\RR                  SS j5       r*\RR                  SS j5       r+S r, " S S5      r-S r.g)    )annotationsN)TYPE_CHECKINGAnyCallable)Layer   )convert_enumerateconvert_lenconvert_printconvert_rangeconvert_zip)TranslatorLogger)StaticFunctionconvert_to_staticunwrap_decorators)TransformOptions
is_builtinis_paddle_funcpatch_method_guard)
ModuleTypec                     [         [        [        [        [        [
        [        [        /n  SSKnU R                  U5        U $ ! [         a     U $ f = f)z
Return builtin modules.
r   N)copycollectionsinspectloggingnumpyospdbresixappendImportError)modulesr    s     f/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/jit/dy2static/convert_call_func.pybuiltin_modulesr%   <   sW    
 	

	Gs N  Ns   A 
AAc                X    U  H$  nU[         ;  d  M  [         R                  U5        M&     g)z(
Adds modules that ignore transcription
N)BUILTIN_LIKELY_MODULESr!   )r#   modules     r$   add_ignore_moduler)   W   s%    
 //"))&1     c                F   ^^^ [        5       mSS jmUUU4S jmT" U 5      $ )Nc                T     [         R                  " U 5      $ ! [         a    / s $ f = fN)r   
getmembers	Exception)r(   s    r$   _try_get_members.get_module_functions.<locals>._try_get_memberse   s,    	%%f-- 	I	s    ''c                
  > U T;   a  / $ TR                  U 5        / nT" U 5       HZ  u  p#[        U5      (       a  UR                  U5        [        R                  " U5      (       d  MC  UR                  T" U5      5        M\     U$ r-   )addcallabler!   r   ismoduleextend)r(   results_member_namemember_get_module_functionsr0   visiteds       r$   r:   3get_module_functions.<locals>._get_module_functionsk   st    WIF$4V$< Lv&''4V<=	 %=
 r*   )returnzlist[tuple[str, Any]])set)r(   r:   r0   r;   s    @@@r$   get_module_functionsr?   a   s!    eG
 !((r*   c                n    SS jn[        U S5      (       a  U R                  c  g U" U R                  5      $ )Nc                2    [         R                  " SSU 5      $ )Nz__init__.py$ )r   sub)	file_paths    r$   _remove_module_init_suffix<get_module_defining_path.<locals>._remove_module_init_suffix|   s    vvor955r*   __file__)rD   strr=   rH   )hasattrrG   )r(   rE   s     r$   get_module_defining_pathrJ   z   s1    6 6:&&&//*A%foo66r*   c                D  ^ [          Vs/ s H  n[        U5      =nc  M  UPM     nn[        U S5      (       ac  U R                  R                  (       aH  U R                  R                  m[        U4S jU 5       5      (       a  [        R                  SSU 5        g[          VV s/ s H  n[        U5        H  n U PM     M     nnn U H!  nW UL d  M
  [        R                  SSU 5          g   [        W 5      (       a  [        R                  SSU 5        ggs  snf s  sn nf )zB
Checks whether the func is supported by dygraph to static graph.
__code__c              3  F   >#    U  H  nTR                  U5      v   M     g 7fr-   )
startswith).0module_path	func_paths     r$   	<genexpr>!is_unsupported.<locals>.<genexpr>   s&      
3   --3s   !   zMWhitelist: %s is part of built-in module and does not have to be transformed.TzKWhitelist: %s is part of Paddle module and does not have to be transformed.F)
r'   rJ   rI   rL   co_filenameanytranslator_loggerlogr?   r   )funcr(   rP   builtin_module_pathsbuiltin_functions
builtin_fnrQ   s         @r$   is_unsupportedr]      s/    -,F3F;;K 	,   tZ  T]]%>%>MM--	 
3
 
 
 !!_
  -,F(0D 	0 	,   (
:!!_
  ( dY	

 Y(s   DD%Dc                       \ rS rSrS rS rSrg)StaticLayerWrapper   c                    Xl         g r-   layer)selfrc   s     r$   __init__StaticLayerWrapper.__init__   s    
r*   c                    [        U R                  S[        U R                  R                  5      5         U R                  " U0 UD6sS S S 5        $ ! , (       d  f       g = f)Nforward)r   rc   convert_callrh   )rd   argskwargss      r$   __call__StaticLayerWrapper.__call__   sG    JJ	<

0B0B#C
 ::t.v.
 
 
s   A
Arb   N)__name__
__module____qualname____firstlineno__re   rl   __static_attributes__ r*   r$   r_   r_      s    /r*   r_   c                D   [         R                  SSU 5        SnSn[        U 5      u  p0[        R                  " U [        R
                  R                  5      (       d  [         R                  SSU 5        U $ [        U S5      (       a  [        $ [        U S5      (       a  [        $ [        U S5      (       a  [        $ [        U S	5      (       a  [        $ [        U S
5      (       a  [        $ [        U 5      (       d  [        U 5      (       a  U $ [        R                  " U 5      (       a<  Sn[         R!                  SSU-  -   SU R"                   S3-   S-   SU-  -   S-   5        U $ [        R$                  " U 5      (       GaW  U R"                  S:X  a  U $  [        R&                  " U 5      n[)        5       nUR*                  R-                  5        H  n[        R$                  " U5      (       a  UR/                  U5        M1  [1        U[2        5      (       a   [        U5      u  p7UR/                  U5        Mf  [        R4                  " U5      (       d  M  [1        UR6                  R9                  U R"                  S5      [:        5      (       d  M  UR/                  U 5        M     X;   a  [=        U 5      n[?        U SS5      nO[         R!                  SU 5        U nO[        RD                  " U 5      (       a   [=        U 5      n[?        U SS5      nO[G        U S5      (       ap  [I        U RJ                  5      (       aV  [G        U S5      (       a   [1        U [L        5      (       a  [O        U 5      $  U RJ                  RP                  n[=        U5      nU nO[U        SU  S35      eUc  [         R!                  SU 5        U $ Ub  [V        RX                  " X!5      nU$ ! [@         a    Sn ND[B         a    Sn NQf = f! [B         a    Sn Ncf = f! [B        [R        4 a    U(       a  SOUn Nf = f)a  
Converts a function call which needs to be transformed to static function.

Args:
    func (callable): A callable function or method to convert.

Returns:
    Callable: A converted function.

Examples:
    .. code-block:: python

        >>> # doctest: +SKIP('`paddle.jit.to_static` can not run in xdoctest')
        >>> import paddle
        >>> from paddle.jit.dy2static import Call

        >>> paddle.enable_static()
        >>> def dyfunc(x):
        ...     if paddle.mean(x) < 0:
        ...         x_v = x - 1
        ...     else:
        ...         x_v = x + 1
        ...     return x_v
        ...
        >>> new_func = Call(dyfunc)
        >>> x = paddle.tensor.manipulation.fill_constant(shape=[3, 3], value=0, dtype='float64')
        >>> x_v = new_func(x)

        >>> exe = paddle.static.Executor(paddle.CPUPlace())
        >>> out = exe.run(fetch_list=[x_v])
        >>> print(out[0])
        [[1. 1. 1.]
         [1. 1. 1.]
         [1. 1. 1.]]

r   z$Convert callable object: convert %s.NrT   zG%s is not converted when it is decorated by 'paddle.jit.not_to_static'.lenziprange	enumerateprint   z

*z
Your function:`zk` doesn't support to transform to static function because it is a generator function, it will be run as-is.
z<lambda>__self__zr%s doesn't have to be transformed to static function because it has been transformed before, it will be run as-is.	__class__rh   z	Callable z# can not be transformed at present.zO%s doesn't have to be transformed to static function, and it will be run as-is.)-rW   rX   r   r   check_fn_need_transformToStaticModeASTr   r
   r   r   r	   r   r]   r   isgeneratorfunctionwarnrn   
isfunctionunwrapr>   __globals__valuesr3   
isinstancer   isclass__dict__getstaticmethodr   getattrAttributeErrorOSErrorismethodrI   r4   r~   r   r_   rl   	TypeErrorNotImplementedError	functoolspartial)	rY   	func_selfconverted_call_number_of_stars	_origfuncglobal_functionsfn	call_funcs	            r$   ri   ri      s   J !CTJIN  %GA33++//  	U	

 $$$  $$$  $  $>$//""4(( O#$!$--  1\  ]]  O#	$
 	
 $==J&K2	"  t,I"u++224%%b))$((,N33-b1EA$((,__R((!t<l  ),,  5 '!24!8#D*d;	
 "&& I "& 
		$			".t4Nj$7I
 
{	#	#(@(@4##
4(?(?%d++= NN33	!29!= 	 "v@A
 	
 ]	
 "**>E[  	" "N 	" "N		"  	"!N	" Y' = %.D9		=sO   B9O 7O 	2O <O 1O/ '#P O,O,+O,/O>=O>PP)r#   zlist[ModuleType])r(   r   r=   zlist[Callable[..., Any]])r(   r   r=   z
str | None)/
__future__r   r   r   r   r   r   r   r   r   typingr   r   r   r   	paddle.nnr   convert_operatorsr	   r
   r   r   r   logging_utilsr   program_translatorr   r   r   utilsr   r   r   r   typesr   __all__rW   r%   r'   r)   	lru_cacher?   rJ   r]   r_   ri   rs   r*   r$   <module>r      s    #      	 
 	 / /    , 
   
 %& 0 )* 2 ) )0 7 71h/ /rr*   