o
    IhS                     @   s  d Z ddlZddlZddlmZmZmZmZ ddlm	  m
Z
 ddlm	  mZ ddlm	  mZ ddlmZ ddlmZ ddlmZmZ d>ddZd?d	d
Zd@ddZ			dAdddededededef
ddZdBdedededefddZ	dBdedededefddZdddedefddZdddded ed!ed"edef
d#d$Z 	dCdddd%dedee!e"e! f d&ee! fd'd(Z#		dBdd)dedededefd*d+Z$dCd,d-Z%d.d/ded0edefd1d2Z&dDd3ej'd4efd5d6Z	dDd3ej'd4efd7d8Z(d9d: Z)eee
j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j)d= dS )Ea$  
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)AnyCallableOptionalUnion)	argnums_t)	in_dims_t
out_dims_tFc                 C   s8   |d u r	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)apinew_apireplace_newlineswarning r   O/var/www/vscode/kcb/lib/python3.10/site-packages/torch/_functorch/deprecated.pyget_warning   s   
r   c                 C   s"   t | |dd}tj|tdd d S )NT)r      )
stacklevel)r   warningswarnFutureWarning)r   r   r   r   r   r   warn_deprecated'   s   r   c                 C   s\   | j }|d u rtt|}|jd u rd S t||}dt|d }t|d}|j| | _d S )Nz
.. warning::

z    )__name__getattr_impl__doc__r   textwrapindent)functorch_apitorch_func_apinew_api_nameapi_namer   warning_noter   r   r   
setup_docs,   s   


r$   error
chunk_sizefuncin_dimsout_dims
randomnessreturnc                C   s   t dd tj| ||||dS )Nvmap
torch.vmapr&   )r   apisr-   )r(   r)   r*   r+   r'   r   r   r   r-   :   s   
r-   argnumshas_auxc                 C      t d t| ||S )Ngrad)r   r/   r3   r(   r0   r1   r   r   r   r3   F      r3   c                 C   r2   )Ngrad_and_value)r   r/   r6   r4   r   r   r   r6   K   s   r6   )r1   c                G   s    t d tj| g|R d|iS )Nvjpr1   )r   r   r7   )r(   r1   primalsr   r   r   r7   R   s   r7   strictr1   r8   tangentsr:   c                C      t d tj| ||||dS )Njvpr9   )r   r   r=   )r(   r8   r;   r:   r1   r   r   r   r=   W   s   r=   r1   r'   _preallocate_and_copyr'   c                C   r<   )Njacrevr>   )r   r   r@   )r(   r0   r1   r'   r?   r   r   r   r@   c   s   r@   r+   c                C   s   t d tj| |||dS )NjacfwdrA   )r   r   rB   )r(   r0   r1   r+   r   r   r   rB   u   s   rB   c                 C      t d tj| |dS )Nhessian)r0   )r   r   rD   )r(   r0   r   r   r   rD      r5   rD   	mutationsremoverG   c                C   rC   )NfunctionalizerF   )r   r   rH   )r(   rG   r   r   r   rH      r5   rH   modeldisable_autograd_trackingc                 C      t dd t| |S )Nmake_functionaltorch.func.functional_call)r   _nn_implrL   rI   rJ   r   r   r   rL      s   
rL   c                 C   rK   )Nmake_functional_with_buffersrM   )r   rN   rP   rO   r   r   r   rP      s   
rP   c                 C   s   t dd t| S )Ncombine_state_for_ensembletorch.func.stack_module_state)r   rN   rQ   )modelsr   r   r   rQ      s   

rQ   r.   rM   rR   )NF)N)NN)r   r   r%   )r   F)r   )F)*r   r   r   typingr   r   r   r   torch._functorch.apis
_functorchr/   !torch._functorch.eager_transformseager_transformsr    torch._functorch.make_functionalrL   rN   torch.nnnnr   torch._functorch.vmapr   r   r   r   r$   strr-   boolr3   r6   r7   r=   inttupler@   rB   rD   rH   ModulerP   rQ   r   r   r   r   <module>   s   	










