§
    �Štj‹š  ã                  ón  — d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ d dl	m
Z
mZmZmZ d dlmZ d dl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Z erd d	lmZmZ d d
lmZ da da!da"d@dAd„Z#dBd„Z$dBd„Z% G d„ d¦  «        Z&dCd„Z'd„ Z(d„ Z)d„ Z*dDd„Z+dEd„Z,dFdGd!„Z-ej.        dFdHd#„¦   «         Z/ej.        d$„ ¦   «         Z0 G d%„ d&e&¦  «        Z1 G d'„ d(e¦  «        Z2e2Z3dId+„Z4dJd-„Z5dKd0„Z6dLd1„Z7dMd2„Z8dNd4„Z9e G d5„ d6¦  «        ¦   «         Z:e G d7„ d8¦  «        ¦   «         Z;ej<        dOd9„¦   «         Z=dPd>„Z>d?„ Z?dS )Qé    )ÚannotationsN)Údeque)Ú	dataclass)ÚcastÚoverloadÚProtocolÚTYPE_CHECKING)ÚTypeIs)Ú_get_dispatch_stack_atÚ_len_torch_dispatch_stackÚ_pop_torch_dispatch_stackÚ_push_on_torch_dispatch_stackÚDispatchKey)Ú/set_is_in_mode_without_ignore_compile_internals)ÚMappingÚSequence)Ú
OpaqueBaseFTÚinclude_infra_modesÚboolÚreturnc                ó"   — | rt           nt          S ©N)Ú_is_in_torch_dispatch_modeÚ$_is_in_non_infra_torch_dispatch_mode)r   s    úZ/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/torch/utils/_python_dispatch.pyÚis_in_torch_dispatch_moder   +   s   € ð ð	2Õ"Ð"å1ðó    c                 ó   — t           S r   )Ú0_is_in_any_mode_without_ignore_compile_internals© r   r   Ú/is_in_any_mode_without_ignore_compile_internalsr!   3   s   € Ý;Ð;r   c                 óÜ   — t           j                             ¦   «         } t          | ¦  «        D ]=}t	          |¦  «        }|                     ¦   «         rŒ&|                     ¦   «         rŒ; dS dS )NTF)ÚtorchÚ_Cr   Úranger   Úis_infra_modeÚignore_compile_internals)Ú	stack_lenÚidxÚmodes      r   Ú any_torch_dispatch_mode_on_stackr+   7   su   € Ý”×2Ò2Ñ4Ô4€Iå�YÑÔð 
ð 
ˆÝ% cÑ*Ô*ˆð ×ÒÑÔð 	Øà×(Ò(Ñ*Ô*ð 	ØàˆtˆtØˆ5r   c                  ó¦   ‡ — e Zd ZdZdZˆ fd„Zdd„Zd„ Zdd„Zd	„ Z	d
„ Z
ed„ ¦   «         Zedd„¦   «         Zedd„¦   «         Zedd„¦   «         Zˆ xZS )ÚTorchDispatchModeaé  
    A ``TorchDispatchMode`` allows you to override the meaning of all
    ``__torch_dispatch__`` overridable functions within a dynamic scope,
    without having to actually create a tensor subclass or manually
    monkey-patch functions in the PyTorch API.  Some common situations
    where you should use a mode:

        * You want to override the meaning of factory functions, or other
          functions that do not otherwise take a tensor as an argument
          (these cannot be overridden with tensor subclasses).

        * You want to override the behavior of all functions without needing
          to wrap your inputs in tensor subclasses; e.g., if you are just
          interested in logging intermediate computations.

        * You want to control the order of execution of various tensor
          subclasses explicitly, rather than implicitly via the return of
          ``NotImplemented``.

    Independent subclasses of :class:`TorchDispatchMode` are compositional:
    modes can be pushed onto a stack using ``with MyMode():``.
    When you call functions in the PyTorch API inside your
    ``__torch_dispatch__`` implementation, by default, they will forward on to
    the next mode on the mode stack.  If you want recursively call back into
    your current ``__torch_dispatch__`` implementation, either explicitly
    invoke ``self.__torch_dispatch__(...)``, or use the context manager
    ``self`` to make PyTorch
    API self-referential (beware of infinite loops, in this case!)
    Fc                óú   •—  t          ¦   «         j        di |¤Ž |                      ¦   «         rHd| j        v rA| j        d         }t	          |t
          ¦  «        s!t          j        |d¬¦  «        | _        d S d S d S d S )NÚ__torch_dispatch__T)Ú	recursiver    )	ÚsuperÚ__init_subclass__Ú_should_skip_dynamoÚ__dict__Ú
isinstanceÚclassmethodr#   Ú_disable_dynamor/   )ÚclsÚkwargsÚrawÚ	__class__s      €r   r2   z#TorchDispatchMode.__init_subclass__m   sŸ   ø€ Ø!�‰ŒÔ!Ð+Ð+ FÐ+Ð+Ð+Ø×"Ò"Ñ$Ô$ð 	XØ# s¤|Ð3Ð3Ø”lÐ#7Ô8�Ý! #¥{Ñ3Ô3ð XÝ-2Ô-BÀ3ÐRVÐ-WÑ-WÔ-W�CÔ*Ð*Ð*ð		Xð 	XØ3Ð3ðXð Xr   Nc                óì   — |�8t          |t          j        j        ¦  «        st	          d¦  «        ‚|| j        d<   t          ¦   «         | _        t          ¦   «         | _        t          ¦   «         | _	        d S )Nz,_dispatch_key must be a torch._C.DispatchKeyÚ_dispatch_key)
r5   r#   r$   r   ÚAssertionErrorr4   r   Úold_dispatch_mode_flagsÚ!old_non_infra_dispatch_mode_flagsÚ8old_without_ignore_compile_internals_dispatch_mode_flags)Úselfr=   s     r   Ú__init__zTorchDispatchMode.__init__u   sh   € ØÐ$Ý˜m­U¬XÔ-AÑBÔBð UÝ$Ð%SÑTÔTÐTØ-:ˆDŒM˜/Ñ*å49±G´GˆÔ$Ý>C¹g¼gˆÔ.å‰GŒGð 	ÔEÐEÐEr   c                óÜ   — t          | d¦  «        st          ¦   «         | _        t          | d¦  «        st          ¦   «         | _        t          | d¦  «        st          ¦   «         | _        d S d S )Nr?   r@   rA   )Úhasattrr   r?   r@   rA   ©rB   s    r   Ú"_lazy_init_old_dispatch_mode_flagsz4TorchDispatchMode._lazy_init_old_dispatch_mode_flags�   s{   € Ý�tÐ6Ñ7Ô7ð 	@Ý8=¹¼ˆDÔ(å�tÐ@ÑAÔAð 	JÝBGÁ'Ä'ˆDÔ2åØÐLñ
ô 
ð 	õ
 ‘”ð ÔIÐIÐIð	ð 	r   r    c                ó   — t           ‚r   )ÚNotImplementedError©rB   ÚfuncÚtypesÚargsr9   s        r   r/   z$TorchDispatchMode.__torch_dispatch__�   s   € Ý!Ð!r   c                ó¢  — |                       ¦   «          | j                             t          ¦  «         da| j                             t
          ¦  «         t
          p|                      ¦   «          a| j                             t          ¦  «         t          p|  	                    ¦   «          at          t          ¦  «         t          | ¦  «         | S )NT)rG   r?   Úappendr   r@   r   r&   rA   r   r'   r   Ú
