Ë
    N²j
 ã                   ó&  — U d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZmZ ddlmZmZ ddlmZmZ ddlZddlmZ ddlmZ ddlmZmZ ddlmZ dd	lmZ dd
lm Z m!Z! ddl"m#Z#m$Z$m%Z% ddl&m'Z'm(Z(m)Z)m*Z* ddl+m,Z,m-Z-m.Z.m/Z/m0Z0 ddl1m2Z2m3Z3m4Z4 ddl5m6Z6 ddl7m8Z8m9Z9m:Z: ddl;m<Z<m=Z= ddl>m?Z? ddl@mAZA  ed«      ZB e$«       aCe!ejˆ                  jŠ                  _F        e ejˆ                  jŽ                  _F        ejˆ                  jŽ                  ZGdeG_         deG_H        deG_I         e?eGd«       d„ ZJeJeG_K        e,r ej˜                  dddg«      ZMnd„ ZMdeM_         d „ ZNd!„ ZOd"„ ZP G d#„ d$«      ZQ G d%„ d&eQ«      ZR G d'„ d(eS«      ZT G d)„ d*«      ZU G d+„ d,eV«      ZWd-„ ZX G d.„ d/«      ZYd0e=d1eZd2ej¶                  jl                  fd3„Z\e,�rg d4¢Z] G d5„ d6«      Z^e]D ]  Z_d7„ Z` eae^e_e`«       Œ  G d8„ d9e6eT¬:«      Zb G d;„ d<eb«      ZcecjÈ                  jË                  «       D ]<  \  ZfZg eheg«      s
 eiegej«      sŒefj×                  d=«      s	 elebef«      rŒ3 eaebefeg«       Œ> d>„ Zmh d?£Znd@„ Zo emej¶                  jl                  «      D ]V  \  ZfZpefj×                  d=«      sefjã                  dA«      rŒ)efecjÈ                  vsŒ8efenvsŒ= eaecepj�                   eoef«      «       ŒX n4 G dB„ d6«      Z^ G dC„ d9ej¶                  jl                  «      Zb G dD„ d<eb«      ZcdE„ ZrdF„ ZsdG„ ZtdgdH„ZudIavewexdJ<   	 	 	 	 dhdKeyez   e{e
eyez   f   z  dz  fdL„Z|	 	 	 	 dhdMedNddOe}dPe
eZgef   dz  dKeyez   e{e
eyez   f   z  dz  d2efdQ„Z~dR„ ZdS„ Z€dT„ Z�dU„ Z‚dMeBd2eBfdV„ZƒdW„ Z„ejˆ                  �j
                  Z… e?e…d«       didXeZdYe}dZe}d[eZfd\„Z† G d]„ d^«      Z‡ G d_„ d`«      Zˆ G da„ db«      Z‰dc„ ZŠ eeŠdd«        ee�j                  de«        ee8df«        ee9df«        ee:df«       y)jzàTorchScript.

This module contains functionality to support the JIT's scripting frontend, notably:
    - torch.jit.script

This is not intended to be imported directly; please use the exposed
functionalities in `torch.jit`.
é    N)ÚCallableÚIteratorÚMappingÚSequence)ÚAnyÚTypeVar)Ú
deprecatedÚSelf)Úclasses)Ú_get_model_idÚ_qualified_name)Úlog_torchscript_usage)Ú_register_builtin)Ú
_graph_forÚ_script_method_graph_for)ÚJitTypeTraceConfigÚJitTypeTraceStoreÚmonkeytype_trace)Ú_compile_and_register_classÚinfer_methods_to_compileÚScriptMethodStubÚwrap_cpp_module)Ú_enabledÚ_set_jit_function_cacheÚ_set_jit_overload_cacheÚ_try_get_jit_cached_functionÚ_try_get_jit_cached_overloads)Úget_default_argsÚget_jit_class_defÚget_jit_def)ÚModule)Úhas_torch_functionÚhas_torch_function_unaryÚhas_torch_function_variadic)ÚPackageExporterÚPackageImporter)Ú
set_moduleé   )Úvalidate_map_locationÚ_Tz†
Functionally equivalent to a :class:`ScriptModule`, but represents a single
function and does not have any attributes or Parameters.
ÚScriptFunctionútorch.jit.ScriptFunctionz	torch.jitc                 ó,   — t        j                  d«      ‚)Nz ScriptFunction cannot be pickled©ÚpickleÚPickleError©Úclss    úP/var/www/html/ia-enhanced/venv/lib/python3.12/site-packages/torch/jit/_script.pyÚ_reducer4   O   s   € Ü
×
Ñ
Ð?Ó
@Ð@ó    Ú	AttributeÚvalueÚtypec                 ó   — | S ©N© )r7   r8   s     r3   r6   r6   Z   s   € Øˆr5   a¨  
    This method is a pass-through function that returns `value`, mostly
    used to indicate to the TorchScript compiler that the left-hand side
    expression is a class instance attribute with type of `type`. Note that
    `torch.jit.Attribute` should only be used in `__init__` method of `jit.ScriptModule`
    subclasses.

    Though TorchScript can infer correct type for most Python expressions, there are some cases where
    type inference can be wrong, including:

    - Empty containers like `[]` and `{}`, which TorchScript assumes to be container of `Tensor`
    - Optional types like `Optional[T]` but assigned a valid value of type `T`, TorchScript would assume
      it is type `T` rather than `Optional[T]`

    In eager mode, it is simply a pass-through function that returns `value`
    without other implications.

    Example:

    .. testcode::

        import torch
        from typing import Dict

        class AttributeModule(torch.jit.ScriptModule):
            def __init__(self) -> None:
                super().__init__()
                self.foo = torch.jit.Attribute(0.1, float)

                # we should be able to use self.foo as a float here
                assert 0.0 < self.foo

                self.names_ages = torch.jit.Attribute({}, Dict[str, int])
                self.names_ages["someone"] = 20
                assert isinstance(self.names_ages["someone"], int)

        m = AttributeModule()
        # m will contain two attributes
        # 1. foo of type float
        # 2. names_ages of type Dict[str, int]

    .. testcleanup::

        del AttributeModule
        del m

    Note: it's now preferred to instead use type annotations instead of `torch.jit.Attribute`:

    .. testcode::

        import torch
        from typing import Dict

        class AttributeModule(torch.nn.Module):
            names: Dict[str, int]

            def __init__(self) -> None:
                super().__init__()
                self.names = {}

        m = AttributeModule()

    .. testcleanup::

        del AttributeModule
        del m

    Args:
        value: An initial value to be assigned to attribute.
        type: A Python type

    Returns:
        Returns `value`
c                  ó   — t         S r:   )Útype_trace_dbr;   r5   r3   Ú_get_type_trace_dbr>   ª   s   € äÐr5   c                 ó   — t        | |d «      S r:   )Úgetattr)r2   Únames     r3   Ú_get_function_from_typerB   °   s   € Ü�3˜˜dÓ#Ð#r5   c                 óR   — t        | d«      rdt        | «      v xs t        | d«      S y )NÚ	__class__Ú__dict__Ú	__slots__)ÚhasattrÚdirr1   s    r3   Ú_is_new_style_classrI   ¶   s,   € Üˆs�KÔ ØœS ›XÐ%ÒB¬°°kÓ)BÐBð !r5   c                   óB   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zy
)ÚOrderedDictWrapperc                 ó   — || _         y r:   )Ú_c)ÚselfrM   s     r3   Ú__init__zOrderedDictWrapper.__init__Ë   s	   € Øˆ�r5   c                 óT   — | j                  «       D ��cg c]  \  }}|‘Œ	 c}}S c c}}w r:   ©Úitems©rN   ÚkÚvs      r3   ÚkeyszOrderedDictWrapper.keysÎ   ó    € Ø"Ÿj™j›l×+‘d�a˜’Ó+Ð+ùÓ+ó   ”$c                 óT   — | j                  «       D ��cg c]  \  }}|‘Œ	 c}}S c c}}w r:   rQ   rS   s      r3   ÚvalueszOrderedDictWrapper.valuesÑ   rW   rX   c                 ó4   — t        | j                  «       «      S r:   )ÚlenrZ   ©rN   s    r3   Ú__len__zOrderedDictWrapper.__len__Ô   s   € Ü�4—;‘;“=Ó!Ð!r5   c                 ó   — t        d«      ‚)Nz6cannot delete methods or parameters of a script module©ÚRuntimeError©rN   rT   s     r3   Ú__delitem__zOrderedDictWrapper.__delitem__×   s   € ÜÐSÓTÐTr5   c                 ó6   — | j                   j                  «       S r:   )rM   rR   r]   s    r3   rR   zOrderedDictWrapper.itemsÚ   s   € Ø�w‰w�}‰}‹Ðr5   c                 ó`   — || vrt        d|› �«      ‚| j                  j                  ||«       y )NzICan't add a new parameter after ScriptModule construction. Tried to add ')ra   rM   ÚsetattrrS   s      r3   Ú__setitem__zOrderedDictWrapper.__setitem__Ý   s6   € Ø�D‰=ÜØ[Ð\]Ð[^Ð_óð ð 	�‰�‰˜˜1Õr5   c                 ó8   — | j                   j                  |«      S r:   )rM   Úcontainsrb   s     r3   Ú__contains__zOrderedDictWrapper.__contains__ä   s   € Ø�w‰w×Ñ Ó"Ð"r5   c                 óV   — || vrt        |«      ‚| j                  j                  |«      S r:   )ÚKeyErrorrM   r@   rb   s     r3   Ú__getitem__zOrderedDictWrapper.__getitem__ç   s&   € Ø�D‰=Ü˜1“+ÐØ�w‰w�‰˜qÓ!Ð!r5   N)Ú__name__Ú
__module__Ú__qualname__rO   rV   rZ   r^   rc   rR   rg   rj   rm   r;   r5   r3   rK   rK   Ê   s0   „ òò,ò,ò"òUòòò#ó"r5   rK   c                   ó6   ‡ — e Zd Zˆ fd„Zd„ Zd„ Zd„ Zd„ Zˆ xZS )ÚOrderedModuleDictc                 ól   •— t         ‰| �  t        j                  j	                  |«      «       || _        y r:   )ÚsuperrO   ÚtorchÚ_CÚ
ModuleDictÚ_python_modules)rN   ÚmoduleÚpython_dictrD   s      €r3   rO   zOrderedModuleDict.__init__î   s)   ø€ Ü‰ÑœŸ™×,Ñ,¨VÓ4Ô5ð  +ˆÕr5   c                 ó:   — | j                   j                  «       }|S r:   )rx   rR   ©rN   Úrs     r3   rR   zOrderedModuleDict.itemsø   s   € Ø× Ñ ×&Ñ&Ó(ˆØˆr5   c                 ó   — || j                   v S r:   ©rx   rb   s     r3   rj   zOrderedModuleDict.__contains__ü   s   € Ø�D×(Ñ(Ð(Ð(r5   c                 óœ   — t        |t        «      r,| j                  j                  ||«       || j                  |<   y t        d|› d|› �«      ‚)NzgCannot re-assign modules in a ScriptModule with non-scripted module, tried to replace existing module 'z': )Ú
isinstanceÚScriptModulerM   rf   rx   ra   rS   s      r3   rg   zOrderedModuleDict.__setitem__ÿ   sS   € ô �aœÔ&Ø�G‰G�O‰O˜A˜qÔ!Ø&'ˆD× Ñ  Ò#äð=Ø=>¸C¸sÀ1À#ðGóð r5   c                 ó    — | j                   |   S r:   r   rb   s     r3   rm   zOrderedModuleDict.__getitem__  s   € Ø×#Ñ# AÑ&Ð&r5   )	rn   ro   rp   rO   rR   rj   rg   rm   Ú__classcell__©rD   s   @r3   rr   rr   í   s   ø„ ô+òò)òö&'r5   rr   c                   ó   ‡ — e Zd Zˆ fd„Zˆ xZS )Ú
ScriptMetac                 óÄ  •‡ ‡	— i ‰ _         t        t        ‰ dd«      «      ‰ _        t	        |«      D ]i  }t        |di «      j                  «       D ]  \  }}|‰ j                   |<   Œ t        |dt        «       «      }‰ j                  j                  |«      ‰ _        Œk t        |j                  «       «      D ]E  \  }}t        |t        «      sŒt        ‰ |«       |‰ j                   |j                  j                  <   ŒG t        ‰ dd«      rt        ‰
‰ �9  |||«       y t        ‰ dd„ «      Š	t        j                   ‰	«      ˆ ˆ	fd	„«       }|‰ _        t        ‰
‰ �9  |||«       y )
NÚ__constants__r;   Ú_methodsÚ_constants_setÚ_disable_script_metaFrO   c                  ó   — y r:   r;   r]   s    r3   ú<lambda>z%ScriptMeta.__init__.<locals>.<lambda>6  s   � r5   c                 óê  •— t        ‰	j                  «      } ‰
| g|¢­i |¤Ž t        ‰	j                  «      |kD  }t        | «      ‰	u r¬d„ }t        j                  j
                  j                  | || ¬«      | j                  d<   | j                  j                  }|j                  «       D ]  }t        | |«       Œ |j                  «       D ]  \  }}t        | |«       Œ dD ]  }t        | |«       Œ y y )Nc                 ó¾   — t        | «      }t        |d«      r6t        |j                  j	                  «       «      D ��cg c]  \  }}|‘Œ	 c}}S t        | «      S c c}}w )NrŠ   )r8   rG   ÚsortedrŠ   rR   r   )ry   r2   rT   rU   s       r3   Ú
