
    9jc                    ^   d Z ddlmZ ddlZddlZddlmZmZ ddlm	c m
Z
 ddlm	c mZ ddlm	c mZ ddlmZ er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	 	 	 d)dd	 	 	 	 	 	 	 	 	 	 	 d*dZ	 d+	 	 	 	 	 	 	 d,dZ	 d+	 	 	 	 	 	 	 d,dZddd-dZddd	 	 	 	 	 	 	 	 	 	 	 d.dZ 	 d/dddd	 	 	 	 	 	 	 	 	 	 	 d0dZ!	 	 d+dd	 	 	 	 	 	 	 	 	 d1dZ"d/d2dZ#dd	 	 	 	 	 d3dZ$d4d5dZ	 d4	 	 	 	 	 d5dZ%d6dZ& eee
j8                  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jL                  d"       y)7a$  
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.
    )annotationsN)AnyTYPE_CHECKING)Callable)	argnums_t)	in_dims_t
out_dims_tFc                N    |d|  }d|  d| d}|r|j                  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warnings       [/media/conek/DATA/Code/OCR/venv/lib/python3.12/site-packages/torch/_functorch/deprecated.pyget_warningr      sR     u%##&% (i  <	=  //$+N    c                X    t        | |d      }t        j                  |t        d       y )NT)r      )
stacklevel)r   warningswarnFutureWarning)r   r   r   s      r   warn_deprecatedr   /   s     #w>GMM'=Q7r   c                    | j                   }|t        t        |      }|j                  y t	        ||      }dt        j                  |d      z   }t        j                  |d      }|j                  |z   | _        y )Nz
.. warning::

z    )__name__getattr_impl__doc__r   textwrapindent)functorch_apitorch_func_apinew_api_nameapi_namer   warning_notes         r   
setup_docsr(   4   st    
 %%H 1%(L1G'(//'6*JJL??<8L*22\AMr   error
chunk_sizec               N    t        dd       t        j                  | ||||      S )Nvmap
torch.vmapr*   )r   apisr-   )funcin_dimsout_dims
randomnessr+   s        r   r-   r-   F   s%     FL)99T7HjZPPr   c                F    t        d       t        j                  | ||      S )Ngrad)r   r/   r5   r0   argnumshas_auxs      r   r5   r5   R   s     F99T7G,,r   c                F    t        d       t        j                  | ||      S )Ngrad_and_value)r   r/   r:   r6   s      r   r:   r:   Y   s"     $%tWg66r   )r8   c               J    t        d       t        j                  | g|d|iS )Nvjpr8   )r   r   r<   )r0   r8   primalss      r   r<   r<   `   s#    E99T5G5W55r   strictr8   c               L    t        d       t        j                  | ||||      S )Njvpr>   )r   r   rA   )r0   r=   tangentsr?   r8   s        r   rA   rA   e   s#     E99T7HVWMMr   r8   r+   _preallocate_and_copyc               L    t        d       t        j                  | ||||      S )NjacrevrC   )r   r   rF   )r0   r7   r8   r+   rD   s        r   rF   rF   q   s,     H<<3 r   r3   c               J    t        d       t        j                  | |||      S )NjacfwdrG   )r   r   rI   )r0   r7   r8   r3   s       r   rI   rI      s!     H<<gw:FFr   c                F    t        d       t        j                  | |      S )Nhessian)r7   )r   r   rK   )r0   r7   s     r   rK   rK      s    I==w//r   	mutationsremovec               F    t        d       t        j                  | |      S )NfunctionalizerM   )r   r   rP   )r0   rN   s     r   rP   rP      s     O$tF33r   c                F    t        dd       t        j                  | |      S )Nmake_functionaltorch.func.functional_call)r   _nn_implrR   modeldisable_autograd_trackings     r   rR   rR      s"    %'CD##E+DEEr   c                F    t        dd       t        j                  | |      S )Nmake_functional_with_buffersrS   )r   rT   rY   rU   s     r   rY   rY      s$     24PQ008QRRr   c                D    t        dd       t        j                  |       S )Ncombine_state_for_ensembletorch.func.stack_module_state)r   rT   r[   )modelss    r   r[   r[      s    02QR..v66r   r.   rS   r\   )NF)r   strr   
str | Noner   boolreturnr^   )N)r   r^   r   r_   ra   None)NN)r#   Callable[..., Any]r$   zCallable[..., Any] | Noner%   r_   ra   rb   )r   r   r)   )r0   rc   r1   r   r2   r	   r3   r^   r+   
int | Nonera   rc   )r   F)r0   rc   r7   r   r8   r`   ra   rc   )r0   rc   r=   r   r8   r`   ra   r   )r0   rc   r=   r   rB   r   r?   r`   r8   r`   ra   r   )r   )r0   rc   r7   zint | tuple[int, ...]r8   r`   r+   rd   rD   r`   ra   rc   )
r0   rc   r7   r   r8   r`   r3   r^   ra   rc   )r0   rc   r7   intra   rc   )r0   rc   rN   r^   ra   rc   )F)rV   z	nn.ModulerW   r`   ra   r   )r]   zlist[nn.Module]ra   r   )'r    
__future__r   r!   r   typingr   r   torch._functorch.apis
_functorchr/   !torch._functorch.eager_transformseager_transformsr    torch._functorch.make_functionalrR   rT   torch.nnnncollections.abcr   r   torch._functorch.vmapr   r	   r   r   r(   r-   r5   r:   r<   rA   rF   rI   rK   rP   rY   r[    r   r   <module>rr      sB   #   % $ $ 1 1 3 3  (;; DI	!<@$8 15#B%B-B B 
	B( 		Q "	Q
	Q	Q 	Q 		Q 	Q 	Q GL-
-'0-?C-- GL7
7'07?C77 BG 6 	N
	N	N 	N
 	N 	N 		N &' !"'
" 	
    ( G
 G
GG G
 G G0 0;4
4),44F 9>SS15SS7
 4L ) 
4  
>4.. / 
3 
3 
6  
6  
7  
=  
?H446R S 
 (":":<X ''#r   