
    ϑib                    X   S SK Jr  S SKrS SKJrJrJrJrJr  S SK	J
r
  S SKrS SKJr  SSKJr  \(       a  S SKJr  \" S	5      r\
" S
5      r " S S\5      r\    SS j5       r\SSS jj5       rSS jr SSSS.       SS jjjr S   SS jjr S   SS jjr      SS jrg)    )annotationsN)TYPE_CHECKINGCallableProtocolTypeVaroverload)	ParamSpec)DYNAMIC_DIMS_ATTR_NAME   )TransformOptions)Sequence_RetT_InputTc                  H    \ rS rSr\    SS j5       r\SSS jj5       rSrg)	_NotToStaticDecorator'   c                    g N selffuncs     Q/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/jit/marker.py__call___NotToStaticDecorator.__call__(   s     $'    c                    g r   r   r   s     r   r   r   -   s    CFr   r   Nr   Callable[_InputT, _RetT]returnr   .r   Noner    r   )__name__
__module____qualname____firstlineno__r   r   __static_attributes__r   r   r   r   r   '   s4    ','	!' ' F Fr   r   c                    g r   r   r   s    r   not_to_staticr+   1   s      #r   c                    g r   r   r*   s    r   r+   r+   7   s    >Ar   c                    [        U SSS9$ )a  
A Decorator to suppresses the convention of a function.

Args:
    func(callable): The function to decorate.

Returns:
    callable: A function which won't be converted in Dynamic-to-Static.

Examples:
    .. code-block:: python

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

        >>> @paddle.jit.not_to_static
        ... def func_not_to_static(x):
        ...     res = x - 1
        ...     return res

        >>> @paddle.jit.to_static
        ... def func(x):
        ...     if paddle.mean(x) < 0:
        ...         out = func_not_to_static(x)
        ...     else:
        ...         out = x + 1
        ...     return out
        ...
        >>> x = paddle.ones([1, 2], dtype='float32')
        >>> out = func(x)
        >>> print(out)
        Tensor(shape=[1, 2], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[2., 2.]])
FTfor_sotfor_ast)unifiedr*   s    r   r+   r+   <   s    F 455r   Tr.   c               8   ^^^ SS jmU c  UUU4S j$ T" U TTS9$ )a:  
Mark a function already unified in dygraph and static mode. So
that it won't be transformed again in SOT or AST mode.

Args:
    fn(callable): The function to decorate.
    for_sot(bool): Whether to mark the function as unified in SOT mode.
    for_ast(bool): Whether to mark the function as unified in AST mode.
c               &   [         R                  R                  5       nU(       a  U[         R                  R                  -  nU(       a  U[         R                  R                  -  n[        5       R                  U5      nUR                  U 5        U $ r   )r   ToStaticModeNilSOTASTwith_skip_transform_modeattach)fnr/   r0   modeoptionss        r   _mark_as_unified!unified.<locals>._mark_as_unifiedr   sn    ,,002$11555D$11555D"$==dCr	r   c                   > T" U TTS9$ )Nr.   r   )r:   r=   r0   r/   s    r   <lambda>unified.<locals>.<lambda>}   s    *2wPr   r.   )r/   boolr0   rB   r   )r:   r/   r0   r=   s    ``@r   r1   r1   b   s$      
zPPBAAr   c                "    S nU c  U$ U" U 5      $ )Nc                Z    [        5       R                  S5      nUR                  U 5        U $ )NT)r   with_need_capture_control_flowr9   )r:   r<   s     r   "_mark_as_need_capture_control_flow@capture_control_flow.<locals>._mark_as_need_capture_control_flow   s&    "$CCDIr	r   r   )r:   rF   s     r   capture_control_flowrH      s    
 
z11-b11r   c                   SSK Jn  [        R                  " U 5      (       aP  [	        U [
        R                  R                  5      (       a'  UR                  R                  R                  U 5        U $ [        R                  " U 5      (       a'  UR                  R                  R                  U 5        U $ [        S[        U 5      R                   S35      e)z
Mark a function or paddle.nn.Layer to be executed in dynamic mode, it will
break the graph and prevent it from being converted to static mode.
r   )sotz0Expected a callable or paddle.nn.Layer, but got .)
paddle.jitrJ   inspectisclass
issubclasspaddlennLayerutilspaddle_api_configadd_break_graph_layer_class
isfunctionadd_break_graph_function	TypeErrortyper$   )r:   rJ   s     r   force_dynamicrZ      s     rz"fiioo>>		##??C	"		##<<R@	

:48;L;L:MQO r   c                z   [        U [        R                  5      (       d"  [        S[	        U 5      R
                   S35      e[        U[        5      (       a  U4n[        U[        [        45      (       d  [        S5      e[        S U 5       5      (       d  [        S5      e[        U [        [        U5      5        g)aS  
Mark a tensor as having dynamic dimensions.
This is used to indicate that the tensor's shape may change dynamically
during execution, which is particularly useful in dynamic-to-static
conversion scenarios.
Args:
    tensor (paddle.Tensor): The tensor to mark as dynamic.
    dims (int | Sequence[int]): The dimensions to mark as dynamic.
z"Expected a paddle.Tensor, but got rK   z#Dimensions must be a list or tuple.c              3  B   #    U  H  n[        U[        5      v   M     g 7fr   )
isinstanceint).0dims     r   	<genexpr>dynamic_dims.<locals>.<genexpr>   s     4tz#s##ts   z All dimensions must be integers.N)r]   rP   TensorrX   rY   r$   r^   listtupleallsetattrr
   )tensordimss     r   dynamic_dimsrj      s     ffmm,,0f1F1F0GqI
 	
 $wdT5M**=>>4t444:;;F*E$K8r   r   r!   r"   r   )r:   7Callable[_InputT, _RetT] | type[paddle.nn.Layer] | Noner/   rB   r0   rB   r    r   )r:   zCallable[_InputT, _RetT] | Noner    r   )r:   rk   r    r   )rh   zpaddle.Tensorri   zint | Sequence[int]r    r#   )
__future__r   rM   typingr   r   r   r   r   typing_extensionsr	   rP   paddle.jit.dy2static.utilsr
   dy2static.utilsr   collections.abcr   r   r   r   r+   r1   rH   rZ   rj   r   r   r   <module>rr      s&   #  G G  = ( 	
I
GH G 
#
"## 
#
 
 A 
 A#6N CGB 	B?B B 	B
 B@ +/
2'
2
2 CG?*99
9 
9r   