make_stubszAScriptMeta.__init__.<locals>.init_then_script.<locals>.make_stubs@  sM   € Ü˜v›,�CÜ˜s JÔ/Ü.4°S·\±\×5GÑ5GÓ5IÓ.J×K¡d a¨¢ÓKÐKä7¸Ó?Ð?ùó  Ls   ¾A)Úshare_typesÚ_actual_script_module)Ú_parametersÚ_buffersÚ_modules)r\   rŠ   r8   ru   ÚjitÚ
_recursiveÚcreate_script_modulerE   r”   Ú_concrete_typeÚget_attributesÚdelattrÚget_modules)rN   ÚargsÚkwargsÚnum_methodsÚadded_methods_in_initr’   Úconcrete_typerA   Ú_r2   Úoriginal_inits            €€r3   Úinit_then_scriptz-ScriptMeta.__init__.<locals>.init_then_script8  sû   ø€ ä˜cŸl™lÓ+ˆKÙ˜$Ð0 Ò0¨Ò0Ü$'¨¯©Ó$5¸Ñ$CÐ!ä�D‹z˜SÑ ò@ô —I‘I×(Ñ(×=Ñ=Ø˜jÐ:OÐ6Oð >ó ð —‘Ð5Ñ6ð !%× :Ñ :× IÑ I�Ø)×8Ñ8Ó:ò (�DÜ˜D $Õ'ð(à,×8Ñ8Ó:ò (‘G�D˜!Ü˜D $Õ'ð(àCò (�DÜ˜D $Õ'ñ(ð/ !r5   )rŠ   Úsetr@   r‹   ÚreversedrR   Úunionr‘   r�   r   r�   Úoriginal_methodrn   rt   rO   Ú	functoolsÚwraps)r2   rA   ÚbasesÚattrsÚbaserT   rU   Úbase_constantsr¦   r¥   rD   s   `        @€r3   rO   zScriptMeta.__init__  sH  ú€ à')ˆŒÜ ¤¨¨o¸rÓ!BÓCˆÔÜ˜U“Oò 	JˆDÜ  j°"Ó5×;Ñ;Ó=ò $‘��1Ø"#�—‘˜Q’ð$ä")¨$Ð0@Ä#Ã%Ó"HˆNØ!$×!3Ñ!3×!9Ñ!9¸.Ó!IˆCÕð		Jô ˜5Ÿ;™;›=Ó)ò 	=‰DˆAˆqÜ˜!Ô-Õ.Ü˜˜Q”Ø;<�—‘˜Q×.Ñ.×7Ñ7Ò8ð	=ô
 �3Ð.°Ô6ô ‰GÑ˜T 5¨%Ô0Øä  ZÑ1BÓCˆä	�‰˜Ó	'ô	(ó 
(ð	(ð> (ˆŒÜ‰Ñ˜˜u eÕ,r5   ©rn   ro   rp   rO   r„   r…   s   @r3   r‡   r‡     s   ø„ ÷:-ð :-r5   r‡   c                   ó   — e Zd Zd„ Zy)Ú_CachedForwardc                 ó$   — | j                  d«      S )NÚforward)Ú__getattr__)rN   Úobjr2   s      r3   Ú__get__z_CachedForward.__get__]  s   € Ø×Ñ 	Ó*Ð*r5   N)rn   ro   rp   r¸   r;   r5   r3   r³   r³   \  s   „ ó+r5   r³   c                   ó   — e Zd Zy)ÚScriptWarningN©rn   ro   rp   r;   r5   r3   rº   rº   a  s   „ Ør5   rº   c                 ó  — t         j                  dk\  rt        j                  dt        «       nt        j                  dt        «       t
        s| S t        j                  d¬«      }t        | | j                  d¬«      }t        ||| «      S )N©é   é   z}`torch.jit.script_method` is not supported in Python 3.14+ and may break. Please switch to `torch.compile` or `torch.export`.z\`torch.jit.script_method` is deprecated. Please switch to `torch.compile` or `torch.export`.é   ©Ú	frames_upr‚   )Ú	self_name)ÚsysÚversion_infoÚwarningsÚwarnÚDeprecationWarningr   Ú_jit_internalÚ!createResolutionCallbackFromFramer    rn   r   )ÚfnÚ_rcbÚasts      r3   Úscript_methodrÎ   e  sv   € Ü
×Ñ˜7Ò"Ü�‰ðBäõ	
ô 	�‰ØjÜô	
õ Øˆ	ô ×:Ñ:ÀQÔG€DÜ
�b˜"Ÿ+™+°Ô
@€CÜ˜D # rÓ*Ð*r5   c                   ó6   — e Zd Zdeeef   ddfd„Zdedefd„Zy)ÚConstMapÚconst_mappingÚreturnNc                 ó   — || _         y r:   ©rÑ   )rN   rÑ   s     r3   rO   zConstMap.__init__…  s
   € Ø*ˆÕr5   Úattrc                 ó    — | j                   |   S r:   rÔ   )rN   rÕ   s     r3   r¶   zConstMap.__getattr__ˆ  s   € Ø×!Ñ! $Ñ'Ð'r5   )rn   ro   rp   r   Ústrr   rO   r¶   r;   r5   r3   rÐ   rÐ   „  s1   „ ð+ g¨c°3¨hÑ&7ð +¸Dó +ð( ð (¨ô (r5   rÐ   ÚimporterÚscript_module_idrÒ   c                 óZ  — t        | j                  t        j                  j                  «      st        d«      ‚t        j                  j                  «       }t        j                  j                  || j                  | j                  t        | j                  «      |«      }t        |«      S )zº
    Call by ``torch.package.PackageImporter``'s Pickler's ``persistent_load`` function.

    Performs work of loading and returning a ScriptModule from a ``torch.package`` archive.
    z{Loading ScriptObjects from a PackageImporter created from a directory is not supported. Use a package archive file instead.)r�   Ú
zip_readerru   rv   ÚPyTorchFileReaderra   ÚCompilationUnitÚ_import_ir_module_from_packageÚstorage_contextr)   Úlast_map_locationr   )rØ   rÙ   ÚcuÚ
cpp_modules       r3   Úunpackage_script_modulerã   Œ  sŒ   € ô �h×)Ñ)¬5¯8©8×+EÑ+EÔFÜðNó
ð 	
ô 
�‰×	!Ñ	!Ó	#€BÜ—‘×8Ñ8Ø
Ø×ÑØ× Ñ Ü˜h×8Ñ8Ó9Øó€Jô ˜:Ó&Ð&r5   )Ú__iter__r^   Ú__neg__Ú__mul__rj   Ú__add__Ú__sub__Ú__pow__Ú__truediv__Ú__mod__Ú__ne__Ú__eq__Ú__lt__Ú__gt__Ú__le__Ú__ge__Ú__and__Ú__or__Ú__xor__rm   rg   Ú__call__Ú__int__Ú	__float__Ú__bool__Ú__str__Ú	__enter__Ú__exit__c                   ó|   ‡ — e Zd ZdZˆ fd„Zdedefˆ fd„Zdededdfˆ fd„Zd	ed
ededefd„Z	d„ Z
dedefd„Zˆ xZS )ÚRecursiveScriptClassaX  Wrapper for a TorchScript class instance for use in Python.

        An analogue of RecursiveScriptModule for regular objects that are not modules.
        This class is a wrapper around a torch._C.ScriptObject that represents an instance
        of a TorchScript class and allows it to be used in Python.

        Attributes:
            _c [torch._C.ScriptObject]: The C++ object to which attribute lookups and method
                calls are forwarded.
            _props [Dict[str, property]]: A dictionary of properties fetched from self._c and
                exposed on this wrppaer.
        c                 ó"  •— t         ‰| �  «        d| j                  d<   || _        | j                  j	                  «       D �ci c]-  }|j
                  t        |j                  |j                  «      “Œ/ c}| _	        d| j                  d<   y c c}w )NTÚ_initializingF)