_push_moderF   s    r   Ú	__enter__zTorchDispatchMode.__enter__’   sÝ   € ð 	×/Ò/Ñ1Ô1Ð1ØÔ$×+Ò+Õ,FÑGÔGÐGØ%)Ð"ØÔ.×5Ò5Ý0ñ	
ô 	
ð 	
õ 1ÐL¸×8JÒ8JÑ8LÔ8LÐ4Lð 	-ð 	ÔE×LÒLÝ<ñ	
ô 	
ð 	
õ =ð 3Ø×0Ò0Ñ2Ô2Ð2ð 	9õ 	8Ý<ñ	
ô 	
ð 	
õ 	�4ÑÔÐØˆr   c                óR  — | j                              dd ¦  «        }|€| j                              dd ¦  «        }| j                             ¦   «         a| j                             ¦   «         a| j                             ¦   «         at          t          ¦  «         t          |¦  «         d S )Nr=   Ú	_mode_key)r4   Úgetr?   Úpopr   r@   r   rA   r   r   Ú	_pop_mode)rB   Úexc_typeÚexc_valÚexc_tbÚmb_dk_or_mode_keys        r   Ú__exit__zTorchDispatchMode.__exit__±   s¯   € Ø œM×-Ò-¨o¸tÑDÔDÐØÐ$ð !%¤× 1Ò 1°+¸tÑ DÔ DÐà%)Ô%A×%EÒ%EÑ%GÔ%GÐ"ð Ô2×6Ò6Ñ8Ô8ð 	-ð
 ÔI×MÒMÑOÔOð 	9õ 	8Ý<ñ	
ô 	
ð 	
õ 	Ð#Ñ$Ô$Ð$Ð$Ð$r   c                óB   — t          j        dd¬¦  «          | |i |¤Ž}|S )NzP`Mode.push()` is no longer necessary and can be replaced with just `with Mode()`é   )Ú
stacklevel)ÚwarningsÚwarn)r8   rM   r9   Úinstances       r   ÚpushzTorchDispatchMode.pushÆ   s<   € åŒØ^Øð	
ñ 	
ô 	
ð 	
ð �3˜Ð' Ð'Ð'ˆØˆr   r   r   c                ó   — dS )NFr    ©r8   s    r   r&   zTorchDispatchMode.is_infra_modeÏ   s   € àˆur   c                ó   — dS )a  Skip Dynamo when the flag is set to True

        This is temporary measure to rollout a feature
        that skips PT2 compilation inside __torch_dispatch__
        frames.

        If this flag is off, we would expect following:

        class YoloMode(TorchDispatchMode):
            @classmethod
            def _should_skip_dynamo(cls):
                return False
            def __torch_dispatch__(self, func, types, args=(), kwargs=None):
                return torch.ops.aten.mul.Tensor(args[0], args[1])

        x = torch.ones(5)
        with YoloMode():
            out = torch.compile(torch.add, backend=backend, fullgraph=True)(x, x)

        # instead of recursively disabling, we are compiling into __torch_dispatch__
        assert len(backend.graphs) == 1
        Tr    rd   s    r   r3   z%TorchDispatchMode._should_skip_dynamoÓ   s	   € ð0 ˆtr   c                ó2   — |                       ¦   «         rdS dS )a9  Ignore operators that are compiled via torch.compile.

        If ``True``, then this TorchDispatchMode ignores operators that
        are optimized by :func:`torch.compile`. Mechanically, this involves
        turning off the TorchDispatchMode throughout the whole compilation process,
        and turning it back on for the runtime of the compiled artifact(s).
        For example,

        @torch.compile
        def f(x):
            return x.sin().cos()

        with LoggingMode():
            f(x)

        The above example will not log anything if
        ``LoggingMode.ignore_compile_internals()`` is True.
        torch.compile will fuse sin() and cos() into a single operation
        and this TorchDispatchMode will not be passed sin and cos.

        If ``False`` (default), :func:`torch.compile` will respect
        the eager semantics of passing this TorchDispatchMode all
        operators that would have run during eager execution.
        The way this will usually happen is that :func:`torch.compile`
        will just fallback to eager-mode PyTorch.
        TF)r&   rd   s    r   r'   z*TorchDispatchMode.ignore_compile_internalsí   s"   € ð8 ×ÒÑÔð 	Ø�4Øˆur   r   ©r    N©r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úsupports_higher_order_operatorsr2   rC   rG   r/   rQ   r[   r6   rb   r&   r3   r'   Ú__classcell__)r;   s   @r   r-   r-   H   s   ø€ € € € € ðð ðD ',Ð#ðXð Xð Xð Xð Xð

ð 

ð 

ð 

ðð ð ð"ð "ð "ð "ðð ð ð>%ð %ð %ð* ðð ñ „[ðð ðð ð ñ „[ðð ðð ð ñ „[ðð2 ðð ð ñ „[ðð ð ð ð r   r-   úTorchDispatchMode | Nonec                 óR   — t          ¦   «         } | dk    rt          | dz
  ¦  «        S dS )zk
    Return the top user mode on the stack (the next one that would be
    executed) if there are any.
    r   é   N)r   r   ©r(   s    r   Ú_get_current_dispatch_moders     s/   € õ
 *Ñ+Ô+€IØ�1‚}€}Ý% i°!¡mÑ4Ô4Ð4Øˆ4r   c                óp  — | t           j        j        j        t           j        j        j        fvr@t          dt           j        j        j        › dt           j        j        j        › d| › �¦  «        ‚ddlm}  || ¦  «        }t           j                             | ¦  «        }|�|�t          d¦  «        ‚|€|S |S )Nzkey must be either FUNCTIONAL (z)                 or PROXY (z1) _TorchDispatchModeKey,                     got r   )Ú_get_dispatch_mode_pre_dispatchzEAt most one of pre_dispatch_mode and post_dispatch_mode may be active)	r#   r$   Ú_TorchDispatchModeKeyÚ
FUNCTIONALÚPROXYr>   Ú
torch._opsru   Ú_get_dispatch_mode)Úkeyru   Úpre_dispatch_modeÚpost_dispatch_modes       r   Ú_detect_infra_moder~     sé   € Ø
ÝŒÔ&Ô1ÝŒÔ&Ô,ðð ð õ ð­e¬hÔ.LÔ.Wð ð Ý œ8Ô9Ô?ðð àðð ñ
ô 
ð 	
ð
 ;Ð:Ð:Ð:Ð:Ð:à7Ð7¸Ñ<Ô<ÐÝœ×4Ò4°SÑ9Ô9ÐàÐ$Ð);Ð)GÝØSñ
