a
    hS                     @   sF  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 d8ddZd9d	d
Zd:ddZd;ddeeeeedddZd<eeeedddZd=eeeedddZddeedddZdddeeeeedddZ d>ddddeee!e"e! f ee! d d!d"Z#d?dd#eeeed$d%d&Z$d@d'd(Z%d)d*eeed+d,d-Z&dAej'ed.d/d0ZdBej'ed.d1d2Z(d3d4 Z)eee
jd5 eee
j eee
j ee ee  ee# ee$ ee% ee& eeejd6 ee(ejd6 ee)ej)d7 dS )Ca$  
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}|r4| 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   I/var/www/auris/lib/python3.9/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(   )r#   argnumshas_auxr'   c                 C   s   t d t| ||S )Ngrad)r   r*   r-   r#   r+   r,   r   r   r   r-   F   s    r-   c                 C   s   t d t| ||S )Ngrad_and_value)r   r*   r/   r.   r   r   r   r/   K   s    r/   )r,   )r#   r,   c                G   s    t d tj| g|R d|iS )Nvjpr,   )r   r   r0   )r#   r,   primalsr   r   r   r0   R   s    r0   strictr,   r#   r1   Ztangentsr3   r,   c                C   s   t d tj| ||||dS )Njvpr2   )r   r   r5   r4   r   r   r   r5   W   s    r5   r,   r"   _preallocate_and_copy)r#   r+   r"   c                C   s   t d tj| ||||dS )Njacrevr6   )r   r   r8   )r#   r+   r,   r"   r7   r   r   r   r8   c   s    r8   r&   r#   r+   r,   r&   c                C   s   t d tj| |||dS )Njacfwdr9   )r   r   r;   r:   r   r   r   r;   u   s    r;   c                 C   s   t d tj| |dS )Nhessian)r+   )r   r   r<   )r#   r+   r   r   r   r<      s    r<   Z	mutationsremove)r#   r>   r'   c                C   s   t d tj| |dS )Nfunctionalizer=   )r   r   r?   )r#   r>   r   r   r   r?      s    r?   modelZdisable_autograd_trackingc                 C   s   t dd t| |S )Nmake_functionaltorch.func.functional_call)r   _nn_implrB   r@   r   r   r   rB      s    
rB   c                 C   s   t dd t| |S )Nmake_functional_with_buffersrC   )r   rD   rE   r@   r   r   r   rE      s    
rE   c                 C   s   t dd t| S )Ncombine_state_for_ensembletorch.func.stack_module_state)r   rD   rF   )modelsr   r   r   rF      s    
rF   r)   rC   rG   )NF)N)NN)r   r   r    )r   F)r   F)r   )r   F)r   )F)F)*r   r   r   typingr   r   r   r   Ztorch._functorch.apisZ
_functorchr*   Z!torch._functorch.eager_transformsZeager_transformsr   Z torch._functorch.make_functionalrB   rD   Ztorch.nnnnr   Ztorch._functorch.vmapr   r   r   r   r   strr(   boolr-   r/   r0   r5   inttupler8   r;   r<   r?   ModulerE   rF   r   r   r   r   <module>   s   	


    
   
 