rt   rO   rE   rM   Ú_propertiesrA   ÚpropertyÚgetterÚsetterÚ_props)rN   Ú	cpp_classÚproprD   s      €r3   rO   zRecursiveScriptClass.__init__Ò  sy   ø€ Ü‰GÑÔØ-1ˆD�M‰M˜/Ñ*ØˆDŒGð
 !ŸG™G×/Ñ/Ó1öàð —	‘	œ8 D§K¡K°·±Ó=Ñ=òˆDŒKð
 .3ˆD�M‰M˜/Ò*ùòs   Á2BrÕ   rÒ   c                 óÚ   •— | j                   j                  d«      rt        ‰| �  |«      S || j                  v r| j                  |   j                  «       S t        | j                  |«      S ©Nrÿ   )rE   Úgetrt   r¶   r  Úfgetr@   rM   ©rN   rÕ   rD   s     €r3   r¶   z RecursiveScriptClass.__getattr__ß  sZ   ø€ Ø�}‰}× Ñ  Ô1Ü‘wÑ*¨4Ó0Ð0à�t—{‘{Ñ"Ø—{‘{ 4Ñ(×-Ñ-Ó/Ð/ä˜4Ÿ7™7 DÓ)Ð)r5   r7   Nc                 óâ   •— | j                   j                  d«      rt        ‰| �  ||«      S || j                  v r| j                  |   j                  |«      S t        | j                  ||«       y r  )rE   r	  rt   Ú__setattr__r  Úfsetrf   rM   ©rN   rÕ   r7   rD   s      €r3   r  z RecursiveScriptClass.__setattr__è  s]   ø€ Ø�}‰}× Ñ  Ô1Ü‘wÑ*¨4°Ó7Ð7à�t—{‘{Ñ"Ø—{‘{ 4Ñ(×-Ñ-¨eÓ4Ð4ä�D—G‘G˜T 5Õ)r5   Úmethod_namerŸ   r    c                 óv   — | j                   j                  |«      st        ‚| j                  |«      } ||i |¤ŽS r:   )rM   Ú_has_methodÚ	TypeErrorr¶   ©rN   r  rŸ   r    Úself_methods        r3   Úforward_magic_methodz)RecursiveScriptClass.forward_magic_methodó  s;   € ð —7‘7×&Ñ& {Ô3Ü�à×*Ñ*¨;Ó7ˆKÙ Ð/¨Ñ/Ð/r5   c                 ó,   — t        j                  d«      ‚)NzScriptClasses cannot be pickledr.   r]   s    r3   Ú__getstate__z!RecursiveScriptClass.__getstate__ü  s   € Ü×$Ñ$Ð%FÓGÐGr5   Úotherc                 ó€   — | j                   j                  d«      r| j                  d|«      S | j                  d|«      S )NÚ__iadd__rç   )rM   r  r  )rN   r  s     r3   r  zRecursiveScriptClass.__iadd__ÿ  s:   € Ø�w‰w×"Ñ" :Ô.Ø×0Ñ0°¸UÓCÐCà×0Ñ0°¸EÓBÐBr5   )rn   ro   rp   Ú__doc__rO   r×   r   r¶   r  r  r  r
   r  r„   r…   s   @r3   rý   rý   Ä  s{   ø„ ñ	ô	3ð	* Cð 	*¨Cõ 	*ð	* Cð 	*°ð 	*¸õ 	*ð	0Ø"ð	0Ø+.ð	0Ø:=ð	0àó	0ò	Hð	C $ð 	C¨4÷ 	Cr5   rý   c                 ó6   —  | j                   t        g|¢­i |¤ŽS r:   )r  r  ©rN   rŸ   r    s      r3   Úmethod_templater    s   € Ø,�4×,Ñ,¬[ÐJ¸4ÒJÀ6ÑJÐJr5   c                   ó”   ‡ — e Zd ZU dZg d¢Zdˆ fd„Z e«       Zede	f   e
d<   dede	fˆ fd	„Zded
e	ddfˆ fd„Zd„ Zd„ Zdefd„Zˆ xZS )r‚   a'  Wrapper for C++ torch::jit::Module with methods, attributes, and parameters.

        A wrapper around C++ ``torch::jit::Module``. ``ScriptModule``\s
        contain methods, attributes, parameters, and
        constants. These can be accessed the same way as on a normal ``nn.Module``.
        )ÚcodeÚcode_with_constantsÚgraphÚinlined_graphÚoriginal_namerÒ   Nc                 ó"   •— t         ‰| �  «        y r:   ©rt   rO   )rN   rD   s    €r3   rO   zScriptModule.__init__$  ó   ø€ Ü‰GÑÕr5   .rµ   rÕ   c                 ój   •— d| j                   vrt        ‰| �	  |«      S t        | j                  |«      S )Nr”   )rE   rt   r¶   r@   r”   r  s     €r3   r¶   zScriptModule.__getattr__)  s2   ø€ Ø&¨d¯m©mÑ;Ü‘wÑ*¨4Ó0Ð0Ü˜4×5Ñ5°tÓ<Ð<r5   r7   c                 ó,  •— d| j                   vrnt        |t        «      rNd| j                  j                   vri | j                  _        |j
                  | j                  |<   |j                  }t        ‰| �!  ||«      S t        | j                  ||«       y )Nr”   Ú__annotations__)rE   r�   r6   rD   r+  r8   r7   rt   r  rf   r”   r  s      €r3   r  zScriptModule.__setattr__.  s|   ø€ Ø&¨d¯m©mÑ;ô ˜e¤YÔ/ð
 )°·±×0GÑ0GÑGØ9;˜Ÿ™Ô6Ø16·±�D×(Ñ(¨Ñ.Ø!ŸK™K�EÜ‘wÑ*¨4°Ó7Ð7ä�D×.Ñ.°°eÕ<r5   c                 ó$  — d| j                   v r| j                  j                  |«      S t        j                  d¬«      }t
        j                  j                  |«      }t        ||d «      | j                  |j                  «       j                  <   y )Nr”   r(   rÁ   )rE   r”   ÚdefinerÉ   rÊ   ru   rv   Ú_parse_source_defr   rŠ   rA   )rN   ÚsrcÚrcbrÍ   s       r3   r-  zScriptModule.defineC  sn   € Ø&¨$¯-©-Ñ7ð ×1Ñ1×8Ñ8¸Ó=Ð=ô  ×AÑAÈAÔNˆCÜ—(‘(×,Ñ,¨SÓ1ˆCÜ-=¸cÀ3ÈÓ-MˆD�M‰M˜#Ÿ(™(›*Ÿ/™/Ò*r5   c                 ó6   — | j                   j                  «       S r:   )r”   Ú_replicate_for_data_parallelr]   s    r3   r2  z)ScriptModule._replicate_for_data_parallelY  s   € Ø×-Ñ-×JÑJÓLÐLr5   Úexporterc                 ó’   — |j                  «       }|j                  j                  | j                  t	        |«      «       t
        |ffS )a¸  Save a ScriptModule inside of a ``torch.package`` archive.

            Called by ``torch.package.PackageExporter``'s Pickler's ``persistent_id`` when
            saving TorchScript objects. Performs act of saving a ScriptModule inside of
            a ``torch.package`` archive.

            Returns method to load the ScriptModule from a ``torch.package.PackageImporter``'s
            Pickler's ``persistent_load`` function.
            )Úget_unique_idÚscript_module_serializerÚ	serializerM   Úintrã   )rN   r3  rÙ   s      r3   Ú__reduce_package__zScriptModule.__reduce_package__\  sB   € ð  (×5Ñ5Ó7ÐØ×-Ñ-×7Ñ7¸¿¹ÄÐEUÓAVÔWÜ+Ð.>Ð-@ÐAÐAr5   ©rÒ   N)rn   ro   rp   r  Ú__jit_unused_properties__rO   r³   rµ   r   r   r+  r×   r¶   r  r-  r2  r%   r9  r„   r…   s   @r3   r‚   r‚     st   ø… ñ	ò%
Ð!õ	ñ '5Ó&6ˆ�˜#˜s˜(Ñ#Ó6ð	= Cð 	=¨Cõ 	=ð
	= Cð 	=°ð 	=¸õ 	=ò*	Nò,	Mð	B¨÷ 	Br5   r‚   )Ú	metaclassc                   óè  ‡ — e Zd ZdZdZˆ fd„Zed„ «       Zed„ «       Zd„ Z	e
d„ «       Ze
d„ «       Ze
d	„ «       Ze
d
„ «       Zd„ Z ed«      d„ «       Z ed«      d„ «       Zdededefd„Zdededefd„Zdefd„Zdededefd„Ze
d„ «       Zd„ Zdedefˆ fd„Zdededdfˆ fd„Zdefd„Zdee ef   dz  defd„Z!d edededefd!„Z"de#e   fd"„Z$d#e defd$„Z%d%„ Z&d&„ Z'de(e   fˆ fd'„Z)d(„ Z*d)„ Z+ˆ xZ,S )*ÚRecursiveScriptModuleaZ  Retain the existing isinstance(ScriptModule) behavior.

        The core data structure in TorchScript is the ``ScriptModule``. It is an
        analogue of torch's ``nn.Module`` and represents an entire model as a tree of
        submodules. Like normal modules, each individual module in a ``ScriptModule`` can
        have submodules, parameters, and methods. In ``nn.Module``\s methods are implemented
        as Python functions, but in ``ScriptModule``\s methods are implemented as
        TorchScript functions, a statically-typed subset of Python that contains all
        of PyTorch's built-in Tensor operations. This difference allows your
        ``ScriptModule``\s code to run without the need for a Python interpreter.

        ``ScriptModule``\s should not be created manually, instead use
        either :func:`tracing <torch.jit.trace>` or :func:`scripting <torch.jit.script>`.
        Tracing and scripting can be applied incrementally and :ref:`composed as necessary <Types>`.

        * Tracing records the tensor operations as executed with a set of example inputs and uses these
          operations to construct a computation graph. You can use the full dynamic behavior of Python with tracing,
          but values other than Tensors and control flow aren't captured in the graph.

        * Scripting inspects the Python code of the model
          and compiles it to TorchScript. Scripting allows the use of many `types`_ of values and supports dynamic control flow.
          Many, but not all features of Python are supported by the compiler, so changes to the source code may be necessary.
        Tc                 óf   •— d| j                   d<   || _        t        ‰| �  «        t	        | d«       y )NTrÿ   Útraining)rE   rM   rt   rO   r�   )rN   râ   rD   s     €r3   rO   zRecursiveScriptModule.__init__ˆ  s/   ø€ Ø-1ˆD�M‰M˜/Ñ*Ø ˆDŒGÜ‰GÑÔô �D˜*Õ%r5   c                 óV   — t        | «      } ||«       t         j                  |«       |S )a†  
            Construct a RecursiveScriptModule that's ready for use.

            PyTorch code should use this to construct a RecursiveScriptModule instead
            of instead of calling `__init__` directly, as it makes sure the
            object is properly finalized (and in the future, we may take
            control of how the RecursiveScriptModule instance is created).

            Args:
                cpp_module:  The C++ Module that will hold the actual state of
                             this RecursiveScriptModule instance.
                init_fn:  Lambda that initializes the RecursiveScriptModule passed to it.
            )r>  Ú_finalize_scriptmodule)râ   Úinit_fnÚscript_modules      r3   Ú