ô 
ð 	
ð Ð Ø!Ð!àÐr   c                óð   — ddl m}m}  || ¦  «        }t          j                             | ¦  «        }|r|rt          d¦  «        ‚|r || ¦  «        }|S |rt          j                             | ¦  «        S d S )Nr   )ru   Úunset_mode_pre_dispatchzECan't have active infra mode on both pre and post dispatch mode stack)ry   ru   r€   r#   r$   rz   r>   Ú_unset_dispatch_mode)r{   ru   r€   r|   r}   r*   s         r   Ú_unset_infra_moder‚   3  s­   € ØSÐSÐSÐSÐSÐSÐSÐSà7Ð7¸Ñ<Ô<ÐÝœ×4Ò4°SÑ9Ô9ÐØð 
Ð/ð 
ÝØSñ
ô 
ð 	
ð ð Ø&Ð& sÑ+Ô+ˆØˆØð 2ÝŒx×,Ò,¨SÑ1Ô1Ð1ð2ð 2r   c              #  ó   K  — | t           j        j        j        t           j        j        j        fvrt          d¦  «        ‚t          | ¦  «        }	 |V — |�t          |¦  «         d S d S # |�t          |¦  «         w w xY w)Nz<key must be either FUNCTIONAL or PROXY _TorchDispatchModeKey)r#   r$   rv   rw   rx   r>   r‚   rP   )r{   Ú
mode_unsets     r   Ú_disable_infra_moder…   D  s¦   è è € Ø
ÝŒÔ&Ô1ÝŒÔ&Ô,ðð ð õ ØJñ
ô 
ð 	
õ # 3Ñ'Ô'€Jð#ØÐÐÐàÐ!Ý�zÑ"Ô"Ð"Ð"Ð"ð "Ð!øˆ:Ð!Ý�zÑ"Ô"Ð"Ð"ð "øøøs   ÁA) Á)A=úlist[TorchDispatchMode]c                 óP   — t          ¦   «         } d„ t          | ¦  «        D ¦   «         S )z´
    Returns the current stack of dispatch modes, with the most recent
    (i.e., the one that will be processed first) at the end of the
    list (standard stack convention).
    c                ó,   — g | ]}t          |¦  «        ‘ŒS r    )r   )Ú.0Úis     r   ú
