U
    zhZ                     @   sJ  d Z ddlZddlZddlmZ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TupleUnion)	argnums_t)	in_dims_t
out_dims_tFc                 C   s8   |d k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   M/var/www/html/venv/lib/python3.8/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 krtt|}|jd k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+   r0   r/   r   r   r   r0   K   s    r0   )r-   )r$   r-   c                G   s   t d tj| f|d|iS )Nvjpr-   )r   r   r1   )r$   r-   primalsr   r   r   r1   R   s    r1   strictr-   r$   r2   Ztangentsr4   r-   c                C   s   t d tj| ||||dS )Njvpr3   )r   r   r6   r5   r   r   r   r6   W   s    r6   r-   r#   _preallocate_and_copy)r$   r,   r#   c                C   s   t d tj| ||||dS )Njacrevr7   )r   r   r9   )r$   r,   r-   r#   r8   r   r   r   r9   c   s    r9   r'   r$   r,   r-   r'   c                C   s   t d tj| |||dS )Njacfwdr:   )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_implrC   rA   r   r   r   rC      s    
rC   c                 C   s   t dd t| |S )Nmake_functional_with_buffersrD   )r   rE   rF   rA   r   r   r   rF      s    
rF   c                 C   s   t dd t| S )Ncombine_state_for_ensembletorch.func.stack_module_state)r   rE   rG   )modelsr   r   r   rG      s    
rG   r*   rD   rH   )NF)N)NN)r   r   r!   )r   F)r   F)r   )r   F)r   )F)F)*r   r   r   typingr   r   r   r   r   Ztorch._functorch.apisZ
_functorchr+   Z!torch._functorch.eager_transformsZeager_transformsr   Z torch._functorch.make_functionalrC   rE   Ztorch.nnnnr   Ztorch._functorch.vmapr   r	   r   r   r    strr)   boolr.   r0   r1   r6   intr9   r<   r=   r@   ModulerF   rG   r   r   r   r   <module>   s   	


        
   
    