_constructz RecursiveScriptModule._construct‘  s,   € ô 2°*Ó=ˆMÙ�MÔ"ô
 "×8Ñ8¸ÔGØ Ð r5   c                 ó8  — t        t        j                  j                  | j                  «      «      | _        t        t        j                  j                  | j                  «      «      | _        t        | j                  | j                  «      | _	        d| _
        y )NF)rK   ru   rv   ÚParameterDictrM   r•   Ú
BufferDictr–   rr   r—   rÿ   ©rD  s    r3   rB  z,RecursiveScriptModule._finalize_scriptmodule©  sx   € ä(:Ü—‘×&Ñ& }×'7Ñ'7Ó8ó)ˆMÔ%ô &8Ü—‘×#Ñ# M×$4Ñ$4Ó5ó&ˆMÔ"ô &7Ø× Ñ  -×"8Ñ"8ó&ˆMÔ"ð +0ˆMÕ'r5   c                 ó:  — | j                  |«       t        j                  j                  j	                  | j
                  j                  «       «      | _        i }t        j                  j                  | j
                  «      j                  «       D ]  \  }}t        |«      ||<   Œ t        | j
                  |«      | _        t        t        j                  j                  | j
                  «      «      | _        t        t        j                  j!                  | j
                  «      «      | _        | j$                  j                  «       D ��ci c],  \  }}t'        |t        j                  j(                  «      s||“Œ. c}}| _        d| j$                  d<   yc c}}w )zä
            Re-construct an instance of RecursiveScriptModule using an instance of a C++ module.

            Args:
                cpp_module: The C++ module that this RecursiveScriptModule will be rebuilt around.
            Frÿ   N)rO   ru   rv   ÚConcreteModuleTypeÚfrom_jit_typerM   Ú_typer›   rw   rR   r   rr   r—   rK   rG  r•   rH  r–   rE   r�   ÚScriptMethod)rN   râ   ÚmodulesrA   rT   rU   s         r3   Ú_reconstructz"RecursiveScriptModule._reconstruct¶  s.  € ð �M‰M˜*Ô%ô #(§(¡(×"=Ñ"=×"KÑ"KØ—‘—‘“ó#ˆDÔð
 ˆGÜ$)§H¡H×$7Ñ$7¸¿¹Ó$@×$FÑ$FÓ$Hò <Ñ ��jÜ /°
Ó ;�˜’ð<ä-¨d¯g©g°wÓ?ˆDŒMô  2´%·(±(×2HÑ2HÈÏÉÓ2QÓRˆDÔÜ.¬u¯x©x×/BÑ/BÀ4Ç7Á7Ó/KÓLˆDŒMð
 !ŸM™M×/Ñ/Ó1÷á�A�qÜ! !¤U§X¡X×%:Ñ%:Ô;ð �1‘óˆDŒMð
 .3ˆD�M‰M˜/Ò*ùós   Å1Fc                 óL   — | j                   j                  d«      j                  S )zPReturn a string representation of the internal graph for the ``forward`` method.rµ   )rM   Ú_get_methodr#  r]   s    r3   r#  zRecursiveScriptModule.graphÖ  s   € ð —7‘7×&Ñ& yÓ1×7Ñ7Ð7r5   c                 ó.   — | j                   j                  S )zÀ
            Return a string representation of the internal graph for the ``forward`` method.

            This graph will be preprocessed to inline all function and method calls.
            )rµ   r$  r]   s    r3   r$  z#RecursiveScriptModule.inlined_graphÛ  s   € ð —<‘<×-Ñ-Ð-r5   c                 ó.   — | j                   j                  S )zŒ
            Return a pretty-printed representation (as valid Python syntax) of the internal graph for the ``forward`` method.

            )rµ   r!  r]   s    r3   r!  zRecursiveScriptModule.codeä  s   € ð —<‘<×$Ñ$Ð$r5   c                 óT   — | j                   j                  }|d   t        |d   «      fS )a|  Return a tuple.

            Returns a tuple of:

            [0] a pretty-printed representation (as valid Python syntax) of
            the internal graph for the ``forward`` method. See `code`.
            [1] a ConstMap following the CONSTANT.cN format of the output in [0].
            The indices in the [0] output are keys to the underlying constant's values.

            r   r(   )rµ   r"  rÐ   r|   s     r3   r"  z)RecursiveScriptModule.code_with_constantsì  s*   € ð —‘×0Ñ0ˆAØ�a‘Dœ( 1 Q¡4›.Ð)Ð)r5   c                 óN   —  | j                   j                  t        |«      fi |¤ŽS )am  Save with a file-like object.

            save(f, _extra_files={})

            See :func:`torch.jit.save <torch.jit.save>` which accepts a file-like object.
            This function, torch.save(), converts the object to a string, treating it as a path.
            DO NOT confuse these two functions when it comes to the 'f' parameter functionality.
            )rM   Úsaver×   )rN   Úfr    s      r3   rW  zRecursiveScriptModule.saveû  s"   € ð  �4—7‘7—<‘<¤ A£Ñ1¨&Ñ1Ð1r5   z”Lite Interpreter is deprecated. Please consider switching to ExecuTorch.             https://docs.pytorch.org/executorch/stable/getting-started.htmlc                 ór   — t        j                  dt        d¬«        | j                  j                  |i |¤ŽS )az  Add (or update) the bytecode session to the script model.

            _save_for_lite_interpreter(f)

            The updated model is used
            in lite interpreter for mobile applications.

            Args:
                f: a string containing a file name.
                _extra_files: Map from filename to contents which will be stored as part of 'f'.

            ú˜Lite Interpreter is deprecated. Please consider switching to ExecuTorch.                 https://docs.pytorch.org/executorch/stable/getting-started.htmlrÀ   ©Ú
stacklevel)rÆ   rÇ   rÈ   rM   Ú_save_for_mobiler  s      r3   Ú_save_for_lite_interpreterz0RecursiveScriptModule._save_for_lite_interpreter  s:   € ô" �M‰MðQä"Øõ	ð ,�4—7‘7×+Ñ+¨TÐ<°VÑ<Ð<r5   c                 ór   — t        j                  dt        d¬«        | j                  j                  |i |¤ŽS )NrZ  rÀ   r[  )rÆ   rÇ   rÈ   rM   Ú_save_to_buffer_for_mobiler  s      r3   Ú$_save_to_buffer_for_lite_interpreterz:RecursiveScriptModule._save_to_buffer_for_lite_interpreter  s:   € ô
 �M‰MðQä"Øõ	ð 6�4—7‘7×5Ñ5°tÐF¸vÑFÐFr5   rŸ   r    rÒ   c                 ó:   —  | j                   j                  |i |¤ŽS r:   )rM   Úsave_to_bufferr  s      r3   rc  z$RecursiveScriptModule.save_to_buffer,  s   € Ø)�4—7‘7×)Ñ)¨4Ð:°6Ñ:Ð:r5   c                 ó6   — | j                   j                  «       S r:   )rM   Úget_debug_stater  s      r3   re  z%RecursiveScriptModule.get_debug_state/  s   € Ø—7‘7×*Ñ*Ó,Ð,r5   c                 ó    — d| j                   › �S )Nzoriginal_name=)r%  r]   s    r3   Ú
extra_reprz RecursiveScriptModule.extra_repr2  s   € Ø# D×$6Ñ$6Ð#7Ð8Ð8r5   c                 óB   —  | j                   j                  | g|¢­i |¤ŽS r:   )rµ   Ú	graph_forr  s      r3   ri  zRecursiveScriptModule.graph_for5  s#   € Ø)�4—<‘<×)Ñ)¨$Ð@°Ò@¸Ñ@Ð@r5   c                 óÞ   — t        | «      t        | j                  j                  «       j	                  «       «      u ryt        | j                  j                  «       j	                  «       «      S ©NÚ )r8   r×   rM   rM  rA   r]   s    r3   r%  z#RecursiveScriptModule.original_name8  sI   € ô �D‹zœS §¡§¡£×!5Ñ!5Ó!7Ó8Ñ8ØÜ�t—w‘w—}‘}“×+Ñ+Ó-Ó.Ð.r5   c                 ó~   — t        j                  d¬«      }| j                  j                  | j                  ||«       y )Nr(   rÁ   )rÉ   rÊ   rM   Ú_definer›   )rN   r/  r0  s      r3   r-  zRecursiveScriptModule.define?  s.   € ô  ×AÑAÈAÔNˆCØ�G‰G�O‰O˜D×/Ñ/°°cÕ:r5   rÕ   c                 ó¾  •— d| j                   vrt        d«      ‚| j                  rt        ‰| �  |«      S || j
                  v r| j
                  |   S | j                  j                  |«      r| j                  j                  |«      S | j                  j                  |«      r,| j                  j                  |«      }|| j                   |<   |S t        ‰| �  |«      S )Nrÿ   zKScriptModule has not been initialized, did you forget to call super's init?)rE   ra   rÿ   rt   r¶   r—   rM   rG   r@   r  rR  )rN   rÕ   rÎ   rD   s      €r3   r¶   z!RecursiveScriptModule.__getattr__K  sÆ   ø€ Ø d§m¡mÑ3Ü"Øaóð ð ×!Ò!Ü‘wÑ*¨4Ó0Ð0ð �t—}‘}Ñ$Ø—}‘} TÑ*Ð*Ø—‘—‘ Ô&Ø—w‘w—‘ tÓ,Ð,Ø—‘×$Ñ$ TÔ*Ø $§¡× 3Ñ 3°DÓ 9�ð '4�—‘˜dÑ#Ø$Ð$ä‘7Ñ& tÓ,Ð,r5   r7   Nc                 ó|  •— | j                   rt        ‰| �	  ||«      S || j                  v r|| j                  |<   y | j                  j                  |«      r| j                  j                  ||«       y t        | d«      r.|| j                  j                  «       v rt        d|› d|› d�«      ‚t        ‰| �	  ||«      S )Nr›   z+Cannot mutate TorchScript constant value: 'z'. Value: 'ú')
