
    /jc                       d Z ddlmZ ddlZddlZddl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 erddlmZ ddlmZ ddlmZmZ 	 dHdIdZdJdKdZ	 	 dLdMdZ	 	 	 dNdddOd#Z	 dPdQd'Z	 dPdQd(Zdd)dRd,Zddd-dSd0Z 	 dTdddd1dUd4Z!	 	 dPdd5dVd6Z"dTdWd8Z#d9d:dXd<Z$dYdZd@Z	 dYdZdAZ%d[dDZ& eee
j        dE            eee
j                    eee
j                    ee            ee             ee!            ee"            ee#            ee$            eeej        dF            ee%ej        dF            ee&ej&        dG           dS )\a$  
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.
    )annotationsN)AnyTYPE_CHECKING)Callable)	argnums_t)	in_dims_t
out_dims_tFapistrnew_api
str | Nonereplace_newlinesboolreturnc                V    |d|  }d|  d| d}|r|                     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)r
   r   r   warnings       `/home/longshao/multi-rider-rag/.venv/lib/python3.11/site-packages/torch/_functorch/deprecated.pyget_warningr      sc     %%%	=#&	= 	= 	= 	= 	=   ,//$++N    Nonec                b    t          | |d          }t          j        |t          d           d S )NT)r      )
stacklevel)r   warningswarnFutureWarning)r
   r   r   s      r   warn_deprecatedr    /   s3    #w>>>GM'=Q777777r   functorch_apiCallable[..., Any]torch_func_apiCallable[..., Any] | Nonenew_api_namec                    | j         }|t          t          |          }|j        d S t	          ||          }dt          j        |d          z   }t          j        |d          }|j        |z   | _        d S )Nz
.. warning::

z    )__name__getattr_impl__doc__r   textwrapindent)r!   r#   r%   api_namer   warning_notes         r   
setup_docsr/   4   s{    
 %H 11%(L11G'(/'6*J*JJL?<88L*2\AMr   error
chunk_sizefuncin_dimsr   out_dimsr	   
randomnessr2   
int | Nonec               T    t          dd           t          j        | ||||          S )Nvmap
torch.vmapr1   )r    apisr9   )r3   r4   r5   r6   r2   s        r   r9   r9   F   s/     FL)))9T7HjZPPPPr   argnumsr   has_auxc                L    t          d           t          j        | ||          S )Ngrad)r    r;   r?   r3   r<   r=   s      r   r?   r?   R   s&     F9T7G,,,r   c                L    t          d           t          j        | ||          S )Ngrad_and_value)r    r;   rB   r@   s      r   rB   rB   Y   s(     $%%%tWg666r   )r=   primalsr   c               J    t          d           t          j        | g|R d|iS )Nvjpr=   )r    r)   rE   )r3   r=   rC   s      r   rE   rE   `   s0    E9T5G555W555r   strictr=   tangentsrG   c               R    t          d           t          j        | ||||          S )NjvprF   )r    r)   rJ   )r3   rC   rH   rG   r=   s        r   rJ   rJ   e   s-     E9T7HVWMMMMr   r=   r2   _preallocate_and_copyint | tuple[int, ...]rL   c               R    t          d           t          j        | ||||          S )NjacrevrK   )r    r)   rO   )r3   r<   r=   r2   rL   s        r   rO   rO   q   s:     H<3   r   r6   c               P    t          d           t          j        | |||          S )NjacfwdrP   )r    r)   rR   )r3   r<   r=   r6   s       r   rR   rR      s+     H<gw:FFFFr   intc                L    t          d           t          j        | |          S )Nhessian)r<   )r    r)   rU   )r3   r<   s     r   rU   rU      s%    I=w////r   	mutationsremoverX   c               L    t          d           t          j        | |          S )NfunctionalizerW   )r    r)   rZ   )r3   rX   s     r   rZ   rZ      s(     O$$$tF3333r   model	nn.Moduledisable_autograd_trackingc                L    t          dd           t          j        | |          S )Nmake_functionaltorch.func.functional_call)r    _nn_implr_   r[   r]   s     r   r_   r_      s(    %'CDDD#E+DEEEr   c                L    t          dd           t          j        | |          S )Nmake_functional_with_buffersr`   )r    ra   rd   rb   s     r   rd   rd      s*     24PQQQ08QRRRr   modelslist[nn.Module]c                J    t          dd           t          j        |           S )Ncombine_state_for_ensembletorch.func.stack_module_state)r    ra   rh   )re   s    r   rh   rh      s%    02QRRR.v666r   r:   r`   ri   )NF)r
   r   r   r   r   r   r   r   )N)r
   r   r   r   r   r   )NN)r!   r"   r#   r$   r%   r   r   r   )r   r   r0   )r3   r"   r4   r   r5   r	   r6   r   r2   r7   r   r"   )r   F)r3   r"   r<   r   r=   r   r   r"   )r3   r"   rC   r   r=   r   r   r   )r3   r"   rC   r   rH   r   rG   r   r=   r   r   r   )r   )r3   r"   r<   rM   r=   r   r2   r7   rL   r   r   r"   )
r3   r"   r<   r   r=   r   r6   r   r   r"   )r3   r"   r<   rS   r   r"   )r3   r"   rX   r   r   r"   )F)r[   r\   r]   r   r   r   )re   rf   r   r   )'r*   
__future__r   r+   r   typingr   r   torch._functorch.apis
_functorchr;   !torch._functorch.eager_transformseager_transformsr)    torch._functorch.make_functionalr_   ra   torch.nnnncollections.abcr   r   torch._functorch.vmapr   r	   r   r    r/   r9   r?   rB   rE   rJ   rO   rR   rU   rZ   rd   rh    r   r   <module>rv      s    # " " " " "   % % % % % % % % $ $ $ $ $ $ $ $ $ 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3        <((((((;;;;;;;;;;;;;; DI    $8 8 8 8 8 15#B B B B B( 		Q "	Q 	Q 	Q 	Q 	Q 	Q GL- - - - - GL7 7 7 7 7 BG 6 6 6 6 6 6 	N 	N 	N 	N 	N 	N &' !"'     ( G
 G G G G G G0 0 0 0 0 0;4 4 4 4 4 4F F F F F 9>S S S S S7 7 7 7
 
4L ) ) ) 

4    

>4. / / / 

3 

3 

6    

6    

7    

=    

?H46R S S S 

 (":<X   
'#    r   