<listcomp>z4_get_current_dispatch_mode_stack.<locals>.<listcomp>[  s!   € Ð@Ð@Ð@¨!Õ" 1Ñ%Ô%Ð@Ð@Ð@r   )r   r%   rr   s    r   Ú _get_current_dispatch_mode_stackrŒ   T  s+   € õ *Ñ+Ô+€IØ@Ð@­u°YÑ/?Ô/?Ð@Ñ@Ô@Ð@r   r*   ÚNonec                óf  — t          | d¦  «        r| j        nd }|�)|t          j        j        j        k    rt          d¦  «        ‚|€t          | ¦  «         d S ddlm	}m
} t          j                             |¦  «        } |¦   «         D ]}|D ]}|                     |¦  «         ŒŒ || ¦  «         d S )Nr=   z:mode._dispatch_key must be None or DispatchKey.PreDispatchr   )Ú_set_mode_pre_dispatchÚget_cached_ops)rE   r=   r#   r$   r   ÚPreDispatchr>   r   ry   r�   r�   Ú_functionality_to_backend_keysÚ_uncache_dispatch)r*   Úkr�   r�   ÚksÚopr{   s          r   rP   rP   ^  sì   € Ý% d¨OÑ<Ô<ÐFˆÔÐÀ$€AØ€}˜�eœhÔ2Ô>Ò>Ð>ÝØHñ
ô 
ð 	
ð 	€yÝ% dÑ+Ô+Ð+ØˆàAÐAÐAÐAÐAÐAÐAÐAõ 
Œ×	0Ò	0°Ñ	3Ô	3€BØˆnÑÔð &ð &ˆØð 	&ð 	&ˆCØ× Ò  Ñ%Ô%Ð%Ð%ð	&àÐ˜4Ñ Ô Ð Ð Ð r   r”   ú3DispatchKey | torch._C._TorchDispatchModeKey | Nonec                óº   — | t           j        j        j        k    rddlm}  |¦   «         S | �t          | t           j        j        ¦  «        rt          | ¦  «        S d S )Nr   )Ú_pop_mode_from_pre_dispatch)	r#   r$   r   r‘   ry   r™   r5   rv   r   )r”   r™   s     r   rV   rV   s  sc   € Ø�EŒHÔ Ô,Ò,Ð,Ø:Ð:Ð:Ð:Ð:Ð:à*Ð*Ñ,Ô,Ð,à€y•J˜q¥%¤(Ô"@ÑAÔA€yÝ(¨Ñ+Ô+Ð+ð €yr   úDispatchKey | Nonec              #  óx   K  — t          | ¦  «        }	 |V — t          |¦  «         d S # t          |¦  «         w xY wr   )rV   rP   )r”   Úolds     r   Ú_pop_mode_temporarilyr�   }  s>   è è € å
�A‰,Œ,€CðØˆ	ˆ	ˆ	å�3‰Œˆˆˆø�
�3‰Œˆˆøøøs   “( ¨9c               #  óL  ‡K  — ddl m} mŠ ddlm} ddlm} ddlm}  | ¦   «         }ˆfd„t          |¦  «        D ¦   «         }d}d}d}|D ]8}	t          |	|¦  «        rd}t          |	|¦  «        rd}t          |	|¦  «        rd}Œ9t          ¦   «         }
d	„ t          |
¦  «        D ¦   «         }|D ]e}t          ||¦  «        r|rt          d
¦  «        ‚t          ||¦  «        r|rt          d¦  «        ‚t          ||¦  «        r|rt          d¦  «        ‚Œf	 ||z   V — t          |¦  «        D ]}t          |¦  «         Œt          |¦  «        D ]}t          |¦  «         Œd S # t          |¦  «        D ]}t          |¦  «         Œt          |¦  «        D ]}t          |¦  «         Œw xY w)Nr   )Ú&_len_torch_dispatch_stack_pre_dispatchr™   )ÚFunctionalTensorMode)ÚSchemaCheckMode)ÚProxyTorchDispatchModec                ó$   •— g | ]} ‰¦   «         ‘ŒS r    r    )r‰   Ú_r™   s     €r   r‹   z*_disable_current_modes.<locals>.<listcomp>‘  s0   ø€ ð ð ð Ø*+Ð#Ð#Ñ%Ô%ðð ð r   FTc                ó*   — g | ]}t          ¦   «         ‘ŒS r    )rV   )r‰   r¤   s     r   r‹   z*_disable_current_modes.<locals>.<listcomp>¢  s   € Ð6Ð6Ð6 •‘”Ð6Ð6Ð6r   zFCan't have FunctionalMode available both in PreDispatch and Python KeyzNCan't have ProxyTorchDispatchMode available both in PreDispatch and Python KeyzGCan't have SchemaCheckMode available both in PreDispatch and Python Key)ry   rŸ   r™   Ú#torch._subclasses.functional_tensorr    Ú#torch._subclasses.schema_check_moder¡   Ú"torch.fx.experimental.proxy_tensorr¢   r%   r5   r   r>   ÚreversedrP   )rŸ   r    r¡   r¢   Úmode_len_pre_dispatchÚold_pre_dispatch_modesÚhas_proxy_mode_in_pre_dispatchÚ#has_functional_mode_in_pre_dispatchÚ%has_schema_check_mode_in_pre_dispatchrŠ   Úmode_lenÚ	old_modesrœ   r*   r™   s                 @r   Ú_disable_current_modesr±   †  s­  øè è € ðð ð ð ð ð ð ð ð IÐHÐHÐHÐHÐHØCÐCÐCÐCÐCÐCØIÐIÐIÐIÐIÐIàBÐBÑDÔDÐðð ð ð Ý/4Ð5JÑ/KÔ/Kðñ ô Ðð &+Ð"Ø*/Ð'Ø,1Ð)à#ð 9ð 9ˆÝ�aÐ/Ñ0Ô0ð 	2Ø-1Ð*Ý�aÐ-Ñ.Ô.ð 	7Ø26Ð/Ý�a˜Ñ)Ô)ð 	9Ø48Ð1øå(Ñ*Ô*€HØ6Ð6¥e¨H¡o¤oÐ6Ñ6Ô6€Iàð ð ˆå�sÐ0Ñ1Ô1ð	à3ð	õ !ØXñô ð õ �cÐ1Ñ2Ô2ð 	Ð7Uð 	Ý Ø`ñô ð õ �c˜?Ñ+Ô+ð 	Ð0Uð 	Ý ØYñô ð øð
Ø$ yÑ0Ð0Ð0Ð0å˜YÑ'Ô'ð 	ð 	ˆDÝ�tÑÔÐÐÝÐ3Ñ4Ô4ð 	ð 	ˆDÝ�tÑÔÐÐð	ð 	øõ ˜YÑ'Ô'ð 	ð 	ˆDÝ�tÑÔÐÐÝÐ3Ñ4Ô4ð 	ð 	ˆDÝ�tÑÔÐÐð	øøøs   ÄE ÅAF#c                  ó   — e Zd Zdd„ZdS )ÚBaseTorchDispatchModer    Nc                ó   — |€i } ||i |¤ŽS r   r    rJ   s        r   r/   z(BaseTorchDispatchMode.__torch_dispatch__À  s!   € Øˆ>ØˆFØˆt�TÐ$˜VÐ$Ð$Ð$r   rg   )ri   rj   rk   r/   r    r   r   r³   r³   ¿  s(   € € € € € ð%ð %ð %ð %ð %ð %r   r³   c                  ó"  — e Zd ZU dZd+d„Zed,d„¦   «         Zded<   ed-d.d„¦   «         Z	ed/d„¦   «         Z	ed-d.d„¦   «         Z
ed/d„¦   «         Z
d0d„Zd0d„Ze	 	 d1ddœd2d$„¦   «         Ze	 	 	 	 d3ddœd4d(„¦   «         Ze	 	 d1ddœd5d*„¦   «         ZdS )6ÚTraceableWrapperSubclassa”  
    Canonical protocol for wrapper tensor subclasses that PT2 can trace through.

    ``__tensor_flatten__`` must return stable attribute names for the inner
    values that participate in tracing together with any metadata needed to
    rebuild the outer subclass.

    ``__tensor_unflatten__`` must reconstruct an equivalent wrapper subclass
    instance from the flattened inner values, metadata, and requested outer
    size/stride. Callers may pass tensor attrs and registered reference-type
    opaques in ``inner_tensors``. The returned tensor is expected to preserve
    the requested outer size/stride. If ``attrs, metadata =
    x.__tensor_flatten__()``, then ``type(x).__tensor_unflatten__`` must round-
    trip from ``{name: getattr(x, name) for name in attrs}``, ``metadata``,
    ``x.size()``, and ``x.stride()`` to an equivalent instance of ``x``.

    ``__tensor_unflatten__`` may be implemented as either a ``@staticmethod``
    or a ``@classmethod``; the runtime check below intentionally uses duck
    typing to support both forms, even though static type checkers may only
    recognize the ``@staticmethod`` form as conforming to this protocol.
    r   útuple[Sequence[str], object]c                ó   — d S r   r    rF   s    r   Ú__tensor_flatten__z+TraceableWrapperSubclass.__tensor_flatten__à  ó   € € € r   Úinner_tensorsú'Mapping[str, torch.Tensor | OpaqueBase]ÚmetadataÚobjectÚ