rÿ   rt   r  r—   rM   rG   rf   r›   Úget_constantsÚAttributeErrorr  s      €r3   r  z!RecursiveScriptModule.__setattr__c  s´   ø€ Ø×!Ò!Ü‘wÑ*¨4°Ó7Ð7à�t—}‘}Ñ$Ø&+�—‘˜dÒ#Ø—‘—‘ Ô&Ø—‘—‘  eÕ,ä˜Ð.Ô/Ø˜D×/Ñ/×=Ñ=Ó?Ñ?ô %ØAÀ$ÀÀ{ÐSXÐRYÐYZÐ[óð ô ‘wÑ*¨4°Ó7Ð7r5   c                 óŽ   — t         j                  j                  j                  t	        j                  | j
                  «      «      S r:   )ru   r˜   r™   r   ÚcopyrM   r]   s    r3   Ú__copy__zRecursiveScriptModule.__copy__~  s*   € Ü—9‘9×'Ñ'×7Ñ7¼¿	¹	À$Ç'Á'Ó8JÓKÐKr5   Úmemoc                 ó�   — t         j                  j                  j                  t	        j
                  | j                  |«      «      S r:   )ru   r˜   r™   r   ru  ÚdeepcopyrM   )rN   rw  s     r3   Ú__deepcopy__z"RecursiveScriptModule.__deepcopy__�  s,   € Ü—9‘9×'Ñ'×7Ñ7¼¿¹ÀdÇgÁgÈtÓ8TÓUÐUr5   r  c                 ór   — t        | |«      }t        |dd «      t        t        |«      k(  rt        ‚ ||i |¤ŽS )NÚ__func__)r@   r>  ÚNotImplementedErrorr  s        r3   r  z*RecursiveScriptModule.forward_magic_methodˆ  sE   € ô " $¨Ó4ˆKÜ�{ J°Ó5¼Ü% {ó:ò ô *Ð)Ù Ð/¨Ñ/Ð/r5   c                 ó$   — | j                  d«      S )Nrä   ©r  r]   s    r3   rä   zRecursiveScriptModule.__iter__’  s   € Ø×,Ñ,¨ZÓ8Ð8r5   Úidxc                 ó&   — | j                  d|«      S )Nrm   r  )rN   r€  s     r3   rm   z!RecursiveScriptModule.__getitem__•  s   € Ø×,Ñ,¨]¸CÓ@Ð@r5   c                 ó$   — | j                  d«      S )Nr^   r  r]   s    r3   r^   zRecursiveScriptModule.__len__˜  s   € Ø×,Ñ,¨YÓ7Ð7r5   c                 ó&   — | j                  d|«      S )Nrj   r  )rN   Úkeys     r3   rj   z"RecursiveScriptModule.__contains__›  s   € Ø×,Ñ,¨^¸SÓAÐAr5   c                 ó~   •— | j                   }|j                  t        t        d«      u rt        ‰| �  «       S  |«       S )NÚ__dir__)r†  r|  rB   r>  rt   )rN   r  rD   s     €r3   r†  zRecursiveScriptModule.__dir__   s=   ø€ ØŸ,™,ˆKà×$Ñ$Ü*Ô+@À)ÓLñMô ‘w‘Ó(Ð(Ù“=Ð r5   c                 ób   — | j                   }|j                  t        t        d«      u ry |«       S )Nrø   T)rø   r|  rB   r>  )rN   r  s     r3   rø   zRecursiveScriptModule.__bool__¬  s2   € ØŸ-™-ˆKà×$Ñ$Ü*Ô+@À*ÓMñNð Ù“=Ð r5   c                 ód   — d„ }t         j                  | j                  j                  «       |«      S )Nc                  ó   — y r:   r;   rI  s    r3   rC  zCRecursiveScriptModule._replicate_for_data_parallel.<locals>.init_fn¸  s   € àr5   )r>  rE  rM   r2  )rN   rC  s     r3   r2  z2RecursiveScriptModule._replicate_for_data_parallelµ  s.   € òô
 )×3Ñ3Ø—‘×4Ñ4Ó6¸óð r5   )-rn   ro   rp   r  rŒ   rO   ÚstaticmethodrE  rB  rP  r  r#  r$  r!  r"  rW  r	   r^  ra  r   rc  re  r×   rg  ri  r%  r-  r¶   r  r
   rv  Údictr8  rz  r  r   rä   rm   r^   rj   r   r†  rø   r2  r„   r…   s   @r3   r>  r>  j  s  ø„ ñ	ð0  $Ðô	&ð 
ñ	!ó 
ð	!ð. 
ñ
	0ó 
ð
	0ò	3ð@ 
ñ	8ó 
ð	8ð 
ñ	.ó 
ð	.ð 
ñ	%ó 
ð	%ð 
ñ	*ó 
ð	*ò		2ñ 
ðMó

ñ	=ó	

ð	=ñ* 
ðMó

ñ	Gó	

ð	Gð	;¨ð 	;°sð 	;¸só 	;ð	-¨ð 	-¸ð 	-Àó 	-ð	9 ó 	9ð	A 3ð 	A°#ð 	A¸#ó 	Að 
ñ	/ó 
ð	/ò
	;ð	- Cð 	-¨Cõ 	-ð0	8 Cð 	8°ð 	8¸õ 	8ð6	L˜dó 	Lð	V T¨#¨s¨(¡^°dÑ%:ð 	V¸tó 	Vð	0Ø"ð	0Ø+.ð	0Ø:=ð	0àó	0ð	9˜h s™mó 	9ð	A 3ð 	A¨3ó 	Aò	8ò	Bð
	!˜X c™]õ 	!ò	!ö
	r5   r>  Ú__c                 ó:   ‡— dd l Š ‰j                  | ˆfd„¬«      S )Nr   c                 óP   •—  ‰j                   | «      xs  ‰j                  | «      S r:   )Ú
isfunctionÚismethod)ÚxÚinspects    €r3   rŽ   z_get_methods.<locals>.<lambda>Ö  s(   ø€ Ð%7 W×%7Ñ%7¸Ó%:Ò%QÐ>N¸g×>NÑ>NÈqÓ>Q€ r5   )Ú	predicate)r’  Ú
getmembers)r2   r’  s    @r3   Ú_get_methodsr•  Ñ  s#   ø€ Ûð "ˆw×!Ñ!ØÓQô
ð 	
r5   >%   ÚtoÚcpuÚcudaÚevalÚhalfr8   ÚapplyÚfloatÚtrainÚ_applyÚdoubleÚbuffersrµ   rO  ÚchildrenÚ	_get_nameÚ	zero_gradÚ
add_modulerg  Ú
parametersÚ
state_dictÚshare_memoryÚ_slow_forwardÚ_tracing_nameÚnamed_buffersÚnamed_modulesÚ_named_membersÚnamed_childrenÚget_extra_stateÚload_state_dictÚregister_bufferÚregister_moduleÚset_extra_stateÚnamed_parametersÚregister_parameterÚ_save_to_state_dictÚ_load_from_state_dictc                 ó   ‡ — ˆ fd„}|S )Nc                 ó    •— t        ‰dz   «      ‚)Nz" is not supported on ScriptModulesr`   )rN   rŸ   r    rA   s      €r3   Úfailz_make_fail.<locals>.fail  s   ø€ Ü˜tÐ&JÑJÓKÐKr5   r;   )rA   r¹  s   ` r3   Ú
_make_failrº    s   ø€ ô	Lð ˆr5   Ú
_call_implc                   ó   — e Zd Zy)rý   Nr»   r;   r5   r3   rý   rý     s   „ Ør5   c                   ó    ‡ — e Zd Zdˆ fd„	Zˆ xZS )r‚   c                 ó"   •— t         ‰| �  «        y r:   r'  ©rN   ÚargrD   s     €r3   rO   zScriptModule.__init__  r(  r5   r:   r±   r…   s   @r3   r‚   r‚     ó   ø„ ÷	ñ 	r5   c                   ó    ‡ — e Zd Zdˆ fd„	Zˆ xZS )r>  c                 ó"   •— t         ‰| �  «        y r:   r'  r¿  s     €r3   rO   zRecursiveScriptModule.__init__  r(  r5   r:   r±   r…   s   @r3   r>  r>    rÁ  r5   c                 óX  — t        | t        j                  j                  «      s| S t	        | «      }||v r|t	        | «         S t        | d«      r| j                  «       n| } | ||<   i }| j                  j                  «       D ]€  \  }}|dk(  r-|j                  «       D ]  \  }}t        ||«      ||<   Œ |||<   Œ8t        |t        j                  j                  «      r t        |t        «      st        ||«      ||<   Œ||||<   Œ‚ |j                  «       D ]  }|| j                  <   Œ | S )NÚ__prepare_scriptable__r—   )r�   ru   Únnr!   ÚidrG   rÅ  rE   rR   Ú!call_prepare_scriptable_func_implr‚   rZ   )r·   rw  Úobj_idÚnew_obj_dictrA   Ú
sub_modulerT   rU   s           r3   rÈ  rÈ     s5  € Ü�cœ5Ÿ8™8Ÿ?™?Ô+Øˆ
ä�‹W€Fð ��~Ø”B�s“G‰}Ðô )0°Ð5MÔ(Nˆ×"Ñ"Ô$ÐTWð ð €Dˆ�Là€LàŸL™L×.Ñ.Ó0ò 
,ÑˆˆjØ�:ÒØ"×(Ñ(Ó*ò K‘��1Ü AÀ!ÀTÓ J�
˜1’ðKà!+ˆL˜ÒÜ˜
¤E§H¡H§O¡OÔ4¼ZØœô>
ô "CÀ:ÈtÓ!TˆL˜Òà!+ˆL˜Òð
,ð × Ñ Ó"ò ˆØˆ�‰�TÒðð €Jr5   c                 ó   — i }t        | |«      S r:   )rÈ  )r·   rw  s     r3   Úcall_prepare_scriptable_funcrÍ  G  s   € Ø')€DÜ,¨S°$Ó7Ð7r5   c                 ó@   — t         j                  j                  | «      S )a²  
    Create a ``torch._C.ScriptDict`` instance with the data from ``obj``.

    Args:
        obj (dict): The Python dictionary that is used to initialize the ``ScriptDict``
                    returned by this function.

    Returns:
        An instance of ``torch._C.ScriptDict`` that has the same data as ``obj``
        and can be passed between Python and TorchScript with reference semantics and
        zero copy overhead.
    )ru   rv   Ú
ScriptDict)r·   s    r3   Úcreate_script_dictrÐ  L  s   € ô �8‰8×Ñ˜sÓ#Ð#r5   c                 ó@   — t         j                  j                  | «      S )a«  
    Create a ``torch._C.ScriptList`` instance with the data from ``obj``.

    Args:
        obj (dict): The Python list that is used to initialize the ``ScriptList``
                    returned by this function.
    Returns:
        An instance of ``torch._C.ScriptList`` that has the same data as ``obj``
        and can be passed between Python and TorchScript with reference semantics and
        zero copy overhead.
    )ru   rv   Ú
ScriptList)r·   Ú	type_hints     r3   Úcreate_script_listrÔ  \  s   € ô �8‰8×Ñ˜sÓ#Ð#r5   TÚ	_TOPLEVELÚexample_inputsc                 ó  — |�t        j                  dt        d¬«       t        | t        «      r| S t        | t
        «      r| S t        | t        «      r| S |r¨t        «       at        r�t        t        «      }t        |«      5  t        |t        «      r%|j                  «       D ]  \  }}|D ]  } ||Ž  Œ	 Œ n(t        |t        «      r|D ]  }	 | |	Ž  Œ	 nt        d«      ‚d d d «       nt        j                  dd¬«       t        | t        j                   j"                  «      rWt%        | «      } t        j&                  j(                  j+                  | t        j&                  j(                  j,                  «      S t/        | d«      r| j1                  «       n| } t        | t        «      rt3        | «      S t        | t        «      rt5        | «      S t7        j8                  | «      rÀt;        | «      }
