
    is                     j   d Z ddlZddlZddlmZ ddlmZmZmZ ddl	m
c mZ ddlm
c mZ ddlm
c mZ ddlmZ ddlmZ ddlmZmZ d1dZd2d	Zd3d
Z	 	 	 d4dddededededef
dZd5dedededefdZ	 d5dedededefdZdddedefdZ ddddededededef
dZ!	 d6dddddedee"e#e"df   f   d ee"   fd!Z$	 	 d5dd"dedededefd#Z%d6d$Z&d%d&ded'edefd(Z'd7d)ejP                  d*efd+Z	 d7d)ejP                  d*efd,Z)d- Z* eeej8                  d.        eeej<                          eeej>                          ee         ee!        ee$        ee%        ee&        ee'        eeej                   d/        ee)ej                   d/        ee*ejT                  d0       y)8a$  
The APIs in this file are exposed as `functorch.*`. They are thin wrappers
around the torch.func.* APIs that have deprecation warnings -- we're trying
to move people to the torch.func.* equivalents.

NB: We don't use *args, **kwargs in the signatures because that changes the
documentation.
    N)Callable)AnyOptionalUnion)	argnums_t)	in_dims_t
out_dims_tFc                 N    |d|  }d|  d| d}|r|j                  dd      }|S )Nztorch.func.z[We've integrated functorch into PyTorch. As the final step of the 
integration, `functorch.zk` is deprecated as of PyTorch 
2.0 and will be deleted in a future version of PyTorch >= 2.3. 
Please use `z` instead; see the PyTorch 2.0 release notes 
and/or the `torch.func` migration guide for more details 
https://pytorch.org/docs/main/func.migrating.html
 )replace)apinew_apireplace_newlineswarnings       U/var/www/html/engine/venv/lib/python3.12/site-packages/torch/_functorch/deprecated.pyget_warningr      sP    u%##&% (i  <	=  //$+N    c                 X    t        | |d      }t        j                  |t        d       y )NT)r      )
stacklevel)r   warningswarnFutureWarning)r   r   r   s      r   warn_deprecatedr   (   s     #w>GMM'=Q7r   c                     | j                   }|t        t        |      }|j                  y t	        ||      }dt        j                  |d      z   }t        j                  |d      }|j                  |z   | _        y )Nz
.. warning::

z    )__name__getattr_impl__doc__r   textwrapindent)functorch_apitorch_func_apinew_api_nameapi_namer   warning_notes         r   
setup_docsr(   -   sr    %%H 1%(L1G'(//'6*JJL??<8L*22\AMr   error
chunk_sizefuncin_dimsout_dims
randomnessreturnc                N    t        dd       t        j                  | ||||      S )Nvmap
torch.vmapr*   )r   apisr2   )r,   r-   r.   r/   r+   s        r   r2   r2   ;   s%     FL)99T7HjZPPr   argnumshas_auxc                 F    t        d       t        j                  | ||      S )Ngrad)r   r4   r8   r,   r5   r6   s      r   r8   r8   G   s    F99T7G,,r   c                 F    t        d       t        j                  | ||      S )Ngrad_and_value)r   r4   r;   r9   s      r   r;   r;   L   s"     $%tWg66r   )r6   c                J    t        d       t        j                  | g|d|iS )Nvjpr6   )r   r   r=   )r,   r6   primalss      r   r=   r=   S   s#    E99T5G5W55r   strictr6   r>   tangentsr@   c                L    t        d       t        j                  | ||||      S )Njvpr?   )r   r   rC   )r,   r>   rA   r@   r6   s        r   rC   rC   X   s#     E99T7HVWMMr   r6   r+   _preallocate_and_copy.r+   c                L    t        d       t        j                  | ||||      S )NjacrevrD   )r   r   rG   )r,   r5   r6   r+   rE   s        r   rG   rG   d   s,     H<<3 r   r/   c                J    t        d       t        j                  | |||      S )NjacfwdrH   )r   r   rJ   )r,   r5   r6   r/   s       r   rJ   rJ   v   s!     H<<gw:FFr   c                 F    t        d       t        j                  | |      S )Nhessian)r5   )r   r   rL   )r,   r5   s     r   rL   rL      s    I==w//r   	mutationsremoverO   c                F    t        d       t        j                  | |      S )NfunctionalizerN   )r   r   rQ   )r,   rO   s     r   rQ   rQ      s    O$tF33r   modeldisable_autograd_trackingc                 F    t        dd       t        j                  | |      S )Nmake_functionaltorch.func.functional_call)r   _nn_implrU   rR   rS   s     r   rU   rU      s"    %'CD##E+DEEr   c                 F    t        dd       t        j                  | |      S )Nmake_functional_with_buffersrV   )r   rW   rZ   rX   s     r   rZ   rZ      s$     24PQ008QRRr   c                 D    t        dd       t        j                  |       S )Ncombine_state_for_ensembletorch.func.stack_module_state)r   rW   r\   )modelss    r   r\   r\      s    02QR..v66r   r3   rV   r]   )NF)N)NN)r   r   r)   )r   F)r   )F)+r    r!   r   collections.abcr   typingr   r   r   torch._functorch.apis
_functorchr4   !torch._functorch.eager_transformseager_transformsr    torch._functorch.make_functionalrU   rW   torch.nnnnr   torch._functorch.vmapr   r	   r   r   r(   strr2   boolr8   r;   r=   rC   inttuplerG   rJ   rL   rQ   ModulerZ   r\    r   r   <module>ro      s     $ ' ' $ $ 1 1 3 3  7 7 8
B  		Q 	Q
	Q	Q 	Q 		Q 	Q-x -) -$ -8 - =B7
7&75977 38 6h 64 6 	N
	N	N 	N
 	N 	N ,-  $
3c3h'(
 ( G
 G
GG G
 G0
 4? 4 4S 48 4
F299 F F 9>S99S15S7
 4L ) 
4  
>4.. / 
3 
3 
6  
6  
7  
=  
?H446R S 
 (":":<X ''#r   