o
    ZhS                     @   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   J/var/www/auris/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)Zfunctorch_apiZtorch_func_apiZnew_api_nameZapi_namer   Z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*   r.   r#   r+   r,   r   r   r   r.   F      r.   c                 C   r-   )Ngrad_and_value)r   r*   r1   r/   r   r   r   r1   K   s   r1   )r,   c                G   s    t d tj| g|R d|iS )Nvjpr,   )r   r   r2   )r#   r,   primalsr   r   r   r2   R   s   r2   strictr,   r3   tangentsr5   c                C      t d tj| ||||dS )Njvpr4   )r   r   r8   )r#   r3   r6   r5   r,   r   r   r   r8   W   s   r8   r,   r"   _preallocate_and_copyr"   c                C   r7   )Njacrevr9   )r   r   r;   )r#   r+   r,   r"   r:   r   r   r   r;   c   s   r;   r&   c                C   s   t d tj| |||dS )Njacfwdr<   )r   r   r=   )r#   r+   r,   r&   r   r   r   r=   u   s   r=   c                 C      t d tj| |dS )Nhessian)r+   )r   r   r?   )r#   r+   r   r   r   r?      r0   r?   Z	mutationsremoverA   c                C   r>   )Nfunctionalizer@   )r   r   rB   )r#   rA   r   r   r   rB      r0   rB   modeldisable_autograd_trackingc                 C      t dd t| |S )Nmake_functionaltorch.func.functional_call)r   _nn_implrF   rC   rD   r   r   r   rF      s   
rF   c                 C   rE   )Nmake_functional_with_buffersrG   )r   rH   rJ   rI   r   r   r   rJ      s   
rJ   c                 C   s   t dd t| S )Ncombine_state_for_ensembletorch.func.stack_module_state)r   rH   rK   )modelsr   r   r   rK      s   

rK   r)   rG   rL   )NF)N)NN)r   r   r    )r   F)r   )F)*r   r   r   typingr   r   r   r   Ztorch._functorch.apisZ
_functorchr*   Z!torch._functorch.eager_transformsZeager_transformsr   Z torch._functorch.make_functionalrF   rH   Ztorch.nnnnr   Ztorch._functorch.vmapr   r   r   r   r   strr(   boolr.   r1   r2   r8   inttupler;   r=   r?   rB   ModulerJ   rK   r   r   r   r   <module>   s   	









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