
    ёi4                        S r SSKJr  SSKrSSKrSSKrSSKrSSKJrJ	r	  SSK
Jr  SSKr\" S5      r\	" S5      r/ r " S S	\5      r    S         SS
 jjrg)z,
decorator to deprecate a function or class
    )annotationsN)CallableTypeVar)	ParamSpec_InputT_RetTc                      \ rS rSrSrSrg)VisibleDeprecationWarning%   zVisible deprecation warning.

Since Python 3.7, Python only show the DeprecationWarning if the module
is __main__. So we use this warning to make the deprecation warning visible.

See more details from https://peps.python.org/pep-0565/
 N)__name__
__module____qualname____firstlineno____doc____static_attributes__r       W/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/utils/deprecated.pyr
   r
   %   s    r   r
   c                $   ^ ^^^ SUUUU 4S jjnU$ )a}  Decorate a function to signify its deprecation.

This function wraps a method that will soon be removed and does two things:
    - The docstring of the API will be modified to include a notice
      about deprecation."
    - Raises a :class:`~exceptions.DeprecatedWarning` when old API is called.

Args:
     since(str, optional): The version at which the decorated method is considered deprecated.
     update_to(str, optional): The new API users should use.
     reason(str, optional): The reason why the API is deprecated.
     level(int, optional): The deprecated warning log level. It must be
         an Integer and must be one of 0, 1, 2.
         If `level == 0`, the warning message will not be showed.
         If `level == 1`, the warning message will be showed normally.
         If `level == 2`, it will raise `RuntimeError`.

Returns:
    decorator: decorated function or class.
c                f  >^ ^^^ [        T
[        5      (       d   S5       e[        T	[        5      (       d   S5       e[        T[        5      (       d   S5       e[        T[        5      (       a  TS:  a  TS:  d   ST S35       eT	R                  5       mT
R                  5       nTR                  5       nST R                   ST R
                   S	3m[        T5      S:  a  TS
T 3-  mTS-  m[        U5      S:  a*  UR                  S5      (       d   ST
 S35       eTSU S3-  m[        U5      S:  a  TSU 3-  mT R                  (       a.  ST-   S-   [        R                  " T R                  5      -   T l        TS:X  a  T $ SS jm[        R                  " T 5      SUU UUUU	4S jj5       nU$ )zDconstruct warning message, and return a decorated function or class.z type of "update_to" must be str.ztype of "since" must be str.ztype of "reason" must be str.r      zFtype of "level" must be int and must be one of 0, 1, 2. But received: .API "z" is deprecatedz since z), and will be removed in future versions.zpaddle.z=Argument update_to must start with "paddle.", your value is ""z Please use "z
" instead.z
    Reason: z

Warning:
    z

c                    U R                  S5       Vs/ s H$  oR                  5       (       d  M  [        U5      PM&     sn$ s  snf )Nr   )splitisdigitint)versionparts     r   parse_version4deprecated.<locals>.decorator.<locals>.parse_versionl   s1    *1--*<O*<$ICI*<OOOs
   AAc                   > TS:X  a&  [        STR                   STR                   S35      eST S3n[        R                  R                  5       S:X  a  ST S	3nT	" [        R                  5      nUS
/S[        U5      -
  -  -  nT	" T
5      nUS
/S[        U5      -
  -  -  n[        R                  S:X  d  TS:X  d  X4:  a  [        R                  " U[        SS9  T" U 0 UD6$ )a(  deprecated warning should be fired in 3 circumstances:
1. current version is develop version, i.e. "0.0.0", because we assume develop version is always the latest version.
2. since version is empty, in this case, API is deprecated in all versions.
3. current version is newer than since version.
   r   r   z" has been deprecated.z[93m
Warning:
z [0mwin32z

Warning:
 r      z0.0.0 )category
stacklevel)RuntimeErrorr   r   sysplatformlowerpaddle__version__lenwarningswarnr
   )argskwargs
warningmsg	v_currentv_since_sincefunclevelmsgr!   sinces        r   wrapper.deprecated.<locals>.decorator.<locals>.wrapperp   s     z"DOO,Admm_<RS  0uH=J||!!#w.+C52
%f&8&89I!C	N 233I#E*Gsa#g,.//G""g-R<')Bq (((r   )r   str)r4   z_InputT.argsr5   z_InputT.kwargsreturnr   )
isinstancer@   r   stripr   r   r1   
startswithr   inspectcleandoc	functoolswraps)r:   
_update_to_reasonr>   r9   r<   r!   r;   reasonr=   	update_tos   `   @@@r   	decoratordeprecated.<locals>.decoratorJ   s   )S))M+MM)%%%E'EE%&#&&G(GG&%%%%1* 	
q"	
B
 __&
,,.doo&aoFv;?WVH%%C::z?Q((33 OPY{Z[\3 ]:,j99Cw<!^G9--C<<$s*V3  ./DL A:K	P 
		) 	) 
	)@ r   )r:   Callable[_InputT, _RetT]rA   rO   r   )rL   r=   rK   r;   rM   s   ```` r   
deprecatedrP   /   s    6G GR r   )r(   r(   r(   r   )
rL   r@   r=   r@   rK   r@   r;   r   rA   z>Callable[[Callable[_InputT, _RetT]], Callable[_InputT, _RetT]])r   
__future__r   rG   rE   r,   r2   typingr   r   typing_extensionsr   r/   r   r   __all__UserWarningr
   rP   r   r   r   <module>rV      s    #   
  $ ' 
I
   	ddd d 	d
 Ddr   