outer_sizeúSequence[int | torch.SymInt]Úouter_strideútorch.Tensorc                ó   — d S r   r    )r»   r½   r¿   rÁ   s       r   Ú__tensor_unflatten__z-TraceableWrapperSubclass.__tensor_unflatten__â  s	   € ð �sr   ztorch._C.SizeÚshapeNÚdimr�   útuple[int, ...]c                ó   — d S r   r    ©rB   rÆ   s     r   ÚstridezTraceableWrapperSubclass.strideì  s   € Ø;>¸3r   Úintc                ó   — d S r   r    rÉ   s     r   rÊ   zTraceableWrapperSubclass.strideï  s   € Ø'* sr   c                ó   — d S r   r    rÉ   s     r   ÚsizezTraceableWrapperSubclass.sizeò  s   € Ø9<¸r   c                ó   — d S r   r    rÉ   s     r   rÎ   zTraceableWrapperSubclass.sizeõ  s   € Ø%( Sr   c                ó   — d S r   r    rF   s    r   Ústorage_offsetz'TraceableWrapperSubclass.storage_offsetø  rº   r   c                ó   — d S r   r    rF   s    r   rÆ   zTraceableWrapperSubclass.dimú  rº   r   F)Úmemory_formatÚdtypeútorch.types._dtypeÚnon_blockingr   ÚcopyrÓ   útorch.memory_format | Nonec               ó   — d S r   r    )rB   rÔ   rÖ   r×   rÓ   s        r   ÚtozTraceableWrapperSubclass.toü  ó	   € ð �sr   Údeviceú)torch._prims_common.DeviceLikeType | Noneútorch.types._dtype | Nonec               ó   — d S r   r    )rB   rÜ   rÔ   rÖ   r×   rÓ   s         r   rÚ   zTraceableWrapperSubclass.to  s	   € ð �sr   Úotherc               ó   — d S r   r    )rB   rà   rÖ   r×   rÓ   s        r   rÚ   zTraceableWrapperSubclass.to  rÛ   r   )r   r·   )
r»   r¼   r½   r¾   r¿   rÀ   rÁ   rÀ   r   rÂ   r   )rÆ   r�   r   rÇ   )rÆ   rË   r   rË   )r   rË   )FF)
rÔ   rÕ   rÖ   r   r×   r   rÓ   rØ   r   rÂ   )NNFF)rÜ   rÝ   rÔ   rÞ   rÖ   r   r×   r   rÓ   rØ   r   rÂ   )
rà   rÂ   rÖ   r   r×   r   rÓ   rØ   r   rÂ   )ri   rj   rk   rl   r¹   ÚstaticmethodrÄ   Ú__annotations__r   rÊ   rÎ   rÑ   rÆ   rÚ   r    r   r   r¶   r¶   É  sŠ  € € € € € € ðð ð, FÐEÐEÐEàðð ð ñ „\ðð ÐÐÑàØ>Ð>Ð>Ð>ñ „XØ>àØ*Ð*Ð*ñ „XØ*àØ<Ð<Ð<Ð<ñ „XØ<àØ(Ð(Ð(ñ „XØ(à(Ð(Ð(Ð(àÐÐÐàð #Øð	ð 59ðð ð ð ð ñ „Xðð ð =AØ+/Ø"Øðð 59ðð ð ð ð ñ „Xðð ð #Øð	ð 59ðð ð ð ð ñ „Xðð ð r   r¶   Útr¾   c                óB   — t          | d¦  «        ot          | d¦  «        S )Nr¹   rÄ   )rE   ©rä   s    r   Ú(_has_traceable_wrapper_subclass_protocolrç     s#   € Ý�1Ð*Ñ+Ô+ÐRµ¸Ð;QÑ0RÔ0RÐRr   ú TypeIs[TraceableWrapperSubclass]c                óŽ   — t          | t          j        ¦  «        ot          | ¦  «        t          j        u}|ot	          | ¦  «        S )aë  
    Returns whether ``t`` is a tensor subclass that matches the
    ``TraceableWrapperSubclass`` protocol at runtime.

    See ``TraceableWrapperSubclass`` for the canonical flatten/unflatten
    contract. Matching the protocol is necessary but not sufficient for full
    PT2 support: the subclass's ``__torch_dispatch__`` implementation must also
    desugar into traceable dispatcher operations and preserve aliasing semantics
    with ``return_and_correct_aliasing()`` when needed.
    )r5   r#   ÚTensorÚtyperç   )rä   Úis_subclasss     r   Úis_traceable_wrapper_subclassrí   #  s;   € õ ˜Q¥¤Ñ-Ô-ÐMµ$°q±'´'ÅÄÐ2M€KØÐFÕCÀAÑFÔFÐFr   rë   ú&TypeIs[type[TraceableWrapperSubclass]]c                óp   — t          | t          j        ¦  «        o| t          j        uot          | ¦  «        S )z@Same as above, but takes a type argument instead of an instance.)Ú
issubclassr#   rê   rç   ræ   s    r   Ú"is_traceable_wrapper_subclass_typerñ   2  s7   € õ
 	�1•e”lÑ#Ô#ð 	8Ø•U”\Ð!ð	8å4°QÑ7Ô7ðr   c           	     ó.  — |�|n|                       ¦   «         }|�|n|                      ¦   «         }|                      ¦   «         \  }}i }|D ]} ||t          | |¦  «        ¦  «        ||<   Œ t	          | ¦  «                             ||||¦  «        }|j        |k    r*t          dt	          | ¦  «        › d|› d|j        › �¦  «        ‚|                     ¦   «         |k    r7t          dt	          | ¦  «        › d|› d|                     ¦   «         › �¦  «        ‚|S )aß  
    Given a traceable, wrapper tensor subclass ``t`` that implements
    ``__torch_dispatch__`` and holds some inner tensors,
    and a callback of type ``Callable[[str, torch.Tensor], torch.Tensor]``,
    `transform_subclass` will construct a fresh instance of the wrapper tensor subclass.
    It will do so by grabbing each inner tensor attribute from the wrapper,
    passing them into ``callback`` to get a transformed tensor,
    and putting each transformed tensor into the fresh tensor subclass instance.

    Note: this function will not handle ensuring that the fresh subclass
    gets the same (autograd, and aliasing) metadata as the original tensor.
    This is generally handled in other subsystems like AOTAutograd.
    NzExpected return value from z.__tensor_unflatten__() to have shape equal to z, but got: z/__tensor_unflatten__() to have stride equal to )rÎ   rÊ   r¹   Úgetattrrë   rÄ   rÅ   r>   )	rä   Úcallbackr¿   rÁ   ÚattrsÚctxÚtransformed_tensors_dictÚattrÚsubs	            r   Útransform_subclassrú   =  sm  € ð  *Ð5��¸1¿6º6¹8¼8€JØ#/Ð#;�<�<ÀÇÂÁÄ€Là×%Ò%Ñ'Ô'�J€Eˆ3Ø!ÐØð Jð JˆØ)1¨°$½ÀÀ4Ñ8HÔ8HÑ)IÔ)IÐ  Ñ&Ð&Ý
ˆq‰'Œ'×
&Ò
&Ø  # z°<ñô €Cð „y�JÒÐÝðA­$¨q©'¬'ð Að AØ(ðAð AØ58´YðAð Añ
ô 
ð 	
ð ‡z‚z�|„|�|Ò#Ð#ÝðG­$¨q©'¬'ð Gð GØ+ðGð GØ8;¿
º
¹¼ðGð Gñ
ô 
ð 	
ð
 €Jr   c                ó¸  ‡ — t          ‰ t          j        j        ¦  «        st	          dt          |¦  «        › �¦  «        ‚t          |t          ¦  «        st	          dt          |¦  «        › �¦  «        ‚t          |t          t          f¦  «        st	          dt          |¦  «        › �¦  «        ‚dˆ fd„}|j        D ]\  }} |||         ||         ¦  «         ŒdS )	a  
    Given: an OpOverload, a SchemaInfo (cached information from torchgen about schema),
    and the inputs/outputs to the OpOverload,
    this function checks to see if func is a view operator
    (by checking if any of the outputs in the op's schema
     are immutable aliases of inputs).
    If so, this function manually aliases the storage of the output tensor
    with its corresponding input tensor alias.
    It does this by unsafely overwriting the storage field of the output tensor
    to be the same storage as the input.
    z func must be an OpOverload, got zargs must be a tuple, got z"outs must be a list or tuple, got r   r�   c                ó€  •— t          | ¦  «        }t          |¦  «        }||ur›t          |¦  «        st          |¦  «        r}t          |t          ¦  «        r|n|g}|D ]`}t          | ¦  «        t          |¦  «        ur@t	          dt          ‰¦  «        › dt          | ¦  «        › dt          |¦  «        › d�¦  «        ‚Œat          |t          ¦  «        r|D ]}t          j        || ¦  «         Œd S t          |t          j        ¦  «        st	          dt          |¦  «        › �¦  «        ‚t          j        || ¦  «         d S )NzCalled z with input of type z
