o
    ߗiZ                     @   s  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 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Tuple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   Y/home/ubuntu/transcripts/venv/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   r0   r4   r)   r1   r2   r   r   r   r4   F      r4   c                 C   r3   )Ngrad_and_value)r   r0   r7   r5   r   r   r   r7   K   s   r7   )r2   c                G   s    t d tj| g|R d|iS )Nvjpr2   )r   r   r8   )r)   r2   primalsr   r   r   r8   R   s   r8   strictr2   r9   tangentsr;   c                C      t d tj| ||||dS )Njvpr:   )r   r   r>   )r)   r9   r<   r;   r2   r   r   r   r>   W   s   r>   r2   r(   _preallocate_and_copyr(   c                C   r=   )Njacrevr?   )r   r   rA   )r)   r1   r2   r(   r@   r   r   r   rA   c   s   rA   r,   c                C   s   t d tj| |||dS )NjacfwdrB   )r   r   rC   )r)   r1   r2   r,   r   r   r   rC   u   s   rC   c                 C      t d tj| |dS )Nhessian)r1   )r   r   rE   )r)   r1   r   r   r   rE      r6   rE   	mutationsremoverH   c                C   rD   )NfunctionalizerG   )r   r   rI   )r)   rH   r   r   r   rI      r6   rI   modeldisable_autograd_trackingc                 C      t dd t| |S )Nmake_functionaltorch.func.functional_call)r   _nn_implrM   rJ   rK   r   r   r   rM      s   
rM   c                 C   rL   )Nmake_functional_with_buffersrN   )r   rO   rQ   rP   r   r   r   rQ      s   
rQ   c                 C   s   t dd t| S )Ncombine_state_for_ensembletorch.func.stack_module_state)r   rO   rR   )modelsr   r   r   rR      s   

rR   r/   rN   rS   )NF)N)NN)r   r   r&   )r   F)r   )F)*r   r   r   typingr   r   r   r   r   torch._functorch.apis
_functorchr0   !torch._functorch.eager_transformseager_transformsr    torch._functorch.make_functionalrM   rO   torch.nnnnr   torch._functorch.vmapr   r	   r   r   r%   strr.   boolr4   r7   r8   r>   intrA   rC   rE   rI   ModulerQ   rR   r   r   r   r   <module>   s   	









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