t=        | t        j                   j"                  «      rt?        d| › d	�«      ‚t=        | t@        jB                  «      r| S tE        | «      st?        d
«      ‚tG        | jI                  «       «      dkD  rt?        d«      ‚|€tK        jL                  |dz   «      }tO        | ||
«       | S t7        jP                  | «      st7        jR                  | «      �r	t;        | «      }
t/        | d«      r!| jT                  } tK        jV                  | «      }t/        | d«      rt?        d| jX                  z   «      ‚t[        | «       t]        | «      }|r	| |_/        |S ta        | | jb                  «      }|€tK        jV                  | «      }t        jd                  jg                  |
||ti        | «      «      }| jj                  |_5        d|_1        d|_6        | |_/        to        | |«       |S t        j&                  j(                  jq                  | «      S # 1 sw Y   �ŒxY w)Nz^`optimize` is deprecated and has no effect. Use `with torch.jit.optimized_execution()` insteadr¾   r[  zˆError: Unable to infer types. Please format the inputs to type `List[Tuple]` or `Dict[Callable, List[Tuple]]` to be run with MonkeyType.zîWarning: monkeytype is not installed. Please install https://github.com/Instagram/MonkeyType to enable Profile-Directed Typing in TorchScript. Refer to https://github.com/Instagram/MonkeyType/blob/master/README.rst to install MonkeyType. rÀ   rÅ  zType 'zO' cannot be compiled since it inherits from nn.Module, pass an instance insteadzLTorchScript classes must be new-style classes. Please inherit from 'object'.z\TorchScript classes does not support inheritance yet. Please directly inherit from 'object'.r(   Ú__script_if_tracing_wrapperÚ__script_unsupportedzTorchScript error: r+   r,   )9rÆ   rÇ   ÚFutureWarningr�   rý   r‚   r+   r   r=   r   r   r‹  rR   ÚlistÚ
ValueErrorru   rÆ  r!   rÍ  r˜   r™   rš   r   rG   rÅ  rÐ  rÔ  r’  Úisclassr   Ú
issubclassra   ÚenumÚEnumrI   r\   ÚmrorÉ   rÊ   r   r�  r�  Ú__original_fnÚ#createResolutionCallbackFromClosurerÙ  Ú"_check_directly_compile_overloadedr   Ú_torchdynamo_inliner    rn   rv   Ú_jit_script_compiler   r  rp   r   Úcreate_script_class)r·   ÚoptimizeÚ
_frames_uprÌ   rÖ  Úmonkeytype_configry   Úexample_inputÚexampleÚexamplesÚqualified_nameÚmaybe_already_compiled_fnrÍ   rË   s                 r3   Ú_script_implrð  n  s°  € ð ÐÜ�‰ðAäØõ		
ô �#Ô+Ô,Øˆ
Ü�#”|Ô$Øˆ
Ü�#”~Ô&Øˆ
áô
 *Ó+ˆÝä 2´=Ó AÐÜ!Ð"3Ó4ñ Ü˜n¬dÔ3ð 2@×1EÑ1EÓ1Gò -Ñ-˜ Ø'4ò -˜GÙ" GÒ,ñ-ñ-ô   ´Ô5Ø$2ò '˜Ù˜Xšñ'ô %ðWóð ÷ð ô& �M‰Mðið õ	ô �#”u—x‘x—‘Ô'Ü*¨3Ó/ˆÜ�y‰y×#Ñ#×8Ñ8Ø”—‘×%Ñ%×>Ñ>ó
ð 	
ô �sÐ4Ô5ð ×&Ñ&Ô(àð 	ô �#”tÔÜ! #Ó&Ð&Ü�#”tÔÜ! #Ó&Ð&ä‡��sÔÜ(¨Ó-ˆô �cœ5Ÿ8™8Ÿ?™?Ô+ÜØ˜˜ÐlÐmóð ô �cœ4Ÿ9™9Ô%ØˆJä" 3Ô'Üð0óð ô ˆs�w‰w‹y‹>˜AÒÜð9óð ð ˆ<Ü ×BÑBÀ:ÐPQÁ>ÓRˆDÜ# C¨¨~Ô>Øˆ
Ü	×	Ñ	˜CÔ	 ¤G×$4Ñ$4°SÕ$9Ü(¨Ó-ˆä�3Ð5Ô6Ø×#Ñ#ˆCÜ ×DÑDÀSÓIˆDô �3Ð.Ô/ÜÐ4°s×7OÑ7OÑOÓPÐPä*¨3Ô/Ü$@ÀÓ$EÐ!Ù$Ø<?Ð%Ô9Ø,Ð,Ü˜#˜sŸ|™|Ó,ˆØˆ<Ü ×DÑDÀSÓIˆDÜ�X‰X×)Ñ)Ø˜C Ô'7¸Ó'<ó
ˆð —[‘[ˆŒ
Ø&ˆŒØ4ˆŒà!$ˆÔÜ  RÔ(Øˆ	ä�y‰y×#Ñ#×7Ñ7¸Ó<Ð<÷Mñ ús   ÂAP Ð P
r·   rè  ré  rÌ   c                 ó   — t         j                  dk\  rt        j                  dt        «       nt        j                  dt        «       t
        s| S 	 t        }dat        | ||dz   ||¬«      }|rt        dt        |«      ¬«       ||aS # aw xY w)	a­  Script the function.

    Scripting a function or ``nn.Module`` will inspect the source code, compile
    it as TorchScript code using the TorchScript compiler, and return a :class:`ScriptModule` or
    :class:`ScriptFunction`. TorchScript itself is a subset of the Python language, so not all
    features in Python work, but we provide enough functionality to compute on
    tensors and do control-dependent operations. For a complete guide, see the
    :ref:`language-reference`.

    Scripting a dictionary or list copies the data inside it into a TorchScript instance than can be
    subsequently passed by reference between Python and TorchScript with zero copy overhead.

    ``torch.jit.script`` can be used as a function for modules, functions, dictionaries and lists
     and as a decorator ``@torch.jit.script`` for torchscript-classes and functions.

    Args:
        obj (Callable, class, or nn.Module):  The ``nn.Module``, function, class type,
                                                  dictionary, or list to compile.
        example_inputs (Union[List[Tuple], Dict[Callable, List[Tuple]], None]): Provide example inputs
            to annotate the arguments for a function or ``nn.Module``.

    Returns:
        If ``obj`` is ``nn.Module``, ``script`` returns
        a :class:`ScriptModule` object. The returned :class:`ScriptModule` will
        have the same set of sub-modules and parameters as the
        original ``nn.Module``. If ``obj`` is a standalone function,
        a :class:`ScriptFunction` will be returned. If ``obj`` is a ``dict``, then
        ``script`` returns an instance of `torch._C.ScriptDict`. If ``obj`` is a ``list``,
        then ``script`` returns an instance of `torch._C.ScriptList`.

    **Scripting a function**
        The ``@torch.jit.script`` decorator will construct a :class:`ScriptFunction`
        by compiling the body of the function.

        Example (scripting a function):

        .. testcode::

            import torch

            @torch.jit.script
            def foo(x, y):
                if x.max() > y.max():
                    r = x
                else:
                    r = y
                return r

            print(type(foo))  # torch.jit.ScriptFunction

            # See the compiled graph as Python code
            print(foo.code)

            # Call the function using the TorchScript interpreter
            foo(torch.ones(2, 2), torch.ones(2, 2))

        .. testoutput::
            :hide:

            ...

    ****Scripting a function using example_inputs**
        Example inputs can be used to annotate a function arguments.

        Example (annotating a function before scripting):

        .. testcode::

            import torch

            def test_sum(a, b):
                return a + b

            # Annotate the arguments to be int
            scripted_fn = torch.jit.script(test_sum, example_inputs=[(3, 4)])

            print(type(scripted_fn))  # torch.jit.ScriptFunction

            # See the compiled graph as Python code
            print(scripted_fn.code)

            # Call the function using the TorchScript interpreter
            scripted_fn(20, 100)

        .. testoutput::
            :hide:

            ...

    **Scripting an nn.Module**
        Scripting an ``nn.Module`` by default will compile the ``forward`` method and recursively
        compile any methods, submodules, and functions called by ``forward``. If a ``nn.Module`` only uses
        features supported in TorchScript, no changes to the original module code should be necessary. ``script``
        will construct :class:`ScriptModule` that has copies of the attributes, parameters, and methods of
        the original module.

        Example (scripting a simple module with a Parameter):

        .. testcode::

            import torch

            class MyModule(torch.nn.Module):
                def __init__(self, N, M):
                    super().__init__()
                    # This parameter will be copied to the new ScriptModule
                    self.weight = torch.nn.Parameter(torch.rand(N, M))

                    # When this submodule is used, it will be compiled
                    self.linear = torch.nn.Linear(N, M)

                def forward(self, input):
                    output = self.weight.mv(input)

                    # This calls the `forward` method of the `nn.Linear` module, which will
                    # cause the `self.linear` submodule to be compiled to a `ScriptModule` here
                    output = self.linear(output)
                    return output

            scripted_module = torch.jit.script(MyModule(2, 3))

        Example (scripting a module with traced submodules):

        .. testcode::

            import torch
            import torch.nn as nn
            import torch.nn.functional as F

            class MyModule(nn.Module):
                def __init__(self) -> None:
                    super().__init__()
                    # torch.jit.trace produces a ScriptModule's conv1 and conv2
                    self.conv1 = torch.jit.trace(nn.Conv2d(1, 20, 5), torch.rand(1, 1, 16, 16))
                    self.conv2 = torch.jit.trace(nn.Conv2d(20, 20, 5), torch.rand(1, 20, 16, 16))

                def forward(self, input):
                    input = F.relu(self.conv1(input))
                    input = F.relu(self.conv2(input))
                    return input

            scripted_module = torch.jit.script(MyModule())

        To compile a method other than ``forward`` (and recursively compile anything it calls), add
        the :func:`@torch.jit.export <torch.jit.export>` decorator to the method. To opt out of compilation
        use :func:`@torch.jit.ignore <torch.jit.ignore>` or :func:`@torch.jit.unused <torch.jit.unused>`.

        Example (an exported and ignored method in a module)::

            import torch
            import torch.nn as nn


            class MyModule(nn.Module):
                def __init__(self) -> None:
                    super().__init__()

                @torch.jit.export
                def some_entry_point(self, input):
                    return input + 10

                @torch.jit.ignore
                def python_only_fn(self, input):
                    # This function won't be compiled, so any
                    # Python APIs can be used
                    import pdb

                    pdb.set_trace()

                def forward(self, input):
                    if self.training:
                        self.python_only_fn(input)
                    return input * 99


            scripted_module = torch.jit.script(MyModule())
            print(scripted_module.some_entry_point(torch.randn(2, 2)))
            print(scripted_module(torch.randn(2, 2)))

        Example ( Annotating forward of nn.Module using example_inputs)::

            import torch
            import torch.nn as nn
            from typing import NamedTuple

            class MyModule(NamedTuple):
            result: List[int]

            class TestNNModule(torch.nn.Module):
                def forward(self, a) -> MyModule:
                    result = MyModule(result=a)
                    return result

            pdt_model = TestNNModule()

            # Runs the pdt_model in eager model with the inputs provided and annotates the arguments of forward
            scripted_model = torch.jit.script(pdt_model, example_inputs={pdt_model: [([10, 20, ], ), ], })

            # Run the scripted_model with actual inputs
            print(scripted_model([20]))
    r½   zv`torch.jit.script` is not supported in Python 3.14+ and may break. Please switch to `torch.compile` or `torch.export`.zU`torch.jit.script` is deprecated. Please switch to `torch.compile` or `torch.export`.Fr(   )r·   rè  ré  rÌ   rÖ  Úscript)Úmodel_id)
rÄ   rÅ   rÆ   rÇ   rÈ   r   rÕ  rð  r   r   )r·   rè  ré  rÌ   rÖ  ÚprevÚrets          r3   rò  rò  ù  s”   € ô` ×Ñ˜7Ò"Ü�‰ðBäõ	
ô 	�‰ØcÜô	
õ Øˆ
ðäˆØˆ	ÜØØØ! A‘~ØØ)ô
ˆñ Ü! (´]À3Ó5GÕHàà‰	ø�D‰	ús   Á4B	 Â	Bc                 ó¦   — |j                  «       D ]>  \  }}|| vs	| |   |k7  sŒt        j                  j                  j	                  |d|› �«      ‚ y )Nz™Default parameters on overloads do not affect the runtime so they must equal to the default parameter on the implementation function. Found on parameter )rR   ru   r˜   ÚfrontendÚFrontendError)Úimpl_defaultsÚoverload_defaultsÚlocrA   Úoverload_values        r3   Ú_check_overload_defaultsrý  î  sb   € Ø 1× 7Ñ 7Ó 9ò ÑˆˆnØ�}Ñ$¨°dÑ(;¸~Ó(MÜ—)‘)×$Ñ$×2Ñ2Øðà!˜Fð$óð ñr5   c                 óÌ  — t        | | j                  «      j                  «       }t        j                  j
                  j                  | d d t        j                  | «      «      }t        ||j                  «      }t        | «      }t        |«      }t        j                  |«      }t        |||j                  «       «       t        j                  j                  ||||||«      }	|	S r:   )r    rn   Údeclru   r˜   ÚannotationsÚget_signaturer’  r�  r   rÉ   rã  rý  Úrangerv   Ú_jit_script_compile_overload)
Úoverload_fnÚ	qual_nameÚimpl_fnÚoverload_declÚoverload_signatureÚimpl_astrú  Úimplementation_defaultsrÌ   rË   s
             r3   Ú_compile_function_with_overloadr  ù  sÎ   € Ü ¨[×-AÑ-AÓB×GÑGÓI€MÜŸ™×.Ñ.×<Ñ<Ø�T˜4¤×!1Ñ!1°+Ó!>óÐô ˜7 G×$4Ñ$4Ó5€HÜ(¨Ó5ÐÜ.¨wÓ7ÐÜ×<Ñ<¸WÓE€DÜØÐ!2°M×4GÑ4GÓ4Iôô 
�‰×	.Ñ	.ØØØØØØó
€Bð €Ir5   c                 ó8  — t        | «      }t        | «      }t        j                  |«      }|€|S | |v rt	        t        j
                  d| «      «      ‚|D �cg c]  }t        ||| «      ‘Œ }}|r||z   }t        | |«       t        j                  |«       |S c c}w )NÚfunction)	r   r   rÉ   Ú_get_fn_overloadsra   Ú,get_overload_no_implementation_error_messager  r   Ú_clear_fn_overloads)r·   Úexisting_compiled_fnsr  Úuncompiled_overloadsr  Úcompiled_fnss         r3   Ú_get_overloadsr    s·   € ä9¸#Ó>ÐÜ Ó$€IÜ(×:Ñ:¸9ÓEÐØÐ#Ø$Ð$à
Ð"Ñ"ÜÜ×FÑFÀzÐSVÓWó
ð 	
ð 0öàô 	(¨°YÀÕDð€Lð ñ
 Ø,¨|Ñ;ˆô ˜C Ô.Ü×%Ñ% iÔ0ØÐùòs   ÁBc                 óx   — t        | «      }t        j                  |«      st        | «      rt	        d|› d�«      ‚y )Nz	Function z˜ cannot be directly compiled because it is overloaded. It must be used in a context of a function where its inputs can determine which overload to call.)r   rÉ   r  r   ra   )r·   r  s     r3   rä  rä  +  sI   € Ü Ó$€IÜ×&Ñ& yÔ1Ô5RÐSVÔ5WÜØ˜	�{ð #Fð Fó
ð 	
ð 6Xr5   c                 ó:  — t        j                  dt        «       t        j                  | «      st        d«      ‚t        | «      st        d«      ‚t        | t        j                  j                  «      xr t        | j                  «       «      dk(  }|s't        | j                  «       «      dkD  rt        d«      ‚t        | «      }t        j                  d«      }t!        | | j"                  «      }t        j$                  j'                  ||||«      }|| _        | S )a¸  Decorate to annotate classes or modules of different types.

    .. deprecated:: 2.5
        TorchScript is deprecated, please use ``torch.compile`` instead.

    This decorator can be used to define an interface that can be used to annotate
    classes or modules of different types. This can be used for to annotate a submodule
    or attribute class that could have different types that implement the same
    interface, or which could be swapped at runtime; or to store a list of modules or
    classes of varying types.

    It is sometimes used to implement "Callables" - functions or modules that implement
    an interface but whose implementations differ and which can be swapped out.

    Example:
    .. testcode::

        import torch
        from typing import List

        @torch.jit.interface
        class InterfaceType:
            def run(self, x: torch.Tensor) -> torch.Tensor:
                pass

        # implements InterfaceType
        @torch.jit.script
        class Impl1:
            def run(self, x: torch.Tensor) -> torch.Tensor:
                return x.relu()

        class Impl2(torch.nn.Module):
            def __init__(self) -> None:
                super().__init__()
                self.val = torch.rand(())

            @torch.jit.export
            def run(self, x: torch.Tensor) -> torch.Tensor:
                return x + self.val

        def user_fn(impls: List[InterfaceType], idx: int, val: torch.Tensor) -> torch.Tensor:
            return impls[idx].run(val)

        user_fn_jit = torch.jit.script(user_fn)

        impls = [Impl1(), torch.jit.script(Impl2())]
        val = torch.rand(4, 4)
        user_fn_jit(impls, 0, val)
        user_fn_jit(impls, 1, val)
    zH`torch.jit.interface` is deprecated. Please use `torch.compile` instead.z$interface must be applied to a classz1TorchScript interfaces must inherit from 'object'r¾   rÀ   zmTorchScript interface does not support inheritance yet. Please directly inherit from 'object' or 'nn.Module'.r(   )rÆ   rÇ   rÈ   r’  rÝ  ra   rI   rÞ  ru   rÆ  r!   r\   rá  r   rÉ   rÊ   r   rn   rv   Ú_jit_script_interface_compileÚ__torch_script_interface__)r·   Úis_module_interfacerî  r0  rÍ   Úmangled_classnames         r3   Ú	interfacer  5  sô   € ôf ‡M�MØRÜôô �?‰?˜3ÔÜÐAÓBÐBÜ˜sÔ#ÜÐNÓOÐOô % S¬%¯(©(¯/©/Ó:ÒR¼sÀ3Ç7Á7Ã9»~ÐQRÑ?RÐá¤3 s§w¡w£y£>°AÒ#5ÜðDó
ð 	
ô
 % SÓ)€NÜ
×
9Ñ
9¸!Ó
<€Cô ˜C §¡Ó
.€CÜŸ™×>Ñ>Ø˜˜SÐ"5óÐð &7€CÔ"Ø€Jr5   c                 óœ   — t        | «      }t        j                  j                  ||«      }t	        j
                  | «      }t        | ||«      S r:   )r   ru   rv   Ú	CallStackrÉ   Ú'createResolutionCallbackForClassMethodsr   )r·   rû  Ú
_qual_nameÚerror_stackr0  s        r3   Ú_recursive_compile_classr!  Š  sC   € Ü  Ó%€Jô —(‘(×$Ñ$ Z°Ó5€KÜ
×
?Ñ
?ÀÓ
D€CÜ& s¨C°Ó<Ð<r5   ÚsÚpaddingÚoffsetÚcharc                 ó    — |t        | «      k\  r|t        | «      z  }dj                  t        ||z   «      D �cg c]  }|‘Œ c}«      | z   S c c}w rk  )r\   Újoinr  )r"  r#  r$  r%  r¤   s        r3   Úpadr(  —  sH   € Ø”#�a“&ÒØ”3�q“6ÑˆØ�7‰7¤%¨°&Ñ(8Ó"9Ö:˜Q’DÒ:Ó;¸aÑ?Ð?ùÒ:s   ¸	Ac                   ó8   — e Zd Zd
dededefd„Zdedefd„Zd„ Zy	)Ú_ScriptProfileColumnÚheaderÚ	alignmentr$  c                 ó<   — || _         || _        || _        i | _        y r:   )r+  r,  r$  Úrows)rN   r+  r,  r$  s       r3   rO   z_ScriptProfileColumn.__init__ž  s   € ØˆŒØ"ˆŒØˆŒØ$&ˆ�	r5   Úlinenor7   c                 ó"   — || j                   |<   y r:   )r.  )rN   r/  r7   s      r3   Úadd_rowz_ScriptProfileColumn.add_row¤  s   € Ø!ˆ�	‰	�&Òr5   c           
      óè  — t        | j                  «      }g }| j                  j                  «       D ]8  \  }}t	        |«      }|j                  ||f«       t        t        |«      |«      }Œ: | j                  dkD  r"|| j                  z   }||| j                  z  z  }nd}|D ��cg c]  \  }}|t        ||| j                  «      f‘Œ  }}}t        | j                  || j                  «      |fS c c}}w )Nr   )
r\   r+  r.  rR   r×   ÚappendÚmaxr,  r(  r$  )rN   Ú
max_lengthr.  r„  r7   Úcellr#  s          r3   Úmaterializez _ScriptProfileColumn.materialize§  sÛ   € Ü˜Ÿ™Ó%ˆ
Ø&(ˆØŸ)™)Ÿ/™/Ó+ò 	4‰JˆC�Ü�u“:ˆDØ�K‰K˜˜d˜Ô$ÜœS ›Y¨
Ó3‰Jð	4ð
 �>‰>˜AÒØ  4§>¡>Ñ1ˆGØ�w §¡Ñ/Ñ/‰GàˆGàHL×M¹9¸3À�”c˜$ ¨¯©Ó5Ò6ÐMˆÑMÜ�4—;‘; ¨¯©Ó5°tÐ;Ð;ùó Ns   Â%#C.N)é   r   )	rn   ro   rp   r×   r8  rO   r   r1  r7  r;   r5   r3   r*  r*  �  s4   „ ñ'˜sð '¨sð 'Àó 'ð"˜cð "¨#ó "ó<r5   r*  c                   ó.   — e Zd Zdee   dee   fd„Zd„ Zy)Ú_ScriptProfileTableÚcolsÚsource_rangec                 ó    — || _         || _        y r:   )r;  r<  )rN   r;  r<  s      r3   rO   z_ScriptProfileTable.__init__º  s   € ØˆŒ	Ø(ˆÕr5   c           	      óæ  — g }g }d}| j                   D ]6  }|j                  «       \  }}||z  }|j                  |t        |«      f«       Œ8 |j                  |«       |j                  t	        dt        |«      dd«      «       | j                  D ]P  }d}|D ]6  \  }}|j                  |«      }	|	€|t	        dt        |«      «      z  }Œ2||	z  }Œ8 |j                  |«       ŒR dj                  |«      S )Nrl  r   ú=ú
)	r;  r7  r3  r‹  r(  r\   r<  r	  r'  )
rN   ÚoutputsÚcellsÚheader_bufferÚcolr+  r.  ÚlineÚ
row_bufferr6  s
             r3   Údump_stringz_ScriptProfileTable.dump_string¾  sú   € ØˆØ24ˆØˆØ—9‘9ò 	/ˆCØŸ?™?Ó,‰LˆF�DØ˜VÑ#ˆMØ�L‰L˜&¤$ t£*Ð-Õ.ð	/ð
 	�‰�}Ô%Ø�‰”s˜2œs =Ó1°1°cÓ:Ô;Ø×%Ñ%ò 	'ˆDØˆJØ %ò '‘�˜Ø—x‘x “~�Ø�<Ø¤# b¬#¨f«+Ó"6Ñ6‘Jà $Ñ&‘Jð'ð �N‰N˜:Õ&ð	'ð �y‰y˜Ó!Ð!r5   N)rn   ro   rp   rÛ  r*  r8  rO   rG  r;   r5   r3   r:  r:  ¹  s$   „ ð)˜TÐ"6Ñ7ð )ÀtÈCÁyó )ó"r5   r:  c                   ó2   — e Zd Zdd„Zd„ Zd„ Zdefd„Zd„ Zy)	Ú_ScriptProfilerÒ   Nc                 óJ   — t         j                  j                  «       | _        y r:   )r   Ú	profilingrI  Úprofiler]   s    r3   rO   z_ScriptProfile.__init__Ö  s   € Ü×(Ñ(×7Ñ7Ó9ˆ�r5   c                 ó8   — | j                   j                  «        y r:   )rL  Úenabler]   s    r3   rN  z_ScriptProfile.enableÙ  s   € Ø�‰×ÑÕr5   c                 ó8   — | j                   j                  «        y r:   )rL  Údisabler]   s    r3   rP  z_ScriptProfile.disableÜ  s   € Ø�‰×ÑÕr5   c                 ób  — g }| j                   j                  «       D �]z  }|j                  «       }|j                  «       j	                  «       }t        d„ |D «       «      }|D �cg c]  }||d  ‘Œ	 }}|j                  «       }|t        |«      z   }t        ||«      }	t        d«      }
t        d«      }t        d«      }t        ddd«      }|j                  «       }|	D ]€  }|
j                  ||«       |j                  ||||z
     «       |j                  |«      }|€ŒA|j                  ||j                  «       «       |j                  ||j                  «       «       Œ‚ t        |
|||gt!        |	«      «      }|j#                  |j%                  «       «       �Œ} dj'                  |«      S c c}w )	Nc              3   óh   K  — | ]*  }t        |«      t        |j                  d «      «      z
  –— Œ, y­w)ú N)r\   Úlstrip)Ú.0rE  s     r3   ú	<genexpr>z-_ScriptProfile.dump_string.<locals>.<genexpr>ä  s'   è ø€ ÒT¸tœ˜T›¤S¨¯©°SÓ)9Ó%:Õ:ÑTùs   ‚02zLine #ÚHitsz	Time (ns)zLine Contentsr   r(   z

)rL  Ú_dump_statsÚsourceÚtextÚ
splitlinesÚminÚstarting_linenor\   r  r*  Úline_mapr1  r	  ÚcountÚduration_nsr:  rÛ  r3  rG  r'  )rN   rA  Úsource_statsÚ
source_refÚsource_linesÚdedentrE  Ú
start_lineÚend_liner<  r/  ÚhitsÚtime_nsÚline_contentsÚstatsÚstatÚtables                    r3   rG  z_ScriptProfile.dump_stringß  s”  € ØˆØ ŸL™L×4Ñ4Ó6ó 	0ˆLØ%×,Ñ,Ó.ˆJØ%Ÿ?™?Ó,×7Ñ7Ó9ˆLÜÑTÀ|ÔTÓTˆFØ6BÖC¨d˜D  šMÐCˆLÐCà#×3Ñ3Ó5ˆJØ!¤C¨Ó$5Ñ5ˆHÜ  ¨XÓ6ˆLÜ)¨(Ó3ˆFÜ'¨Ó/ˆDÜ*¨;Ó7ˆGÜ0°À!ÀQÓGˆMØ ×)Ñ)Ó+ˆEØ$ò >�Ø—‘˜t TÔ*Ø×%Ñ% d¨L¸À
Ñ9JÑ,KÔLØ—y‘y “�ØÑ#Ø—L‘L  t§z¡z£|Ô4Ø—O‘O D¨$×*:Ñ*:Ó*<Õ=ð>ô (Ø˜˜w¨Ð6¼¸\Ó8JóˆEð �N‰N˜5×,Ñ,Ó.Ö/ð3	0ð4 �{‰{˜7Ó#Ð#ùò- Ds   Á%F,c                 ó6   — t        | j                  «       «       y r:   )ÚprintrG  r]   s    r3   Údumpz_ScriptProfile.dumpý  s   € Üˆd×ÑÓ Õ!r5   r:  )	rn   ro   rp   rO   rN  rP  r×   rG  ro  r;   r5   r3   rI  rI  Õ  s"   „ ó:òòð$˜Só $ó<"r5   rI  c                 ó    — | €t        d«      ‚| S )NzUnwrapping null optional)ÚAssertionError)r‘  s    r3   Ú_unwrap_optionalrr    s   € Ø€yÜÐ7Ó8Ð8Ø€Hr5   zaten::_unwrap_optionalzaten::is_scriptingzaten::has_torch_functionr:   )Nr   NN)r   rS  )Œr  Úcollectionsru  rß  r«   r’  r/   rÄ   rÆ   Úcollections.abcr   r   r   r   Útypingr   r   Útyping_extensionsr	   r
   ru   Útorch._jit_internalrÉ   Útorch._classesr   r   r   Útorch._utils_internalr   Útorch.jit._builtinsr   Útorch.jit._fuserr   r   Útorch.jit._monkeytype_configr   r   r   Útorch.jit._recursiver   r   r   r   Útorch.jit._stater   r   r   r   r   Útorch.jit.frontendr   r   r    Útorch.nnr!   Útorch.overridesr"   r#   r$   Útorch.packager%   r&   Útorch.utilsr'   Ú_serializationr)   r*   r=   rv   rN  ri  r+   rn   rp   r4   Ú
__reduce__Ú
namedtupler6   r>   rB   rI   rK   rr   r8   r‡   r³   ÚWarningrº   rÎ   rÐ   r×   rÆ  rã   Ú_magic_methodsrý   r  r  rf   r‚   r>  rE   rR   rA   ÚitemÚcallabler�   r  Ú
startswithrG   r•  Ú_compiled_methods_allowlistrº  ÚmethodÚendswithrÈ  rÍ  rÐ  rÔ  rÕ  Úboolr+  rÛ  Útupler‹  rð  r8  rò  rý  r  r  rä  r  r!  rÝ   r(  r*  r:  rI  rr  Úis_scriptingr;   r5   r3   ú<module>r’     sÐ  ðòó Û Û Û Û Û Û 
Û ß AÓ Aß ß .ã Ý +Ý "ß >Ý 7Ý 1ß A÷ñ ÷
ó ÷õ ÷ PÑ OÝ ÷ñ ÷
 ;Ý "å 1ñ ˆTƒ]€ñ "Ó#€à":€‡�× Ñ Ô Ø$.€‡�× Ñ Ô !Ø—‘×(Ñ(€ð€Ô ð +€Ô Ø8€Ô Ù 
ˆ>˜;Ô 'ò
Að $€Ô ñ Ø&�×&Ñ& {°W¸fÐ4EÓF�IòðI€	Ô òXò$òC÷( "ñ  "ôF&'Ð*ô &'ôb;-�ô ;-÷|+ñ +ô
	�Gô 	ò+÷>(ñ (ð'Øð'Ø14ð'à
‡X�X‡_�_ó'ò0 ò€N÷>?Cñ ?CðB &ò Dˆò	Kñ 	Ð$ k°?ÕCðDôTB�v¨õ TBôlU ô Uðz
 ,×4Ñ4×:Ñ:Ó<ò *‰
ˆˆdÙ˜Œ~¡j°°xÔ&@ØØ�?‰?˜4Ô ¡G¨L¸$Ô$?Øñ 	�˜d DÕ)ð*ò
ò&#ÐòPñ % U§X¡X§_¡_Ó5ò N‰ˆˆfØ�?‰?˜4Ô  D§M¡M°,Ô$?Øð Ð-×6Ñ6Ò6ØÐ7Ò7áÐ)¨6¯?©?¹JÀtÓ<LÕMñN÷ñ ô�u—x‘x—‘ô ô ô ò
$òN8ò
$ó $ð €	ˆ4Ó ð
 ØØ	ØGKñH=ð
 ˜‘K $ x°°e±Ð'<Ñ"=Ñ=ÀÑDóH=ðZ ØØ(,ØGKñnØ	ðnàðnð ðnð �C�5˜#�:Ñ
 Ñ
%ð	nð
 ˜‘K $ x°°e±Ð'<Ñ"=Ñ=ÀÑDðnð 	ónòjòò.ò6
ðR�2ð R˜"ó Ròj=ð —(‘(×*Ò*€Ù 
ˆ?˜KÔ (ñ@ˆ3ð @˜ð @ cð @°Só @÷<ñ <÷8"ñ "÷8)"ñ )"òXñ Ð"Ð$<Ô =Ù �-×,Ò,Ð.BÔ CÙ Ð$Ð&@Ô AÙ Ð*Ð,FÔ GÙ Ð-Ð/IÕ Jr5   