and output of type z. But expected types to match.zexpected torch.Tensor, got )	rë   rñ   r5   Úlistr>   Ústrr#   Ú_functionalize_unsafe_setrê   )ÚargÚretÚarg_typeÚret_typeÚret_listÚrrK   s         €r   Úalias_non_inplace_storagez<_correct_storage_aliasing.<locals>.alias_non_inplace_storagez  sx  ø€ õ ˜‘9”9ˆÝ˜‘9”9ˆØ˜8Ð#Ð#Ý.¨xÑ8Ô8ð $å1°(Ñ;Ô;ð $õ )¨­dÑ3Ô3Ð>�s�s¸#¸ˆHØð ð �Ý˜‘9”9¥D¨¡G¤GÐ+Ð+Ý(ðX¥# d¡)¤)ð Xð XÅÀcÁÄð Xð XÝ.2°3©i¬iðXð Xð Xñô ð ð ,õ  �c�4Ñ Ô ð 	6Øð 8ð 8�ÝÔ/°°3Ñ7Ô7Ð7Ð7ð8ð 8õ ˜c¥5¤<Ñ0Ô0ð PÝ$Ð%NÅ4ÈÁ9Ä9Ð%NÐ%NÑOÔOÐOÝÔ+¨C°Ñ5Ô5Ð5Ð5Ð5r   N©r   r�   )	r5   r#   Ú_opsÚ
OpOverloadr>   rë   Útuplerý   Úread_only_alias_match_indexes)rK   Úschema_inforM   Úoutsr  Úarg_idxÚ
return_idxs   `      r   Ú_correct_storage_aliasingr  g  s  ø€ õ �d�EœJÔ1Ñ2Ô2ð NÝÐLÅÀTÁ
Ä
ÐLÐLÑMÔMÐMÝ�d�EÑ"Ô"ð HÝÐF½$¸t¹*¼*ÐFÐFÑGÔGÐGÝ�d�T¥5˜MÑ*Ô*ð PÝÐNÅ$ÀtÁ*Ä*ÐNÐNÑOÔOÐOð)6ð )6ð )6ð )6ð )6ð )6ðV  +ÔHð Cð CÑˆ�Ø!Ð! $ w¤-°°jÔ1AÑBÔBÐBÐBðCð Cr   ú
str | Nonec                ó¢   — | j         }|r| j        sd S t          |¦  «        dk    rt          d¦  «        ‚t	          t          |¦  «        ¦  «        S )Nrq   z1Expected alias_set to contain exactly one element)Ú	alias_setÚis_writeÚlenr>   ÚnextÚiter)Úxr  s     r   Ú_get_write_aliasr  ©  sU   € Ø”€IØð ˜AœJð Øˆtå
ˆ9�~„~˜ÒÐÝÐPÑQÔQÐQõ •�Y‘”Ñ Ô Ð r   c                  ó.   — e Zd ZU ded<   ded<   ded<   dS )Ú	AliasInfozset[str]r  r   r  r  ÚnameN©ri   rj   rk   rã   r    r   r   r  r  ¸  s3   € € € € € € àÐÐÑØ€N€N�NØÐÐÑÐÐr   r  c                  óB   — e Zd ZU ded<   ded<   ded<   ded<   ded	<   d
S )Ú
SchemaInfozlist[AliasInfo]rM   r  r   Úis_inplace_view_opzlist[str] | NoneÚouts_write_aliaseszlist[tuple[int, int]]r  Nr  r    r   r   r  r  ¿  sR   € € € € € € àÐÐÑØÐÐÑàÐÐÑð
 )Ð(Ð(Ñ(ð 9Ð8Ð8Ñ8Ð8Ð8r   r  c                ó8  — | j         dk    r×t          | j        ¦  «        }|                     d¦  «        st	          d¦  «        ‚|dd …         }dd l}|                     dd|¦  «        }|                     dd	|¦  «        }|                     d
d|¦  «        }t          j        j	         
                    |¦  «        }d„ |j        j        D ¦   «         }d„ |j        D ¦   «         }n,d„ | j        j        D ¦   «         }d„ | j        j        D ¦   «         }g }t          |¦  «        D ]J\  }}t          |¦  «        D ]5\  }	}
|j        |
j        z  o|j         }|r|                     ||	f¦  «         Œ6ŒKd„ |D ¦   «         }t%          d„ |D ¦   «         ¦  «        }|dk    rd }nW|t'          |¦  «        k    r$t)          dt          | j        ¦  «        z   ¦  «        ‚t+          t,          t                   |¦  «        }t/          ||t0          j        j        | j        v ||¬¦  «        }|S )NÚatenzaten::z6Expected torchgen schema string to start with 'aten::'é   r   z=\[[0, ]+\]z=0z=\[[1, ]+\]z=1z=\[(-?[0-9]+), (-?[0-9]+)\]z=[\1,\2]c                óº   — g | ]X}t          |j        €t          ¦   «         nt          |j        j        ¦  «        |j        d uo|j        j        |j        ¬¦  «        ‘ŒYS ©N)r  r  r  ©r  Ú
annotationÚsetr  r  r  ©r‰   Úas     r   r‹   z"get_alias_info.<locals>.<listcomp>ê  óq   € ð 	
ð 	
ð 	
ð õ àœ\Ð1•C‘E”E�Eµs¸1¼<Ô;QÑ7RÔ7Ràœ¨TÐ1ÐK°a´lÔ6KØ”Vðñ ô ð	
ð 	
ð 	
r   c                óº   — g | ]X}t          |j        €t          ¦   «         nt          |j        j        ¦  «        |j        d uo|j        j        |j        ¬¦  «        ‘ŒYS r&  r'  r*  s     r   r‹   z"get_alias_info.<locals>.<listcomp>ô  r,  r   c                óº   — g | ]X}t          |j        €t          ¦   «         nt          |j        j        ¦  «        |j        d uo|j        j        |j        ¬¦  «        ‘ŒYS r&  ©r  Ú
alias_infor)  Ú
before_setr  r  r*  s     r   r‹   z"get_alias_info.<locals>.<listcomp>   óq   € ð 	
ð 	
ð 	
ð õ àœ\Ð1•C‘E”E�Eµs¸1¼<Ô;RÑ7SÔ7Sàœ¨TÐ1ÐK°a´lÔ6KØ”Vðñ ô ð	
ð 	
ð 	
r   c                óº   — g | ]X}t          |j        €t          ¦   «         nt          |j        j        ¦  «        |j        d uo|j        j        |j        ¬¦  «        ‘ŒYS r&  r/  r*  s     r   r‹   z"get_alias_info.<locals>.<listcomp>
  r2  r   c                ó,   — g | ]}t          |¦  «        ‘ŒS r    )r  )r‰   r  s     r   r‹   z"get_alias_info.<locals>.<listcomp>  s.   € ð 1ð 1ð 1Ø !Õ˜ÑÔð1ð 1ð 1r   c              3  ó   K  — | ]}|d uV — Œ	d S r   r    )r‰   r  s     r   ú	<genexpr>z!get_alias_info.<locals>.<genexpr>   s&   è è € ÐCÐC a�A˜T�MÐCÐCÐCÐCÐCÐCr   zUnsupported schema: )rM   r  r   r!  r  )Ú	namespacerþ   Ú_schemaÚ
startswithr>   Úrerù   ÚtorchgenÚmodelÚFunctionSchemaÚparseÚ	argumentsÚflat_allÚreturnsÚ	enumerater  r  rO   Úsumr  ÚRuntimeErrorr   rý   r  r#   ÚTagÚinplace_viewÚtags)rK   Útorchgen_schema_strr:  Útorchgen_schemaÚarg_schemasÚout_schemasr  r  Ú
schema_argr  Ú
schema_outÚis_read_only_alias_matchÚouts_write_aliases_listÚ	non_nonesr!  r  s                   r   Úget_alias_inforQ  Ò  sÂ  € ð „~˜ÒÐÝ! $¤,Ñ/Ô/ÐØ"×-Ò-¨hÑ7Ô7ð 	Ý ØHñô ð ð
 2°!°"°"Ô5ÐØˆ	ˆ	ˆ	ð !Ÿfšf ^°TÐ;NÑOÔOÐØ Ÿfšf ^°TÐ;NÑOÔOÐà ŸfšfØ*¨KÐ9Lñ
ô 
Ðõ #œ.Ô7×=Ò=Ð>QÑRÔRˆð	
ð 	
ð %Ô.Ô7ð	
ñ 	
ô 	
ˆð	
ð 	
ð %Ô,ð	
ñ 	
ô 	
ˆˆð	
ð 	
ð ”\Ô+ð	
ñ 	
ô 	
ˆð	
ð 	
ð ”\Ô)ð	
ñ 	
ô 	
ˆð %'Ð!Ý(¨Ñ5Ô5ð Lð LÑˆ�Ý&/°Ñ&<Ô&<ð 	Lð 	LÑ"ˆJ˜
àÔ$ zÔ';Ñ;ð(*à Ô)Ð)ð %ð (ð LØ-×4Ò4°g¸zÐ5JÑKÔKÐKøð	Lð1ð 1Ø%0ð1ñ 1ô 1Ðõ ÐCÐCÐ+BÐCÑCÔCÑCÔC€IØ�A‚~€~Ø/3ÐÐØ	•cÐ1Ñ2Ô2Ò	2Ð	2åÐ1µC¸¼Ñ4EÔ4EÑEÑFÔFÐFå!¥$¥s¤)Ð-DÑEÔEÐåØØõ !œ9Ô1°T´YÐ>Ø-Ø&Cðñ ô €Kð Ðr   rK   útorch._ops.OpOverloadÚ	flat_argsúSequence[torch.Tensor | object]c                óz  — d}|D ]´}t          |t          j        ¦  «        r˜t          j                             t          j                             |j        j        ¦  «        ¦  «        }|€t          d|j        j        › �¦  «        ‚t          j         	                    |  
                    ¦   «         |¦  «        } nŒµ| S )aP  
    Suppose that an operator has CompositeImplicitAutograd decomp registered.
    Would autograd have used this decomposition?  It will only use it if there
    isn't an explicit backend registration for the device as well.  This function
    will tell if this would have occurred.

    Why do we need to apply these decompositions later?  When inference mode is
    on, the autograd key is bypassed entirely, so a lower level mode cannot rely
    on the decomposition having been applied.  It's easy to accidentally never apply
    the decomposition, resulting in an operator showing up in a graph that
    is unexpected.

    Why do we need to AVOID applying the decomposition when autograd wouldn't
    have decomposed?  If autograd doesn't decompose, this means in eager mode
    we would have run the fused kernel.  It must be possible to trace this
    fused kernel directly into the graph for fidelity with eager (NB: a user
    has the option of then further decomposing at proxy tensor mode via
    decomposition table, but we must preserve it to proxy mode to have the
    choice.)

    Why does functionalization need to also perform the test here?  This is
    because some CompositeImplicitAutograd decompositions are not functional.
    If we are eventually going to decompose, we need to do this while we can
    still turn functionalization back on, so those decompositions get functionalized.
    So an early decomposition in functionalization may still be necessary.  Note that
    if proxy tensor decomposition process could turn functionalization back on, this
    wouldn't be necessary, and maybe that is a useful thing to do anyway because
    the decomposition table is user specified and a user could violate the functional
    decomp requirement with a bad decomp.  If this happened, then you could always
    pass through functionalization.
    FNz(failed to parse dispatch key for device )r5   r#   rê   r$   Ú_parse_dispatch_keyÚ_dispatch_key_for_devicerÜ   rë   r>   Ú%_dispatch_has_kernel_for_dispatch_keyr  )rK   rS  Úhas_backend_registrationr+  Úbackend_keys        r   Úautograd_would_have_decomposedr[  5  sÃ   € ðD  %ÐØð ð ˆÝ�a�œÑ&Ô&ð 	Ýœ(×6Ò6Ý”×1Ò1°!´(´-Ñ@Ô@ñô ˆKð Ð"Ý$ØN¸q¼x¼}ÐNÐNñô ð õ (-¤x×'UÒ'UØ—	’	‘”˜[ñ(ô (Ð$ð ˆEð%	ð& (Ð'Ð'r   c           	     óŒ  ‡ ‡‡‡	‡
— t          ‰ ¦  «        Š
ˆ fd„Š	t          ‰ ‰
‰t          |t          ¦  «        s|fn|¦  «         ‰
j        �rˆ
fd„t          ‰¦  «        D ¦   «         }t          |¦  «        dk    rt          d¦  «        ‚ddlm	} t          |d         |¦  «        sÆt          j        j                             ¦   «         5  t          j                             ¦   «         }t          j                             d¦  «         	  ‰ ‰i ‰¤Ž t          j                             |¦  «         n$# t          j                             |¦  «         w xY w	 ddd¦  «         n# 1 swxY w Y   ‰
j        }|€|S t          |¦  «        dk    r ‰	|d         ‰
‰‰¦  «        S  t%          |¦  «        ˆˆ	ˆˆ
fd	„|D ¦   «         ¦  «        }|S )
aZ  
    This function should be used by wrapper tensor ``__torch_dispatch__`` subclasses
    that would like to work with torch.compile. It ensures that the subclass
    properly implements the aliasing behavior of every op,
    which is needed for correctness in AOTAutograd.
    This function will handle:

        * When we see a view op, we will alias the storages of any
          input and output tensor subclasses

        * When we see an inplace or out= op, we will directly
          return the corresponding input tensor, instead of returning
          a (potentially) fresh output tensor.
    c                óR  •‡ — t           j        j                             ‰	||¬¦  «        \  }}ˆ fd„t	          |j        ¦  «        D ¦   «         }t          |¦  «        dk    rt          d¦  «        ‚|d         }|j        |         }|j        �|j        |v r||j                 S ||         S )N)rM   r9   c                ó,   •— g | ]\  }}‰|j         v ¯|‘ŒS r    )r  )r‰   rŠ   r+  Úoutput_aliass      €r   r‹   zKreturn_and_correct_aliasing.<locals>.get_arg_from_alias.<locals>.<listcomp>ˆ  s0   ø€ ð 
ð 
ð 
Ù�!�Q¸ÈÌÐ9TÐ9TˆAÐ9TÐ9TÐ9Tr   rq   z>Expected exactly one argument index for the given output aliasr   )	r#   ÚfxÚoperator_schemasÚnormalize_functionrB  rM   r  r>   r  )
r_  r  rM   r9   Únew_argsÚ
new_kwargsÚarg_indicesr)   Úarg_inforK   s
   `        €r   Úget_arg_from_aliasz7return_and_correct_aliasing.<locals>.get_arg_from_aliasƒ  sÐ   øø€ Ý$œxÔ8×KÒKØ�t Fð  Lñ  
