§
    ŠŠtj2  ã                   óB   — d dl Z d dlmZ d dlmZ  G d„ de¦  «        ZdS )é    N)ÚProxyTorchDispatchMode)ÚTorchFunctionModec                   ó   — e Zd ZdZdd„ZdS )ÚAutogradStateOpsFailSafeguarda  
    Detect grad state ops during exporting the graph and fail the process by
    raising an error, to avoid unexpected behavior. Those grad mode ops could be:
    `torch.no_grad`
    `torch.enable_grad`
    `torch.set_grad_enabled`

    Export with predispatch mode is exempted.
    © Nc                 óÊ  — |pi }t           j        j        g}t           j                             ¦   «         }||v r¤t	          |¦  «        dk    rt          dt	          |¦  «        › �¦  «        ‚|d         }t           j                             t           j        j        j        ¦  «        }|r5t          |t          ¦  «        r |j        s||k    rt          d|› d�¦  «        ‚ ||i |¤ŽS )Né   z6Expected exactly 1 argument for grad mode op, but got r   z&Encountered autograd state manager op zÿ trying to change global autograd state while exporting. This is unsafe because we don't capture this op in torch.export today, hence we can't reflect the user intention soundly. You can fix this by adding a torch.no_grad() context around the export call.)ÚtorchÚ_CÚ_set_grad_enabledÚis_grad_enabledÚlenÚAssertionErrorÚ_get_dispatch_modeÚ_TorchDispatchModeKeyÚPROXYÚ
isinstancer   Úpre_dispatchÚRuntimeError)	ÚselfÚfuncÚtypesÚargsÚkwargsÚunsupported_grad_mode_opsÚcurrent_stateÚchanged_stateÚmodes	            úU/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/torch/export/_safeguard.pyÚ__torch_function__z0AutogradStateOpsFailSafeguard.__torch_function__   s  € Ø�˜2ˆåŒHÔ&ð%
Ð!õ
 œ×0Ò0Ñ2Ô2ˆØÐ,Ð,Ð,Ý�4‰yŒy˜AŠ~ˆ~Ý$ØXÍSÐQUÉYÌYÐXÐXñô ð ð ! œGˆMÝ”8×.Ò.­u¬xÔ/MÔ/SÑTÔTˆDð ðå˜tÕ%;Ñ<Ô<ðð Ô)ðð " ]Ò2Ð2å"ðO¸Tð Oð Oð Oñô ð ð ˆt�TÐ$˜VÐ$Ð$Ð$ó    )r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r    r   r!   r   r   r      s2   € € € € € ðð ð%ð %ð %ð %ð %ð %r!   r   )r
   Ú"torch.fx.experimental.proxy_tensorr   Útorch.overridesr   r   r   r!   r   ú<module>r(      sg   ðà €€€Ø EÐ EÐ EÐ EÐ EÐ EØ -Ð -Ð -Ð -Ð -Ð -ð(%ð (%ð (%ð (%ð (%Ð$5ñ (%ô (%ð (%ð (%ð (%r!   