ô  
Ñˆ�*ð
ð 
ð 
ð 
Ý# KÔ$4Ñ5Ô5ð
ñ 
ô 
ˆõ ˆ{ÑÔ˜qÒ Ð Ý ØPñô ð ð ˜!ŒnˆØÔ# CÔ(ˆØŒ=Ð$¨¬¸*Ð)DÐ)DØ˜hœmÔ,Ð,Ø˜Œ}Ðr   c                óN   •— g | ]!\  }}t          ‰j        |         ¦  «        ®|‘Œ"S r   )r  rM   )r‰   rŠ   r  r  s      €r   r‹   z/return_and_correct_aliasing.<locals>.<listcomp>¡  s=   ø€ ð 
ð 
ð 
á��1Ý Ô 0°Ô 3Ñ4Ô4Ð@ð à@Ð@Ð@r   rq   z5expected exactly one mutated arg for inplace_view opsr   )ÚFunctionalTensorTNc                ó,   •— g | ]} ‰|‰‰‰¦  «        ‘ŒS r    r    )r‰   Úwrite_aliasrM   rg  r9   r  s     €€€€r   r‹   z/return_and_correct_aliasing.<locals>.<listcomp>Ê  s:   ø€ ð 	
ð 	
ð 	
àð  Ð ¨[¸$ÀÑGÔGð	
ð 	
ð 	
r   )rQ  r  r5   r
  r   rB  r  r>   r¦   ri  r#   ÚutilsÚ_mode_utilsÚno_dispatchr$   Ú_meta_in_tls_dispatch_includeÚ!_set_meta_in_tls_dispatch_includer!  rë   )rK   rM   r9   ÚoutÚmutated_argsri  Úmeta_in_tlsÚschema_info_outs_write_aliasesÚouts_to_returnrg  r  s   ```      @@r   Úreturn_and_correct_aliasingrv  o  s’  øøøøø€ õ$ ! Ñ&Ô&€Kðð ð ð ð õ* Øˆk˜4­z¸#½uÑ/EÔ/EÐ!N #  È3ñô ð ð Ô%ñ Lð
ð 
ð 
ð 
å! $™œð
ñ 
ô 
ˆõ ˆ|ÑÔ Ò!Ð!Ý ØGñô ð ð 	IÐHÐHÐHÐHÐHå˜, qœ/Ð+;Ñ<Ô<ð 		LÝ”Ô(×4Ò4Ñ6Ô6ð Lð Lõ $œh×DÒDÑFÔF�Ý”×:Ò:¸4Ñ@Ô@Ð@ðLØ�D˜$Ð) &Ð)Ð)Ð)å”H×>Ò>¸{ÑKÔKÐKÐKø•E”H×>Ò>¸{ÑKÔKÐKÐKøøøÐKðLð Lð Lñ Lô Lð Lð Lð Lð Lð Lð Løøøð Lð Lð Lð Lð &1Ô%CÐ"à%Ð-Øˆ
å
Ð)Ñ*Ô*¨aÒ/Ð/Ø!Ð!Ø*¨1Ô-¨{¸DÀ&ñ
ô 
ð 	
ð
 •T˜#‘Y”Yð	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
à=ð	
ñ 	
ô 	
ñô €Nð Ðs*   Ã>E ÄD/Ä E Ä/!EÅE Å E$Å'E$)T)r   r   r   r   rh   )r   ro   )r   r†   )r*   r-   r   r�   r   )r”   r—   )r”   rš   )rä   r¾   r   r   )rä   r¾   r   rè   )rä   rë   r   rî   )NNr  )r   r  )r   r  )rK   rR  rS  rT  r   r   )@Ú
__future__r   Ú
contextlibÚ	functoolsr_   Úcollectionsr   Údataclassesr   Útypingr   r   r   r	   Útyping_extensionsr
   r#   r;  Útorchgen.modelÚtorch._Cr   r   r   r   r   Útorch._C._dynamo.guardsr   Úcollections.abcr   r   Útorch._opaque_baser   r   r   r   r   r!   r+   r-   rs   r~   r‚   r…   rŒ   rP   rV   Úcontextmanagerr�   r±   r³   r¶   ÚTensorWithFlattenrç   rí   rñ   rú   r  r  r  r  ÚcacherQ  r[  rv  r    r   r   ú<module>r†     sB  ðà "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø Ð Ð Ð Ø €€€Ø Ð Ð Ð Ð Ð Ø !Ð !Ð !Ð !Ð !Ð !Ø :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ø $Ð $Ð $Ð $Ð $Ð $à €€€Ø €€€Ø Ð Ð Ð ðð ð ð ð ð ð ð ð ð ð ð ð ð ð TÐ SÐ SÐ SÐ SÐ Sð ð .Ø1Ð1Ð1Ð1Ð1Ð1Ð1Ð1à-Ð-Ð-Ð-Ð-Ð-ð #Ð Ø',Ð $à38Ð 0ðð ð ð ð ð<ð <ð <ð <ðð ð ð ð"Cð Cð Cð Cð Cñ Cô Cð CðLð ð ð ðð ð ð42ð 2ð 2ð"#ð #ð #ð Að Að Að Að!ð !ð !ð !ð*,ð ,ð ,ð ,ð ,ð Ôðð ð ð ñ Ôðð Ôð5ð 5ñ Ôð5ðp%ð %ð %ð %ð %Ð-ñ %ô %ð %ðPð Pð Pð Pð P˜xñ Pô Pð Pðf -Ð ðSð Sð Sð SðGð Gð Gð Gðð ð ð ð'ð 'ð 'ð 'ðT?Cð ?Cð ?Cð ?CðD	!ð 	!ð 	!ð 	!ð ðð ð ð ð ñ ô ñ „ðð ð9ð 9ð 9ð 9ð 9ñ 9ô 9ñ „ð9ð$ „ð_ð _ð _ñ „ð_ðD7(ð 7(ð 7(ð 7(ðt`ð `ð `ð `ð `r   