§
    ŠŠtjÀ ã                  óœ  — U d dl m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
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 d dlmZmZmZmZm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 Z d dl!m"c m#Z$ d dl%m&Z'm(Z( d d	l)m*Z*m+Z+ d d
l,m-Z- d dl.m/Z/ ddl0m#Z1 ddl2m3Z3 ddl4m5Z5 ddl6m7Z7m8Z8m9Z9m:Z:m;Z; ddl<m=Z=  e	j>        e?¦  «        Z@g d¢ZAerd dlBZBddlCmDZD ddlEmFZF eGejH        eIejJ        eKejL        eMejN        eOejP        iZQeI R                    g d¢¦  «        ZSeeGeT         geGeT         f         ZU G d„ de¦  «        ZVd„ ejW        D ¦   «         ZXeX Y                    ejZ        ¦  «         i Z[de\d<   d›d"„Z] e]d#d$e
j^        ¦  «          e]d%d&e
j_        ¦  «          e]d'd( e`d¦  «        ¦  «          e]d)d*e ¦  «          e]d+d,e ja        ¦  «          e]d-d.e1¦  «          e]d/d0e$¦  «         dœd3„Zbd�d5„Zc ejd         eje        d6¦  «        jf        d7¦  «        Zg eje        d8¦  «        Zh eje        d9¦  «        Zi eje        d:¦  «        jj        Zkdžd;„Zl G d<„ d=¦  «        Zm e3d>¬?¦  «        e G d@„ dA¦  «        ¦   «         ¦   «         ZndŸdD„Zo G dE„ dF¦  «        Zp G dG„ dH¦  «        Zq G dI„ dJe¦  «        Zr ed>¬K¦  «         G dL„ dM¦  «        ¦   «         Zs	 d d¡dR„Zt e3dS¬?¦  «         G dT„ dU¦  «        ¦   «         Zu G dV„ dWeu¦  «        Zv G dX„ dYeu¦  «        Zw G dZ„ d[ew¦  «        Zx G d\„ d]¦  «        Zy e3d>¬?¦  «         G d^„ d_¦  «        ¦   «         Zzed¢dc„¦   «         Z{d£dd„Z|d¤dg„Z}dhdidjdkdldmdndodpœZ~dq„ e~                     ¦   «         D ¦   «         Z€ eje        dr¦  «        Z�dsdtdudvdwdwdxdydzd{d|d}d~dd€d�œZ‚d‚dƒd„d…d†d‡dˆd‰dŠd‹œ	e‚¥ZƒdŒd�dŽd�d�d‘d’d“d”d•d–d—d˜d™dšœZ„dS )¥é    )ÚannotationsN)Údefaultdict)ÚCallableÚ	GeneratorÚIterableÚIteratorÚSequence)Úcontextmanager)Ú	dataclass)ÚAnyÚLiteralÚ
NamedTupleÚTYPE_CHECKING)Ú_fx_map_argÚ	_NodeIter)Úget_opaque_obj_reprÚis_opaque_value_type©Úpy_sym_types)Údtype_abbrsé   )Ú_pytree)Úcompatibility)Úimmutable_dict)Ú_get_qualified_nameÚ
_type_reprÚArgumentÚNodeÚTarget)Ú
TensorType)Ú
PythonCodeÚCodeGenÚGraph)ÚTracer)ÚGraphModule)Úcall_functionÚcall_methodÚget_attrÚcall_moduleÚplaceholderÚoutputc                  ó(   — e Zd ZU dZded<   ded<   dS )Ú_CustomBuiltinzòAdditional objs that we add to every graph's globals.

    The repr() for some standard library objects is not valid Python code without
    an import. For common objects of this sort, we bundle them in the globals of
    every FX graph.
    ÚstrÚ
import_strÚobjectÚobjN©Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__© ó    úL/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/torch/fx/graph.pyr-   r-   F   s.   € € € € € € ðð ð €O€O�Oà€K€K�K€K€Kr9   r-   c                ó,   — i | ]}|t          ¦   «         “ŒS r8   )r0   )Ú.0Úks     r:   ú
<dictcomp>r>   U   s   € Ð6Ð6Ð6 !�!•V‘X”XÐ6Ð6Ð6r9   zdict[str, _CustomBuiltin]Ú_custom_builtinsÚnamer.   r/   r1   r0   ÚreturnÚNonec                óJ   — t          ||¦  «        t          | <   |t          | <   d S ©N)r-   r?   Ú_illegal_names)r@   r/   r1   s      r:   Ú_register_custom_builtinrF   [   s'   € Ý+¨J¸Ñ<Ô<Õ�TÑØ…N�4ÑÐÐr9   Úinfzfrom math import infÚnanzfrom math import nanÚNoneTypezNoneType = type(None)Útorchzimport torchÚdevicezfrom torch import deviceÚ	fx_pytreez$import torch.fx._pytree as fx_pytreeÚpytreez$import torch.utils._pytree as pytreeÚxÚboolc                óV   — |                       d¦  «        o|                      d¦  «        S )NÚ__)Ú
startswithÚendswith©rN   s    r:   Ú	_is_magicrU   i   s%   € Ø�<Š<˜ÑÔÐ2 !§*¢*¨TÑ"2Ô"2Ð2r9   Úsc                óD   — t          | ¦  «                             ¦   «         S )zé
    Transforms the given string ``s`` to a Python-style variable name

    Examples:
        ``mod.snake_case`` -> ``mod.snake_case``
        ``mod.pascalCase``-> ``mod.pascal_case``
        ``mod.ALL_CAPS`` -> ``mod.all_caps``
    )Ú_snake_case_subÚlower)rV   s    r:   Ú_snake_caserZ   m   s   € õ ˜1ÑÔ×#Ò#Ñ%Ô%Ð%r9   z(?<=[a-z])([A-Z])z_\1z[^0-9a-zA-Z_]+z&^([a-zA-Z_][0-9a-zA-Z_]*?)(?:_(\d+))?$z,^torch(?:\.(?!_dynamo\.|_inductor\.)[^.]+)*$c                óâ   — t          | dd ¦  «        }|�t          |¦  «        d uS t          | dd ¦  «        }|�7|dk    r1t          t          j        j        fD ]}t          ||d ¦  «        | u r dS ŒdS )Nr4   r3   rJ   TF)ÚgetattrÚ_torch_but_not_dynamorJ   ÚnnÚ
functional)r1   Úmodule_namer@   Úguesss       r:   Ú_is_from_torchrb   Œ   sŽ   € Ý˜#˜|¨TÑ2Ô2€KØÐÝ$ [Ñ1Ô1¸Ð=Ð=å�3˜
 DÑ)Ô)€DàÐ˜D GšO˜OÝ�UœXÔ0Ð1ð 	ð 	ˆEÝ�u˜d DÑ)Ô)¨SÐ0Ð0Ø�t�tð 1ð ˆ5r9   c                  ó2   — e Zd ZdZdd„Zdd	„Zdd„Zdd„ZdS )Ú
_Namespacea  A context for associating names uniquely with objects.

    The following invariants are enforced:
    - Each object gets a single name.
    - Each name is unique within a given namespace.
    - Names generated do not shadow builtins, unless the object is indeed that builtin.
    rA   rB   c                óH   — i | _         t          ¦   «         | _        i | _        d S rD   )Ú_obj_to_nameÚsetÚ_used_namesÚ_base_count©Úselfs    r:   Ú__init__z_Namespace.__init__¤   s$   € Ø/1ˆÔÝ%(¡U¤UˆÔØ+-ˆÔÐÐr9   Ú	candidater.   r1   úobject | Nonec                óÒ  — |�|| j         v r| j         |         S t                               |¦  «        }|€lt                               d|¦  «        }|sd}|d                              ¦   «         rd|› �}t                               |¦  «        }|€t          d|› �¦  «        ‚|                     dd¦  «        \  }}|�	|| j        v rE| j	         
                    |d¦  «        }t           
                    ||¦  «        |ur|dz  }|› d|› �}nt          |¦  «        }|| j        v r|dz  }|› d|› �}|| j        v °| j                             |¦  «         || j	        |<   |�
|| j         |<   |S )zÜCreate a unique name.

        Arguments:
            candidate: used as the basis for the unique name, relevant to the user.
            obj: If not None, an object that will be associated with the unique name.
        NÚ_Ú_unnamedr   z&Name regex failed to match candidate: r   é   )rf   Ú_name_regexÚmatchÚ_illegal_char_regexÚsubÚisdigitÚAssertionErrorÚgrouprh   ri   ÚgetrE   ÚintÚadd)rk   rm   r1   rt   ÚbaseÚnums         r:   Úcreate_namez_Namespace.create_name©   s²  € ð ˆ?˜s dÔ&7Ð7Ð7ØÔ$ SÔ)Ð)õ ×!Ò! )Ñ,Ô,ˆØˆ=å+×/Ò/°°YÑ?Ô?ˆIàð 'Ø&�	à˜Œ|×#Ò#Ñ%Ô%ð ,Ø+ 	˜O˜O�	å×%Ò% iÑ0Ô0ˆEØˆ}Ý$ØH¸YÐHÐHñô ð ð —K’K  1Ñ%Ô%‰	ˆˆcØˆ;˜) tÔ'7Ð7Ð7ð Ô"×&Ò& t¨QÑ/Ô/ˆCÝ×!Ò! )¨SÑ1Ô1¸Ð<Ð<Ø�q‘�Ø#˜O˜O c˜O˜O�	øõ �c‘(”(ˆCà˜4Ô+Ð+Ð+Ø�1‰HˆCØ˜˜ #˜˜ˆIð ˜4Ô+Ð+Ð+ð 	Ô×Ò˜YÑ'Ô'Ð'Ø!$ˆÔ˜ÑØˆ?Ø%.ˆDÔ˜cÑ"ØÐr9   r@   r0   c                ób   — | j                              ||¦  «        }||urt          d¦  «        ‚dS )zpAssociate a unique name with an object.

        Neither `name` nor `obj` should be associated already.
        zobj is already associatedN)rf   Ú
setdefaultrx   )rk   r@   r1   Úmaybe_existings       r:   Úassociate_name_with_objz"_Namespace.associate_name_with_objÜ   s>   € ð
 Ô*×5Ò5°c¸4Ñ@Ô@ˆØ Ð%Ð%Ý Ð!<Ñ=Ô=Ð=ð &Ð%r9   c                ó†   — || j         vrt          d|› d�¦  «        ‚|| j         |<   | j                             |¦  «         d S )NzObject z is not in _obj_to_name)rf   rx   rh   r|   )rk   r1   r@   s      r:   Ú_rename_objectz_Namespace._rename_objectå   sT   € Ø�dÔ'Ð'Ð'Ý Ð!G¨3Ð!GÐ!GÐ!GÑHÔHÐHØ!%ˆÔ˜#ÑØÔ×Ò˜TÑ"Ô"Ð"Ð"Ð"r9   N©rA   rB   )rm   r.   r1   rn   rA   r.   )r@   r.   r1   r0   rA   rB   )r1   r0   r@   r.   rA   rB   )r3   r4   r5   r6   rl   r   rƒ   r…   r8   r9   r:   rd   rd   ›   so   € € € € € ðð ð.ð .ð .ð .ð
1ð 1ð 1ð 1ðf>ð >ð >ð >ð#ð #ð #ð #ð #ð #r9   rd   T©Úis_backward_compatiblec                  ó@   — e Zd ZU dZded<   ded<   ded<   dZd	ed
<   dS )r!   zZ
    Represents all the information necessary to exec or save a graph as Python code.
    r.   Úsrczdict[str, Any]Úglobalszdict[int, int | None] | NoneÚ_lineno_mapr   r{   Ú_prologue_startN)r3   r4   r5   r6   r7   r�   r8   r9   r:   r!   r!   ì   sR   € € € € € € ðð ð
 €H€H�HàÐÐÑð .Ð-Ð-Ñ-à€OÐÐÐÑÐÐr9   r!   r}   Útargetc                óˆ   — |                      d¦  «        }| }|D ]'}|                     ¦   «         s
d|› d|› d�}Œ |› d|› �}Œ(|S )Nú.zgetattr(z, "ú"))ÚsplitÚisidentifier)r}   rŽ   ÚelemsÚrÚes        r:   Ú_format_targetr—   þ   si   € Ø�LŠL˜ÑÔ€EØ€AØð ð ˆØ�~Š~ÑÔð 	Ø&˜1Ð&Ð& Ð&Ð&Ð&ˆAˆAà�
�
�q�
�
ˆAˆAØ€Hr9   c                  ó&   — e Zd Zdd„Zdd„Zdd„ZdS )Ú_InsertPointÚgraphr#   Ú
new_insertúCallable[..., None]rA   rB   c                ó<   — || _         |j        |c| _        |_        d S rD   )rš   Ú_insertÚorig_insert)rk   rš   r›   s      r:   rl   z_InsertPoint.__init__
  s    € ØˆŒ
Ø*/¬-¸Ð'ˆÔ˜%œ-˜-˜-r9   c                ó   — d S rD   r8   rj   s    r:   Ú	__enter__z_InsertPoint.__enter__  s   € Øˆr9   Útypeútype[BaseException] | NoneÚvalueúBaseException | NoneÚtbútypes.TracebackType | Nonec                ó(   — | j         | j        _        d S rD   )rŸ   rš   rž   )rk   r¢   r¤   r¦   s       r:   Ú__exit__z_InsertPoint.__exit__  s   € ð "Ô-ˆŒ
ÔÐÐr9   N)rš   r#   r›   rœ   rA   rB   r†   )r¢   r£   r¤   r¥   r¦   r§   rA   rB   )r3   r4   r5   rl   r¡   r©   r8   r9   r:   r™   r™   	  sT   € € € € € ðDð Dð Dð Dðð ð ð ð.ð .ð .ð .ð .ð .r9   r™   c                  ó2   — e Zd Z	 ddd„Zdd
„Zdd„Zdd„ZdS )Ú
_node_listÚ_nextrš   r#   Ú	directionúLiteral['_prev', '_next']rA   rB   c                óN   — |dvrt          d|› �¦  «        ‚|| _        || _        d S )N)r¬   Ú_prevz*direction must be '_next' or '_prev', got )rx   rš   r­   )rk   rš   r­   s      r:   rl   z_node_list.__init__  sA   € ð Ð.Ð.Ð.Ý ØH¸YÐHÐHñô ð ð ˆŒ
Ø"ˆŒˆˆr9   r{   c                ó   — | j         j        S rD   )rš   Ú_lenrj   s    r:   Ú__len__z_node_list.__len__%  s   € ØŒzŒÐr9   úIterator[Any]c                óH   — t          | j        j        | j        dk    ¦  «        S )Nr°   ©r   rš   Ú_rootr­   rj   s    r:   Ú__iter__z_node_list.__iter__-  ó   € Ý˜œÔ)¨4¬>¸WÒ+DÑEÔEÐEr9   c                óH   — t          | j        j        | j        dk    ¦  «        S )Nr¬   r¶   rj   s    r:   Ú__reversed__z_node_list.__reversed__0  r¹   r9   N)r¬   )rš   r#   r­   r®   rA   rB   )rA   r{   )rA   r´   )r3   r4   r5   rl   r³   r¸   r»   r8   r9   r:   r«   r«     sv   € € € € € àCJð#ð #ð #ð #ð #ðð ð ð ðFð Fð Fð FðFð Fð Fð Fð Fð Fr9   r«   c                  ó2   — e Zd ZU dZded<   ded<   ded<   dS )	Ú_PyTreeInfoz=
    Contains extra info stored when we're using Pytrees
    ú	list[str]Ú	orig_argszpytree.TreeSpecÚin_speczpytree.TreeSpec | NoneÚout_specNr2   r8   r9   r:   r½   r½   4  sB   € € € € € € ðð ð ÐÐÑØÐÐÑØ$Ð$Ð$Ñ$Ð$Ð$r9   r½   )Úfrozenc                  óD   — e Zd ZU dZded<   ded<   ded<   ded<   d
d„Zd	S )Ú_ParsedStackTracez?
    Represents the top-most frame of a parsed stack trace
    r.   ÚfileÚlinenor@   ÚcoderA   c                óF   — d| j         › d| j        › d| j        › d| j        › �S )NzFile: ú:z in z, code: )rÅ   rÆ   r@   rÇ   rj   s    r:   Úget_summary_strz!_ParsedStackTrace.get_summary_strI  s0   € ØS˜œ	ÐSÐS D¤KÐSÐS°T´YÐSÐSÈÌ	ÐSÐSÐSr9   N©rA   r.   )r3   r4   r5   r6   r7   rÊ   r8   r9   r:   rÄ   rÄ   >  s`   € € € € € € ðð ð €I€I�IØ€K€K�KØ€I€I�IØ€I€I�IðTð Tð Tð Tð Tð Tr9   rÄ   Ústack_traceÚ	filter_fnú&Callable[[str, str, str], bool] | Noneú_ParsedStackTrace | Nonec                ó.  — | €d S t          j        d¦  «        }|                      ¦   «                              d¦  «        }t	          t          |¦  «        dz
  dd¦  «        D ]³}||                              ¦   «         }|                     |¦  «        }|r€|                     d¦  «        }|                     d¦  «        }|                     d¦  «        }	||dz                                 ¦   «         }
|r |||	|
¦  «        sŒŸt          |||	|
¦  «        c S Œ´d S )Nz$^File \"(.+)\", line (\d+), in (.+)$ú
rr   éÿÿÿÿr   é   )	ÚreÚcompileÚstripr’   ÚrangeÚlenrt   ry   rÄ   )rÌ   rÍ   ÚpatternÚlinesÚidxÚlineÚmatchesrÅ   rÆ   r@   rÇ   s              r:   Ú_parse_stack_tracerÞ   N  s%  € ð ÐØˆtÝŒjÐ@ÑAÔA€GØ×ÒÑÔ×%Ò% dÑ+Ô+€Eõ •S˜‘Z”Z !‘^ R¨Ñ,Ô,ð ?ð ?ˆØ�SŒz×ÒÑ!Ô!ˆØ—-’- Ñ%Ô%ˆØð 	?Ø—=’= Ñ#Ô#ˆDØ—]’] 1Ñ%Ô%ˆFØ—=’= Ñ#Ô#ˆDà˜˜q™”>×'Ò'Ñ)Ô)ˆDØð   ¨4°°tÑ!<Ô!<ð ØÝ$ T¨6°4¸Ñ>Ô>Ð>Ð>Ð>ð	?ð ˆ4r9   Fc                  ó°   — e Zd ZU d„ Zded<   d?d„Zd@d
„ZdAd„ZdBd„Z	 	 	 dCdDd„Z	dEd„Z
dFd„Zd d!œdGd&„Zddd'œdHd*„ZdId+„ZdJd-„ZdKd/„Zd d d d d d dd0œdLd>„ZdS )Mr"   c                ó    — t          | ¦  «        S rD   ©ÚreprrT   s    r:   ú<lambda>zCodeGen.<lambda>j  s   € Å$ÀqÁ'Ä'€ r9   ú&Callable[[torch.types.PySymType], str]Ú	_sym_reprrA   rB   c                ó"   — d | _         d| _        d S )NÚforward)Ú_body_transformerÚ
_func_namerj   s    r:   rl   zCodeGen.__init__l  s   € Ø;?ˆÔØ(ˆŒˆˆr9   Úargsr¾   r.   c                óF   ‡ — d                      ˆ fd„|D ¦   «         ¦  «        S )zAHelper to format function arguments in expanded multiline format.Ú c              3  óB   •K  — | ]}‰                      |¦  «        V — Œd S rD   )Ú_format_single_arg)r<   Úargrk   s     €r:   ú	<genexpr>z1CodeGen._format_multiline_args.<locals>.<genexpr>r  s1   øè è € ÐDÐD¸�t×.Ò.¨sÑ3Ô3ÐDÐDÐDÐDÐDÐDr9   ©Újoin©rk   rê   s   ` r:   Ú_format_multiline_argszCodeGen._format_multiline_argsp  s*   ø€ à�wŠwÐDÐDÐDÐD¸tÐDÑDÔDÑDÔDÐDr9   rï   c                ó¢   — d|v rF|                      dd¦  «        \  }}d|                     ¦   «         › d|                     ¦   «         › d�S d|› d�S )z9Helper to format a single argument with optional comment.ú#r   ú    z,  # rÑ   z,
)r’   ÚrstripÚlstrip)rk   rï   Úarg_partÚcomment_parts       r:   rî   zCodeGen._format_single_argt  s`   € à�#ˆ:ˆ:Ø%(§Y¢Y¨s°AÑ%6Ô%6Ñ"ˆH�lØK˜(Ÿ/š/Ñ+Ô+ÐKÐK°,×2EÒ2EÑ2GÔ2GÐKÐKÐKÐKà"˜#�?�?�?Ð"r9   Ú	containerúSequence[object]útuple[str, str]c                ó4   — t          |t          ¦  «        rdndS )z<Helper to get opening and closing delimiters for containers.)ú(ú))ú[ú])Ú
isinstanceÚtuple)rk   rü   s     r:   Ú_get_delimiterszCodeGen._get_delimiters|  s   € å'¨	µ5Ñ9Ô9ÐIˆzˆz¸zÐIr9   Nrì   ÚitemsÚdescsúSequence[str] | NoneÚprefixÚrepr_fnúCallable[[object], str] | Nonec                óè   ‡— |                       |¦  «        \  }}|                      ||¦  «        }‰€t          Š|› |› d�d                     ˆfd„t	          ||¦  «        D ¦   «         ¦  «        z   |› z   S )z?Helper to format containers (lists/tuples) in multiline format.NrÑ   rì   c              3  óB   •K  — | ]\  }}d  ‰|¦  «        › d|› d�V — ŒdS )r÷   ú,rÑ   Nr8   )r<   ÚitemÚtrailerr  s      €r:   rð   z6CodeGen._format_multiline_container.<locals>.<genexpr>�  sV   øè è € ð ð á!�D˜'ð 3�w�w˜t‘}”}Ð2Ð2 wÐ2Ð2Ð2ðð ð ð ð ð r9   )r  Ú_get_desc_trailersrâ   rò   Úzip)rk   r  r  r
  r  ÚldelimÚrdelimÚdesc_trailerss       `   r:   Ú_format_multiline_containerz#CodeGen._format_multiline_container€  s¥   ø€ ð ×-Ò-¨eÑ4Ô4‰ˆ�Ø×/Ò/°°uÑ=Ô=ˆØˆ?ÝˆGð Ð!�vÐ!Ð!Ð!Ø�gŠgð ð ð ð å%(¨°Ñ%>Ô%>ðñ ô ñ ô ñð
 ˆkñð	
r9   c                óD   — |€dgt          |¦  «        z  S d„ |D ¦   «         S )z2Helper to generate description trailers for items.Nrì   c                ó   — g | ]}d |› �‘ŒS )ú  # r8   )r<   Údescs     r:   ú
<listcomp>z.CodeGen._get_desc_trailers.<locals>.<listcomp>œ  s   € Ð0Ð0Ð0 $��t��Ð0Ð0Ð0r9   )rØ   )rk   r  r  s      r:   r  zCodeGen._get_desc_trailers–  s0   € ð ˆ=Ø�4�#˜e™*œ*Ñ$Ð$Ø0Ð0¨%Ð0Ñ0Ô0Ð0r9   ÚmethodúCallable[..., Any]r   Úkwargsc                ó|   ‡— t          j        |¦  «        Šˆfd„|                     ¦   «         D ¦   «         } ||i |¤ŽS )zDHelper to call a method with optional parameters based on signature.c                ó.   •— i | ]\  }}|‰j         v ¯||“ŒS r8   )Ú
parameters)r<   r=   ÚvÚsigs      €r:   r>   z=CodeGen._call_method_with_signature_check.<locals>.<dictcomp>¤  s+   ø€ ÐRÐRÐR¡D A q¸aÀ3Ä>Ð>QÐ>Q˜1˜aÐ>QÐ>QÐ>Qr9   )ÚinspectÚ	signaturer  )rk   r  rê   r  Úfiltered_kwargsr$  s        @r:   Ú!_call_method_with_signature_checkz)CodeGen._call_method_with_signature_checkž  sK   ø€ õ Ô Ñ'Ô'ˆàRÐRÐRÐR¨F¯LªL©N¬NÐRÑRÔRˆØˆv�tÐ/˜Ð/Ð/Ð/r9   F©Úexpanded_defÚ	free_varsÚmaybe_return_annotationr*  rO   c               ó  — t          |¦  «        dk    s|d         dk    r|                     dd¦  «         |r&|                      |¦  «        }d| j        › d|› d|› d�S d| j        › dd                     |¦  «        › d|› d�S )	zÂ
        Given the free variables and a return annotation, generates the beginning of the FX function.
        By default, `gen_fn_def(['a', 'b'], '') == 'def {self._func_name}(a, b):'`
        r   rk   údef z(
r  rÉ   r   ú, )rØ   Úinsertrô   ré   rò   )rk   r+  r,  r*  Úargs_formatteds        r:   Ú
gen_fn_defzCodeGen.gen_fn_def§  s®   € õ ˆy‰>Œ>˜QÒÐ )¨A¤,°&Ò"8Ð"8Ø×Ò˜Q Ñ'Ô'Ð'àð 	^Ø!×8Ò8¸ÑCÔCˆNàV�t”ÐVÐV¨>ÐVÐVÐ<SÐVÐVÐVðð ^˜$œ/Ð]Ð]¨D¯IªI°iÑ,@Ô,@Ð]Ð]ÐCZÐ]Ð]Ð]Ð]r9   ©r  r  Úoutput_argsr   c               óž   — |€t           }|�5t          |t          t          f¦  «        r|                      ||d|¬¦  «        S d ||¦  «        › �S )z�
        Given the output arguments, generates the return statement of the FX function.
        Note: The returned statement should not be indented.
        Nzreturn ©r  )râ   r  Úlistr  r  )rk   r4  r  r  s       r:   Úgenerate_outputzCodeGen.generate_output¿  sg   € ð ˆ?ÝˆGØÐ¥¨K½$Å¸Ñ!GÔ!GÐØ×3Ò3Ø˜U I°wð 4ñ ô ð ð 4˜W˜W [Ñ1Ô1Ð3Ð3Ð3r9   c                ó   — |S )a{  
        Transforms the inputs so that the graph can take them as arguments, as
        non-default codegen may result in the inputs to the function being
        different from the inputs to the graph.

        If the graph was directly runnable, this invariant should hold true
        `f.graph.process_outputs(f.graph(*f.graph.process_inputs(*inputs))) == f(*inputs)`
        r8   ró   s     r:   Úprocess_inputszCodeGen.process_inputsÓ  s	   € ð ˆr9   Úoutputsc                ó   — |S )z‡
        Transforms the outputs of the graph to be identical to the codegen.

        See ``process_inputs`` for more details.
        r8   )rk   r;  s     r:   Úprocess_outputszCodeGen.process_outputsÞ  s	   € ð ˆr9   úlist[tuple[str, Any]]c                ó   — g S )zÑ
        If your codegen uses extra global values, add tuples of (identifier,reference to the value) here.
        For example, return ['List', typing.List] if you need ``List`` in the global context.
        r8   rj   s    r:   Úadditional_globalszCodeGen.additional_globalsæ  s	   € ð
 ˆ	r9   ©ÚverboseÚinclude_strideÚinclude_deviceÚcoloredr*  Úrecord_funcÚadditional_metaÚnodesr«   Úroot_moduleÚ	namespacerd   rB  rC  rD  rE  rF  rG  úlist[str] | Noner!   c               óF	  ‡ ‡‡‡‡‡‡‡
‡"‡#‡$‡%‡&‡'‡(‡)‡*‡+‡,‡-‡.‡/‡0‡1‡2‡3‡4‡5— g Š*g Š&i Š+i Š5dgŠ-‰p#t           j                             dd¦  «        dk    Š‰p#t           j                             dd¦  «        dk    Št           j                             dd¦  «        dk    Š,d<ˆ+ˆfd„Š$t                               ¦   «         D ]\  }\  }} ‰$||¦  «         Œd=ˆ$ˆ2fd„Š2|rBt
          d         Š0t
          d         Š)t
          d         Š't
          d         Š(t
          d         Š%n#t          Š0t          Š)t          Š't          Š(t          Š%d>ˆ#ˆ$ˆ%fd„Š#d?ˆ#fd„Š"i Š.i Š3d@ˆ.ˆ3fd „}t          |¦  «        D ]}|j        D ]} |||¦  «         ŒŒdAˆ&ˆ'ˆ3fd!„}d Š/dBˆ
ˆ&ˆ'ˆ/fd#„}dCd&„Š1dBˆ"ˆ#ˆ$ˆ%ˆ&ˆ(ˆ)ˆˆ*ˆˆ,ˆˆ-ˆ0ˆˆ ˆ1ˆ2ˆˆ5fd'„}|	r‰& 	                    d(¦  «         t          |¦  «        D ]—\  }}‰r ||¦  «         ‰& 	                    d)|› d*�¦  «         |	o|j        d+v }|r)‰& 	                    d,|j        › d-|› d.|j        › d/�¦  «          ||¦  «          ||¦  «         |r‰& 	                    d,|j        › d0�¦  «         Œ˜|	r‰& 	                    d1¦  «         t          ‰&¦  «        d2k    r‰& 	                    d3¦  «         t          ‰5¦  «        d2k    r= ‰$d4t          j        j        ¦  «        Š4d*                     ˆ4fd5„‰5D ¦   «         ¦  «        }nd}‰ j        r‰                      ‰&¦  «        Š&‰                      ¦   «         D ]\  }} ‰$||¦  «         Œ‰                      ‰ j        ‰*‰-d2         ‰¬6¦  «        }i }|                     d*¦  «        d7z   }g }d }d                     ‰&¦  «                             d*¦  «        D ]k}t0                               |¦  «        }|�#t5          |                     d7¦  «        ¦  «        }ŒA||t          |¦  «        |z   <   | 	                    |¦  «         Œld*                     |¦  «                             d*¦  «        }d*                     d8„ |                     d*¦  «        D ¦   «         ¦  «        }d*|› d9|› d*|› �} |                     d*¦  «        d:z   }!t;          | ‰+||!¬;¦  «        S )DNrì   ÚFX_GRAPH_SHOW_STRIDEÚ0Ú1ÚFX_GRAPH_SHOW_DEVICEÚFX_GRAPH_SHOW_METAÚ	name_hintr.   r1   r   rA   c                óä   •— t          |¦  «        r|t          j        k    rt          |¦  «        S ‰                     | |¦  «        }|‰v r!‰|         |k    rt          d|› d�¦  «        ‚|S |‰|<   |S )a  Add an obj to be tracked as a global.

            We call this for names that reference objects external to the
            Graph, like functions or types.

            Returns: the global name that should be used to reference 'obj' in generated source.
            zGlobal name z% already assigned to different object)rb   rJ   rK   r   r   rx   )rR  r1   Úglobal_nameÚglobals_rJ  s      €€r:   Ú
add_globalz,CodeGen._gen_python_code.<locals>.add_global  sœ   ø€ õ ˜sÑ#Ô#ð0Ø(+­u¬|Ò(;Ð(;õ
 +¨3Ñ/Ô/Ð/ð $×/Ò/°	¸3Ñ?Ô?ˆKà˜hÐ&Ð&Ø˜KÔ(¨CÒ/Ð/Ý(ØY {ÐYÐYÐYñô ð ð #Ð"Ø$'ˆH�[Ñ!ØÐr9   Úor0   c                ón  •— | dk    rdS t          | ¦  «        }t          | t          j        ¦  «        r9d|v r5ˆfd„t	          j        | ¦  «        D ¦   «         }d                     |¦  «        S t          | dd ¦  «        x}r¬t          | t          j        ¦  «        rt           
                    ||¦  «        } ‰t          |¦  «        |¦  «        }t          | t          ¦  «        r| j        }nt	          j        | ¦  «        }|r)ˆfd„|D ¦   «         }|› dd                     |¦  «        › d	�S |S  ‰|| ¦  «        S )
Nr8   z()ú|c                ó&   •— g | ]} ‰|¦  «        ‘ŒS r8   r8   ©r<   rï   Ú	type_reprs     €r:   r  z?CodeGen._gen_python_code.<locals>.type_repr.<locals>.<listcomp>3  s!   ø€ ÐEÐEÐE¨3˜	˜	 #™œÐEÐEÐEr9   Ú
__origin__c                ó&   •— g | ]} ‰|¦  «        ‘ŒS r8   r8   r[  s     €r:   r  z?CodeGen._gen_python_code.<locals>.type_repr.<locals>.<listcomp>D  s!   ø€ Ð@Ð@Ð@¨s˜I˜I c™NœNÐ@Ð@Ð@r9   r  r  r  )r   r  ÚtypesÚ	UnionTypeÚtypingÚget_argsrò   r\   Ú_GenericAliasÚ_origin_type_maprz   r    Údims)rW  Útypenamerê   Úorigin_typeÚorigin_typenameÚ	type_argsrV  r\  s         €€r:   r\  z+CodeGen._gen_python_code.<locals>.type_repr+  sP  ø€ Ø�BŠwˆwà�tå! !‘}”}ˆHÝ˜!�Uœ_Ñ-Ô-ð &°#¸°/°/àEÐEÐEÐEµ&´/À!Ñ2DÔ2DÐEÑEÔE�Ø—x’x ‘~”~Ð%å% a¨°tÑ<Ô<Ð<ˆ{ð +õ ˜a¥Ô!5Ñ6Ô6ð Qå"2×"6Ò"6°{ÀKÑ"PÔ"P�Kà", *­Z¸Ñ-DÔ-DÀkÑ"RÔ"R�å˜a¥Ñ,Ô,ð 3Ø !¤�I�Iå &¤°Ñ 2Ô 2�IØð +Ø@Ð@Ð@Ð@°iÐ@Ñ@Ô@�DØ-ÐAÐA°·²¸±´ÐAÐAÐAÐAà*Ð*ð �:˜h¨Ñ*Ô*Ð*r9   ÚredÚ	dim_greenÚdimÚdim_blueÚbluerï   c                óì  •— t          | t          ¦  «        rt          | ¦  «        S t          | t          ¦  «        ret	          | d¦  «        rUt          t          | ¦  «        ¦  «        } ‰|t          | ¦  «        ¦  «        }|› t          t          | ¦  «        ¦  «        › �S t          | t          j        j	        t          j        j
        f¦  «        rt          | ¦  «        } ‰|| ¦  «        }|› S t          | t          j        ¦  «        r$| j        } ‰|j        |¦  «        }|› d| j        › �S t          | t          j        ¦  «        rWt#          |                      ¦   «         ¦  «        }t'          | j        ¦  «                             d¦  «        d         }d|› d|› d�S t          | t          ¦  «        rOt-          | ¦  «        dk    rd ‰| d	         ¦  «        › d
�S dd                     ˆfd„| D ¦   «         ¦  «        z   dz   S t          | t"          ¦  «        r'dd                     ˆfd„| D ¦   «         ¦  «        z   dz   S t          | t0          ¦  «        r6d ‰| j        ¦  «        › d ‰| j        ¦  «        › d ‰| j        ¦  «        › d�S t9          t          | ¦  «        ¦  «        r:t;          | ¦  «        \  }}|                     ¦   «         D ]\  }	}
 ‰|	|
¦  «         Œ|S  ‰t          | ¦  «        ¦  «        S )NÚ_fieldsr�   rÒ   ztorch.Tensor(size=z, dtype=r  r   r   r   z,)r/  c              3  ó.   •K  — | ]} ‰|¦  «        V — Œd S rD   r8   ©r<   ÚaÚ	_get_reprs     €r:   rð   z>CodeGen._gen_python_code.<locals>._get_repr.<locals>.<genexpr>s  s+   øè è € Ð*EÐ*E¸A¨9¨9°Q©<¬<Ð*EÐ*EÐ*EÐ*EÐ*EÐ*Er9   r  c              3  ó.   •K  — | ]} ‰|¦  «        V — Œd S rD   r8   rr  s     €r:   rð   z>CodeGen._gen_python_code.<locals>._get_repr.<locals>.<genexpr>u  s+   øè è € Ð&AÐ&A¸ y y°¡|¤|Ð&AÐ&AÐ&AÐ&AÐ&AÐ&Ar9   r  zslice()r  r   râ   r  Úhasattrr   r¢   rJ   Ú_opsÚ
OpOverloadÚHigherOrderOperatorÚenumÚEnumÚ	__class__r3   r@   ÚTensorr7  Úsizer.   Údtyper’   rØ   rò   ÚsliceÚstartÚstopÚstepr   r   r  )rï   Úqualified_namerT  ÚclsÚclsnamer~  r  Úobj_reprÚopaque_typesÚnÚtrt  rV  rn  s              €€€r:   rt  z+CodeGen._gen_python_code.<locals>._get_reprY  s  ø€ Ý˜#�tÑ$Ô$ð $'Ý˜C‘y”yÐ Ý˜C¥Ñ'Ô'ð "'­G°C¸Ñ,CÔ,Cð "'å!4µT¸#±Y´YÑ!?Ô!?�Ø(˜j¨½¸c¹¼ÑCÔC�Ø%Ð9¥t­E°#©J¬JÑ'7Ô'7Ð9Ð9Ð9ÝØ•e”jÔ+­U¬ZÔ-KÐLñô ð 'õ "5°SÑ!9Ô!9�Ø(˜j¨¸Ñ=Ô=�Ø%Ð'Ð'Ý˜C¥¤Ñ+Ô+ð 'Ø”m�Ø$˜* S¤\°3Ñ7Ô7�Ø!Ð.Ð. C¤HÐ.Ð.Ð.Ý˜C¥¤Ñ.Ô.ð 'Ý˜CŸHšH™JœJÑ'Ô'�Ý˜CœI™œ×,Ò,¨SÑ1Ô1°"Ô5�ØB¨DÐBÐB¸%ÐBÐBÐBÐBÝ˜C¥Ñ'Ô'ð 'Ý�s‘8”8˜q’=�=Ø4˜y˜y¨¨Q¬Ñ0Ô0Ð4Ð4Ð4Ð4à §¢Ð*EÐ*EÐ*EÐ*EÀÐ*EÑ*EÔ*EÑ!EÔ!EÑEÈÑKÐKÝ˜C¥Ñ&Ô&ð 
'Ø˜TŸYšYÐ&AÐ&AÐ&AÐ&A¸SÐ&AÑ&AÔ&AÑAÔAÑAÀCÑGÐGÝ˜C¥Ñ'Ô'ð 'Øe 	 	¨#¬)Ñ 4Ô 4ÐeÐe¸	¸	À#Ä(Ñ8KÔ8KÐeÐeÈyÈyÐY\ÔYaÑObÔObÐeÐeÐeÐeÝ%¥d¨3¡i¤iÑ0Ô0ð 'Ý)<¸SÑ)AÔ)AÑ&�˜,Ø(×.Ò.Ñ0Ô0ð %ð %‘D�A�qØ�J˜q !Ñ$Ô$Ð$Ð$Ø�à�t�D ™IœI‘”Ð&r9   rê   útuple[Argument, ...]r  údict[str, Argument]c                ó°   •— ˆfd„| D ¦   «         }|                      ˆfd„|                     ¦   «         D ¦   «         ¦  «         d                     |¦  «        S )Nc                ó&   •— g | ]} ‰|¦  «        ‘ŒS r8   r8   rr  s     €r:   r  zBCodeGen._gen_python_code.<locals>._format_args.<locals>.<listcomp>ƒ  s!   ø€ Ð.Ð.Ð. A�9�9˜Q‘<”<Ð.Ð.Ð.r9   c                ó6   •— g | ]\  }}|› d  ‰|¦  «        › �‘ŒS )ú = r8   )r<   r=   r#  rt  s      €r:   r  zBCodeGen._gen_python_code.<locals>._format_args.<locals>.<listcomp>„  s3   ø€ ÐKÐKÐK±D°A°q˜1Ð/Ð/  ¨1¡¤Ð/Ð/ÐKÐKÐKr9   r/  )Úextendr  rò   )rê   r  Úresrt  s      €r:   Ú_format_argsz.CodeGen._gen_python_code.<locals>._format_args€  s]   ø€ ð /Ð.Ð.Ð.¨Ð.Ñ.Ô.ˆCØ�JŠJÐKÐKÐKÐK¸F¿LºL¹N¼NÐKÑKÔKÑLÔLÐLØ—9’9˜S‘>”>Ð!r9   r‰  r   ÚuserrB   c                óp   •— | ‰vr0|‰| <   ‰                      |g ¦  «                             | ¦  «         d S d S rD   )r�   Úappend)r‰  r”  Únode_to_last_useÚuser_to_last_usess     €€r:   Úregister_last_usesz4CodeGen._gen_python_code.<locals>.register_last_usesŽ  sL   ø€ ØÐ(Ð(Ð(Ø&*Ð  Ñ#Ø!×,Ò,¨T°2Ñ6Ô6×=Ò=¸aÑ@Ô@Ð@Ð@Ð@ð )Ð(r9   c                óæ  •— | j         dk    rdS | j         dk    r‰                     d¦  «         dS ‰                     | g ¦  «        }t          | j                             ¦   «         ¦  «        dk    r|                     | ¦  «         t          |¦  «        rGd                     d„ |D ¦   «         dgz   ¦  «        }‰                     d	 ‰|¦  «        › d�¦  «         dS ‰                     d¦  «         dS )
zÔ
            Delete values after their last use. This ensures that values that are
            not used in the remainder of the code are freed and the memory usage
            of the code is optimal.
            r*   Nr+   rÑ   r   r�  c                ó,   — g | ]}t          |¦  «        ‘ŒS r8   rá   ©r<   r‰  s     r:   r  zJCodeGen._gen_python_code.<locals>.delete_unused_values.<locals>.<listcomp>¬  s   € Ð6Ð6Ð6 •T˜!‘W”WÐ6Ð6Ð6r9   rB   ú;  )Úopr–  rz   rØ   ÚusersÚkeysrò   )r”  Únodes_to_deleteÚto_delete_strÚbodyrl  r˜  s      €€€r:   Údelete_unused_valuesz6CodeGen._gen_python_code.<locals>.delete_unused_values—  s  ø€ ð Œw˜-Ò'Ð'Ø�ØŒw˜(Ò"Ð"Ø—’˜DÑ!Ô!Ð!Ø�Ø/×3Ò3°D¸"Ñ=Ô=ˆOå�4”:—?’?Ñ$Ô$Ñ%Ô%¨Ò*Ð*ð  ×&Ò& tÑ,Ô,Ð,å�?Ñ#Ô#ð "Ø %§
¢
Ø6Ð6 oÐ6Ñ6Ô6¸&¸ÑAñ!ô !�ð —’Ð8 # # mÑ"4Ô"4Ð8Ð8Ð8Ñ9Ô9Ð9Ð9Ð9à—’˜DÑ!Ô!Ð!Ð!Ð!r9   Únodec           	     óÚ  •— | j         dv�rÝd}‰rPg }‰D ]0}|| j        v r%|                     |› d| j        |         › �¦  «         Œ1|rdd                     |¦  «        › d�}d}| j                             di ¦  «        }i }|rW|                     ¦   «         D ]=\  }}t          |¦  «        }t          |¦  «        dk    r|d	d…         d
z   ||<   Œ8|||<   Œ>d|› �}d}	| j        x}
r%t          |
¦  «        x}r| 
                    ¦   «         }	d}t          | d¦  «        r—| j        r�| j                             dd	¦  «        }| j                             dd	¦  «        }|�*|�(dt          |¦  «        › dt          |j        ¦  «        › �}n.|�dt          |j        ¦  «        › �}n|�dt          |¦  «        › �}d ‰|› d|› |› d|	› �¦  «        › d�}|‰k    r|Š‰                     |¦  «         d	S d	S d	S )z}
            Append a summary of the stacktrace to the generated code. This is
            useful for debugging.
            >   r+   r*   rì   ú: z# r/  ú Úcustomé(   Nz...z Annotation: z'No stacktrace found for following nodesÚmetaÚ	recomputeÚac_graph_idz ac_graph_id: z - z recompute: rÑ   rö   )rž  r«  r–  rò   rz   r  r.   rØ   rÌ   rÞ   rÊ   rv  r@   )r¥  Úadditional_meta_strÚpartsÚkeyÚannotation_strÚ
annotationÚannotation_truncr¤   Ú	value_strÚstack_trace_strrÌ   Úparsed_stack_traceÚmaybe_recompute_infor¬  r­  Úsummary_strrG  r£  rl  Úprev_summary_strs                   €€€€r:   Úappend_stacktrace_summaryz;CodeGen._gen_python_code.<locals>.append_stacktrace_summary´  s¥  ø€ ð ŒwÐ7Ð7Ñ7Ø&(Ð#Ø"ð GØ')�EØ.ð Eð E˜Ø $¤)Ð+Ð+Ø!ŸLšL¨CÐ)CÐ)C°4´9¸S´>Ð)CÐ)CÑDÔDÐDøØð GØ.F°4·9²9¸UÑ3CÔ3CÐ.FÐ.FÐ.FÐ+à!#�Ø!œYŸ]š]¨8°RÑ8Ô8�
Ø#%Ð Øð HØ&0×&6Ò&6Ñ&8Ô&8ð :ð :™
˜˜UÝ$'¨¡J¤J˜	Ý˜y™>œ>¨BÒ.Ð.Ø4=¸c¸r¸c´NÀUÑ4JÐ,¨SÑ1Ð1à49Ð,¨SÑ1Ð1Ø%GÐ5EÐ%GÐ%G�Nà"K�Ø"&Ô"2Ð2�;ð OÝ-?ÀÑ-LÔ-LÐLÐ)ð OØ*<×*LÒ*LÑ*NÔ*N˜à')Ð$Ý˜4 Ñ(Ô(ð S¨T¬Yð Sð !%¤	§¢¨k¸4Ñ @Ô @�IØ"&¤)§-¢-°¸tÑ"DÔ"D�Kà Ð,°Ð1HàW­S°Ñ-=Ô-=ÐWÐWÅ#ÀiÄnÑBUÔBUÐWÐWð -Ð,ð #Ð.Ø/S½cÀ)Ä.Ñ>QÔ>QÐ/SÐ/SÐ,Ð,Ø$Ð0Ø/RÅÀKÑ@PÔ@PÐ/RÐ/RÐ,à} 3 3Ð*=Ð'xÐ'xÀÐ'xÐPdÐ'xÐ'xÐgvÐ'xÐ'xÑ#yÔ#yÐ}Ð}Ð}�àÐ"2Ò2Ð2Ø'2Ð$Ø—K’K Ñ,Ô,Ð,Ð,Ð,ða 8Ð7ð\ 3Ð2r9   ÚshapeúIterable[object]c                óH   — dd                      d„ | D ¦   «         ¦  «        › d�S )Nr  r/  c                ó,   — g | ]}t          |¦  «        ‘ŒS r8   ©r.   ©r<   rN   s     r:   r  zECodeGen._gen_python_code.<locals>.stringify_shape.<locals>.<listcomp>î  s   € Ð!8Ð!8Ð!8¨Q¥# a¡&¤&Ð!8Ð!8Ð!8r9   r  rñ   )r»  s    r:   Ústringify_shapez1CodeGen._gen_python_code.<locals>.stringify_shapeí  s.   € Ø<�t—y’yÐ!8Ð!8°%Ð!8Ñ!8Ô!8Ñ9Ô9Ð<Ð<Ð<Ð<r9   c                ó‚  •— | j         €dnd ‰'| j         ¦  «        › �}d}‰(�rò	 ddlm}m} |j        }n# t
          $ r d }d }Y nw xY wddlm} ddlm	} | j
                             d| j
                             d| j
                             d	d ¦  «        ¦  «        ¦  «        }d<ˆˆˆˆˆ!ˆ#ˆ&fd„}	t          |t          j        ¦  «        rç|j        t          j        t          j        fvrÈt          |¦  «        t          j        u pt          |t          j        j        ¦  «        }
 |	|¦  «        }|
rd|› d�}nát          |¦  «        |u rS|€t)          d¦  «        ‚ ||j        j        |j        j        ¦  «        }|j        j        }d|› d|› d ‰|¦  «        › d�}n}|j        j        }d|› d|› d�}ngt          ||¦  «        r!t4                               |¦  «        }d|› d�}n6t          ||¦  «        r&dt8          |j                 ›  ‰&|j        ¦  «        › d�}d }‰r0| j
                             dd ¦  «        }|�| j        dk    r|d|› �z  }‰ r�tA          | d¦  «        r�| j
        r†‰ !                    d¦  «         | j
         "                    ¦   «         D ]B\  }}‰ !                    |› dtG          j$        tK          |¦  «        dd¬¦  «        › d�¦  «         ŒC‰ !                    d¦  «         | j        dk    rÚt          | j&        tJ          ¦  «        s$t)          d t          | j&        ¦  «        › �¦  «        ‚| j'        sdnd! ‰| j'        d         ¦  «        › �}‰ !                    | j&        › |› |› |› �¦  «         | j&         (                    d"d¦  «        }|tS          | ¦  «        k    r(‰ !                    tS          | ¦  «        › d!|› d�¦  «         d S | j        d#k    r°t          | j&        tJ          ¦  «        s$t)          d$t          | j&        ¦  «        › �¦  «        ‚‰ !                    tS          | ¦  «        › |› d!tU           ‰| j'        d         ¦  «        | j&        ¦  «        › d ‰| j'        d%d …         | j+        ¦  «        › d&�¦  «         d S | j        d'k    �rþtY          | j&        ¦  «        s$t)          d(t          | j&        ¦  «        › �¦  «        ‚t[          | j&        d)d¦  «        d*k    r©| j&        j        t\          v r–t          | j'        t^          ¦  «        s$t)          d+t          | j'        ¦  «        › �¦  «        ‚‰ !                    tS          | ¦  «        › |› d!t]          | j&        j                 j0        ˆfd,„| j'        D ¦   «         Ž › �¦  «         d S t[          | j&        d)d¦  «        d*k    r‚| j&        j        tb          v ro‰ !                    tc          | j&        j                 j0        ˆfd-„| j'        D ¦   «         Ž › d.tS          | ¦  «        › |› d! ‰| j'        d         ¦  «        › �¦  «         d S te          | j&        ¦  «        } ‰|| j&        ¦  «        }|d/k    rÉt          | j'        t^          ¦  «        r¯t          | j'        d%         tJ          ¦  «        r�| j'        d%          3                    ¦   «         rpti          | j'        ¦  «        d0k    rX‰ !                    tS          | ¦  «        › |› d!tU           ‰| j'        d         ¦  «        | j'        d%         ¦  «        › �¦  «         d S ‰ !                    tS          | ¦  «        › |› d!|› d ‰| j'        | j+        ¦  «        › d&�¦  «         | j
                             d1d2¦  «        r‰) 5                    |¦  «         d S | j        d3k    r”t          | j&        tJ          ¦  «        s$t)          d4t          | j&        ¦  «        › �¦  «        ‚‰ !                    tS          | ¦  «        › |› d!tU          ‰$| j&        ¦  «        › d ‰| j'        | j+        ¦  «        › d&�¦  «         d S | j        d5k    r|t          | j&        tJ          ¦  «        s$t)          d6t          | j&        ¦  «        › �¦  «        ‚‰ !                    tS          | ¦  «        › |› d!tU          ‰$| j&        ¦  «        › �¦  «         d S | j        d7k    r_| j         �d8 ‰'| j         ¦  «        › �‰"d<   ‰ !                    ‰% 6                    ‰%j7        | j'        d         ‰r|nd ‰¬9¦  «        ¦  «         d S tq          d:| j        › d;| j&        › �¦  «        ‚)=Nrì   z : r   )ÚDTensorÚDTensorSpecr   )ÚTensorMetadataÚvalÚtensor_metaÚexample_valuerŠ  útorch.TensorrA   r.   c                óö   •— ‰r ‰	|                       ¦   «         ¦  «        nd}‰r| j        › nd} ‰t          | j                 ¦  «        ›  ‰ ‰	| j        ¦  «        ¦  «        ›  ‰|¦  «        ›  ‰|¦  «        › �S )Nrì   )ÚstriderK   r   r  r»  )
rŠ  rË  rK   rn  rm  rk  rD  rC  rj  rÁ  s
      €€€€€€€r:   Ú_tensor_annotationzGCodeGen._gen_python_code.<locals>.emit_node.<locals>._tensor_annotation	  sž   ø€ Ø<JÐR˜_˜_¨Q¯XªX©Z¬ZÑ8Ô8Ð8ÐPR�FØ.<ÐD ¤˜]˜]À"�Fà˜3�{¨1¬7Ô3Ñ4Ô4ð /Ø˜4  °´Ñ 8Ô 8Ñ9Ô9ð/à#˜8 FÑ+Ô+ð/ð %˜9 VÑ,Ô,ð/ð /ðr9   z: "ú"z6dtensorspec_format_shard_order_str is None for DTensorr   r/  z)"z: "Sym(r  r*   r  r«  z"""
r§  éP   T)ÚwidthÚcompactrÑ   z$Expected node.target to be str, got r�  Ú*r'   z4Expected node.target to be str for call_method, got r   r  r&   z)Expected node.target to be callable, got r4   Ú	_operatorz$Expected node.args to be tuple, got c              3  ó.   •K  — | ]} ‰|¦  «        V — Œd S rD   r8   rr  s     €r:   rð   z>CodeGen._gen_python_code.<locals>.emit_node.<locals>.<genexpr>r  s-   øè è € ÐGhÐGhÐYZÈ	È	ÐRSÉÌÐGhÐGhÐGhÐGhÐGhÐGhr9   c              3  ó.   •K  — | ]} ‰|¦  «        V — Œd S rD   r8   rr  s     €r:   rð   z>CodeGen._gen_python_code.<locals>.emit_node.<locals>.<genexpr>}  s-   øè è € ÐIjÐIjÐ[\È)È)ÐTUÉ,Ì,ÐIjÐIjÐIjÐIjÐIjÐIjr9   r�  r\   rr   Ú
is_wrappedFr)   z4Expected node.target to be str for call_module, got r(   z1Expected node.target to be str for get_attr, got r+   z -> r3  znode: r¨  )rŠ  rÉ  rA   r.   )9r¢   Útorch.distributed.tensor._apirÃ  rÄ  Úformat_shard_order_strÚModuleNotFoundErrorÚ"torch.fx.experimental.proxy_tensorr   Útorch.fx.passes.shape_proprÅ  r«  rz   r  rJ   r}  ÚlayoutÚ
sparse_cscÚ
sparse_csrÚ_subclassesÚ
FakeTensorrx   Ú_specÚ
placementsÚshard_orderr|  r3   r"   rå   r   r  r»  rž  rv  r–  r  ÚpprintÚpformatr.   rŽ   rê   Úreplacerâ   r—   r  Úcallabler\   Úmagic_methodsr  ÚformatÚinplace_methodsr   r“   rØ   r�   r(  r8  ÚNotImplementedError)*r¥  Úmaybe_type_annotationÚmaybe_commentrÃ  rÄ  Ú"dtensorspec_format_shard_order_strr   rÅ  Úmeta_valrÌ  Úis_plainÚcoreÚdtensor_metar…  Úval_strr  r=   r#  Úmaybe_default_argÚraw_namer„  rT  r“  rt  rV  rn  r£  rm  rk  r*  r+  rD  Úinclude_metarC  r,  rj  rI  rk   rÁ  r\  rB  Úwrapped_fnss*                         €€€€€€€€€€€€€€€€€€€€r:   Ú	emit_nodez+CodeGen._gen_python_code.<locals>.emit_nodeð  s3  ø€ à”iÐ'��Ð-I°9°9¸T¼YÑ3GÔ3GÐ-IÐ-Ið "ð ˆMàñ ?rð>ØRÐRÐRÐRÐRÐRÐRÐRð $Ô:ð 7Ð6øõ +ð >ð >ð >Ø"�GØ9=Ð6Ð6Ð6ð>øøøð LÐKÐKÐKÐKÐKØEÐEÐEÐEÐEÐEàœ9Ÿ=š=ØØ”I—M’M -°´·²¸ÐPTÑ1UÔ1UÑVÔVñô �ð
ð ð ð ð ð ð ð ð ð ð ð õ ˜h­¬Ñ5Ô5ð !r¸(¼/ÝÔ$ÝÔ$ðRð ;ð ;õ
  $ H™~œ~µ´Ð=ð  ÅØ ¥%Ô"3Ô">ñBô B�Hð .Ð-¨hÑ7Ô7�DØð EØ0=°d°°°Ð-Ð-Ý˜h™œ¨7Ð2Ð2Ø=ÐEÝ"0Ø Xñ#ô #ð ð (JÐ'IØ$œNÔ5Ø$œNÔ6ñ(ô (˜ð 'Ô0Ô9˜àK #ÐKÐK¨ÐKÐK°	°	¸,Ñ0GÔ0GÐKÐKÐKð .Ð-ð 'Ô0Ô9˜Ø0D°cÐ0DÐ0D¸DÐ0DÐ0DÐ0DÐ-Ð-å ¨,Ñ7Ô7ð rÝ%×/Ò/°Ñ9Ô9�GØ,A°gÐ,AÐ,AÐ,AÐ)Ð)å ¨.Ñ9Ô9ð rØ,qµ+¸h¼nÔ2MÐ,qÈÈÐ_gÔ_mÑOnÔOnÐ,qÐ,qÐ,qÐ)àˆDØð 3Ø”y—}’} V¨TÑ2Ô2�ØÐ#¨¬°=Ò(@Ð(@Ø! ]¨D ] ]Ñ2�Mð ð 	%¥¨¨fÑ 5Ô 5ð 	%¸$¼)ð 	%Ø—’˜GÑ$Ô$Ð$Ø œIŸOšOÑ-Ô-ð ð ‘D�A�qð —K’KØÐRÐR¥¤­s°1©v¬v¸RÈÐ NÑ NÔ NÐRÐRÐRñô ð ð ð —’˜GÑ$Ô$Ð$àŒw˜-Ò'Ð'Ý! $¤+­sÑ3Ô3ð Ý(ØR½tÀDÄKÑ?PÔ?PÐRÐRñô ð ð #œiÐL�B�BÐ-L°9°9¸T¼YÀq¼\Ñ3JÔ3JÐ-LÐ-Lð "ð × Ò Ø”{Ð]Ð$9Ð]Ð;LÐ]ÈmÐ]Ð]ñô ð ð  œ;×.Ò.¨s°BÑ7Ô7�Ø�t D™zœzÒ)Ð)Ø—K’K¥4¨¡:¤:Ð >Ð >°(Ð >Ð >Ð >Ñ?Ô?Ð?Ø�Ø”˜MÒ)Ð)Ý! $¤+­sÑ3Ô3ð Ý(ØbÍtÐTXÔT_ÑO`ÔO`ÐbÐbñô ð ð —’Ý˜D‘z”zð DÐ#8ð Dð D½^ÈIÈIÐVZÔV_Ð`aÔVbÑLcÔLcÐeiÔepÑ=qÔ=qð Dð DØ$˜ T¤Y¨q¨r¨r¤]°D´KÑ@Ô@ðDð Dð Dñô ð ð �Ø”˜OÒ+Ñ+Ý ¤Ñ,Ô,ð Ý(ØWÅDÈÌÑDUÔDUÐWÐWñô ð õ
 ˜DœK¨°rÑ:Ô:¸kÒIÐIØœÔ,µÐ=Ð=å% d¤iµÑ7Ô7ð Ý,ØTÅ4ÈÌ	Á?Ä?ÐTÐTñô ð ð —K’KÝ ™:œ:ð lÐ'<ð lð lÝ(¨¬Ô)=Ô>ÔEÐGhÐGhÐGhÐGhÐ^bÔ^gÐGhÑGhÔGhÐiðlð lñô ð ð �Fõ
 ˜DœK¨°rÑ:Ô:¸kÒIÐIØœÔ,µÐ?Ð?à—K’KÝ*¨4¬;Ô+?Ô@ÔGÐIjÐIjÐIjÐIjÐ`dÔ`iÐIjÑIjÔIjÐkð [ð [Ý ™:œ:ð[Ø'<ð[ð [ØAJÀÈ4Ì9ÐUVÌ<ÑAXÔAXð[ð [ñô ð ð �Få!4°T´[Ñ!AÔ!A�Ø(˜j¨¸¼ÑEÔE�ð   9Ò,Ð,Ý" 4¤9­eÑ4Ô4ð -å" 4¤9¨Q¤<µÑ5Ô5ð -ð œ	 !œ×1Ò1Ñ3Ô3ð -õ ˜DœI™œ¨!Ò+Ð+à—K’KÝ ™:œ:ÐxÐ'<ÐxÐxÅÐPYÐPYÐZ^ÔZcÐdeÔZfÑPgÔPgÐimÔirÐstÔiuÑAvÔAvÐxÐxñô ð ð �FØ—’Ý˜D‘z”zÐrÐ#8ÐrÐr¸[ÐrÐrÈ<È<ÐX\ÔXaÐcgÔcnÑKoÔKoÐrÐrÐrñô ð ð ”9—=’= ¨uÑ5Ô5ð 8Ø×*Ò*¨;Ñ7Ô7Ð7Ø�Ø”˜MÒ)Ð)Ý! $¤+­sÑ3Ô3ð Ý(ØbÍtÐTXÔT_ÑO`ÔO`ÐbÐbñô ð ð —’Ý˜D‘z”zð jÐ#8ð jð jÝ% k°4´;Ñ?Ô?ðjð jØBNÀ,ÈtÌyÐZ^ÔZeÑBfÔBfðjð jð jñô ð ð �Ø”˜JÒ&Ð&Ý! $¤+­sÑ3Ô3ð Ý(Ø_ÍDÐQUÔQ\ÑL]ÔL]Ð_Ð_ñô ð ð —’Ý˜D‘z”zÐgÐ#8ÐgÐg½^ÈKÐY]ÔYdÑ=eÔ=eÐgÐgñô ð ð �Ø”˜HÒ$Ð$Ø”9Ð(Ø1N¸	¸	À$Ä)Ñ8LÔ8LÐ1NÐ1NÐ+¨AÑ.Ø—’Ø×:Ò:ØÔ,Øœ	 !œØ&2Ð<˜d˜d¸Ø )ð	 ;ñ ô ñô ð ð �Ý%Ð&F¨t¬wÐ&FÐ&F¸¼Ð&FÐ&FÑGÔGÐGs   ¤4 ´AÁAzc_rf = torch._C._profiler._RecordFunctionFast('## ENTER_GRAPH_PLACEHOLDER_KEY ##'); _rf.__enter__()
z# COUNTER: rÑ   ©r&   r'   r)   Ú_rf_z. = torch._C._profiler._RecordFunctionFast('## z ##'); _rf_z.__enter__()
z.__exit__(None, None, None)
z_rf.__exit__(None, None, None)
r   zpass
Úwrapc                ó    •— g | ]
}‰› d |› d�‘ŒS )z("r‘   r8   )r<   r@   Ú	wrap_names     €r:   r  z,CodeGen._gen_python_code.<locals>.<listcomp>Þ  s*   ø€ Ð#UÐ#UÐ#UÀ yÐ$<Ð$<°DÐ$<Ð$<Ð$<Ð#UÐ#UÐ#Ur9   r)  r   c              3  ó    K  — | ]	}d |z   V — Œ
dS )r÷   Nr8   )r<   rÜ   s     r:   rð   z+CodeGen._gen_python_code.<locals>.<genexpr>ý  s&   è è € ÐDÐD¨4˜ $™ÐDÐDÐDÐDÐDÐDr9   z

é   )rŒ   r�   )rR  r.   r1   r   rA   r.   )rW  r0   rA   r.   )rï   r0   rA   r.   )rê   r‹  r  rŒ  rA   r.   )r‰  r   r”  r   rA   rB   )r”  r   rA   rB   ©r¥  r   rA   rB   )r»  r¼  rA   r.   )ÚosÚenvironrz   r?   r  Ú
_color_fnsÚ	_identityÚreversedÚ_input_nodesr–  Ú	enumeraterž  r@   rØ   rJ   Úfxrú  rò   rè   r@  r(  r2  Úcountr’   Ú_counter_regexpÚsearchr{   ry   rù   r!   )6rk   rH  rI  rJ  rB  rC  rD  rE  r*  rF  rG  r@   rp   r1   r™  r¥  Ú
input_noder¤  rº  r÷  ÚiÚ	do_recordÚ
wrap_stmtsr¤   ÚprologueÚ
lineno_mapÚprologue_lenÚ	new_linesÚcur_idxrÜ   ÚcounterrÇ   Úfn_codeÚprologue_startr“  rt  rV  rn  r£  rl  rm  rk  r+  rU  rõ  r,  r—  r¹  rj  rÁ  r\  r˜  rü  rö  s6   ` ````` ` `                       @@@@@@@@@@@@@@@@@@@@r:   Ú_gen_python_codezCodeGen._gen_python_codeí  s  øøøøøøøøøøøøøøøøøøøøøøøøøøøø€ ð  "ˆ	ØˆØ#%ˆØ')ˆð /1¨TÐØ'ð 
ÝŒJ�NŠNÐ1°3Ñ7Ô7¸3Ò>ð 	ð (ð 
ÝŒJ�NŠNÐ1°3Ñ7Ô7¸3Ò>ð 	õ ”z—~’~Ð&:¸CÑ@Ô@ÀCÒGˆð	ð 	ð 	ð 	ð 	ð 	ð 	õ: /×4Ò4Ñ6Ô6ð 	"ð 	"‰NˆD‘(�1�cØˆJ�t˜SÑ!Ô!Ð!Ð!ð	+ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+ðB ð 	Ý˜UÔ#ˆCÝ" ;Ô/ˆIÝ˜UÔ#ˆCÝ! *Ô-ˆHÝ˜fÔ%ˆDˆDåˆCÝ!ˆIÝˆCÝ ˆHÝˆDð%	'ð %	'ð %	'ð %	'ð %	'ð %	'ð %	'ð %	'ðN	"ð 	"ð 	"ð 	"ð 	"ð 	"ð .0ÐØ46Ðð	Að 	Að 	Að 	Að 	Að 	Að 	Aõ
 ˜U‘O”Oð 	5ð 	5ˆDØ"Ô/ð 5ð 5�
Ø"Ð" :¨tÑ4Ô4Ð4Ð4ð5ð	"ð 	"ð 	"ð 	"ð 	"ð 	"ð 	"ð 	"ð6  Ðð7	-ð 7	-ð 7	-ð 7	-ð 7	-ð 7	-ð 7	-ð 7	-ð 7	-ðr	=ð 	=ð 	=ð 	=ðF	Hð F	Hð F	Hð F	Hð F	Hð F	Hð F	Hð F	Hð F	Hð F	Hð F	Hð F	Hð F	Hð F	Hð F	Hð F	Hð F	Hð F	Hð F	Hð F	Hð F	Hð F	Hð F	Hð F	Hð F	HðP ð 	Ø�KŠKØvñô ð õ ! Ñ'Ô'ð 	Mð 	M‰GˆAˆtð ð 0Ø)Ð)¨$Ñ/Ô/Ð/ð �KŠKÐ+ aÐ+Ð+Ð+Ñ,Ô,Ð,Ø#ð ¨¬ð 4ð )ˆIð
 ð à—’Ø{˜4œ9Ð{Ð{ÐTUÐ{Ð{ÐbfÔbkÐ{Ð{Ð{ñô ð ð ˆI�d‰OŒOˆOØ Ð  Ñ&Ô&Ð&Øð MØ—’ÐK 4¤9ÐKÐKÐKÑLÔLÐLøØð 	<Ø�KŠKÐ:Ñ;Ô;Ð;åˆt‰9Œ9˜Š>ˆ>ð �KŠK˜Ñ!Ô!Ð!åˆ{ÑÔ˜aÒÐØ"˜
 6­5¬8¬=Ñ9Ô9ˆIØŸšÐ#UÐ#UÐ#UÐ#UÈÐ#UÑ#UÔ#UÑVÔVˆJˆJàˆJàÔ!ð 	0Ø×)Ò)¨$Ñ/Ô/ˆDà×2Ò2Ñ4Ô4ð 	$ð 	$‰KˆD�%ØˆJ�t˜UÑ#Ô#Ð#Ð#à×9Ò9ØŒOØØ# AÔ&Ø%ð	 :ñ 
ô 
ˆð -/ˆ
Ø—~’~ dÑ+Ô+¨aÑ/ˆØ!ˆ	ØˆØ—G’G˜D‘M”M×'Ò'¨Ñ-Ô-ð 	'ð 	'ˆDÝ%×,Ò,¨TÑ2Ô2ˆGØÐ"Ý˜gŸmšm¨AÑ.Ô.Ñ/Ô/��à<C�
�3˜y™>œ>¨LÑ8Ñ9Ø× Ò  Ñ&Ô&Ð&Ð&à�yŠy˜Ñ#Ô#×*Ò*¨4Ñ0Ô0ˆØ�yŠyÐDÐD°4·:²:¸dÑ3CÔ3CÐDÑDÔDÑDÔDˆð
Øð
ð 
ð 
ð
ð 
ð ð	
ð 
ˆð $×)Ò)¨$Ñ/Ô/°!Ñ3ˆÝØØØ"Ø*ð	
ñ 
ô 
ð 	
r9   r†   )rê   r¾   rA   r.   )rï   r.   rA   r.   )rü   rý   rA   rþ   )Nrì   N)
r  rý   r  r	  r
  r.   r  r  rA   r.   )r  rý   r  r	  rA   r¾   )r  r  rê   r   r  r   rA   r   ©r+  r¾   r,  r.   r*  rO   rA   r.   ©r4  r   r  r	  r  r  rA   r.   ©rê   r   rA   r   )r;  r   rA   r   )rA   r>  )rH  r«   rI  r.   rJ  rd   rB  rO   rC  rO   rD  rO   rE  rO   r*  rO   rF  rO   rG  rK  rA   r!   )r3   r4   r5   rå   r7   rl   rô   rî   r  r  r  r(  r2  r8  r:  r=  r@  r  r8   r9   r:   r"   r"   g  s™  € € € € € € ð 9JÐ8I€IÐIÐIÐIÑIð)ð )ð )ð )ðEð Eð Eð Eð#ð #ð #ð #ðJð Jð Jð Jð '+ØØ26ð
ð 
ð 
ð 
ð 
ð,1ð 1ð 1ð 1ð0ð 0ð 0ð 0ð #ð^ð ^ð ^ð ^ð ^ð ^ð8 '+Ø26ð4ð 4ð 4ð 4ð 4ð 4ð(	ð 	ð 	ð 	ðð ð ð ðð ð ð ð Ø$Ø$Øà"Ø!Ø,0ð^
ð ^
ð ^
ð ^
ð ^
ð ^
ð ^
ð ^
r9   r"   c                  ó    — e Zd ZdZddœdd„ZdS )Ú_BoxedCodeGenzÿ
    CodeGen subclass that generates code using the "boxed" calling convention.

    The boxed calling convention takes a single list argument and clears it
    after extracting the arguments, which allows for early deallocation of
    input tensors.
    Fr)  r+  r¾   r,  r.   r*  rO   rA   c               ór   — d| j         › d|› d�}|r&d„ |D ¦   «         }|r|dz  }|D ]}|d|› d�z  }Œ|dz  }|S )	a  
        Generate function definition for boxed calling convention.

        Instead of taking individual arguments, the generated function takes
        a single 'args_list' parameter, extracts placeholder values from it,
        and clears the list.
        r.  z(self, args_list)rÉ   c                ó¦   — g | ]N}|d k    ¯|                      d¦  «        d                               d¦  «        d                              ¦   «         ‘ŒOS )rk   rÉ   r   ú=)r’   rÖ   )r<   r#  s     r:   r  z,_BoxedCodeGen.gen_fn_def.<locals>.<listcomp>1  sR   € ð  ð  ð  Ø:;ÈAÐQWÊKÈK�—’˜‘”˜Q”×%Ò% cÑ*Ô*¨1Ô-×3Ò3Ñ5Ô5ÈKÈKÈKr9   z 
    args_iter = iter(args_list)ú
    z = next(args_iter)z
    args_list.clear())ré   )rk   r+  r,  r*  Úfn_defÚplaceholder_varsÚvars          r:   r2  z_BoxedCodeGen.gen_fn_def  s“   € ð U˜œÐTÐTÐ:QÐTÐTÐTˆàð 	4ð ð  Ø?Hð ñ  ô  Ðð  ð 4ØÐ=Ñ=�Ø+ð ?ð ?�CØÐ> sÐ>Ð>Ð>Ñ>�F�FØÐ3Ñ3�àˆr9   Nr  )r3   r4   r5   r6   r2  r8   r9   r:   r  r    sA   € € € € € ðð ð #ðð ð ð ð ð ð ð r9   r  c                  óf   ‡ — e Zd Zd ˆ fd„Zd!d„Zd"d
„Zd#d„Zd$d„Zddœd%ˆ fd„Zdddœd&ˆ fd„Z	ˆ xZ
S )'Ú_PyTreeCodeGenÚpytree_infor½   rA   rB   c                óV   •— t          ¦   «                              ¦   «          || _        d S rD   )Úsuperrl   r&  )rk   r&  r|  s     €r:   rl   z_PyTreeCodeGen.__init__?  s'   ø€ Ý‰Œ×ÒÑÔÐØ(3ˆÔÐÐr9   Úinputsr   c                ó"   — t          j        |Ž }|S rD   )rM   Úarg_tree_leaves)rk   r)  Ú	flat_argss      r:   r:  z_PyTreeCodeGen.process_inputsC  s   € ÝÔ*¨FÐ3ˆ	ØÐr9   Úoutc                óÞ   — | j         �| j         j        €|S t          |t          t          f¦  «        s|g}| j         j        €t          d¦  «        ‚t          j        || j         j        ¦  «        S )Nzpytree_info.out_spec is None)r&  rÁ   r  r7  r  rx   rM   Útree_unflatten©rk   r-  s     r:   r=  z_PyTreeCodeGen.process_outputsG  sl   € ØÔÐ# tÔ'7Ô'@Ð'HØˆJÝ˜#¥¥e˜}Ñ-Ô-ð 	Ø�%ˆCØÔÔ$Ð,Ý Ð!?Ñ@Ô@Ð@ÝÔ$ S¨$Ô*:Ô*CÑDÔDÐDr9   r+  r¾   r*  rO   r.   c                ó¨   — |sdS d„ |D ¦   «         }|sdS |rdd                      |¦  «        z   S dd                      d„ |D ¦   «         ¦  «        z   dz   S )z=Helper to format annotations for variables in pytree codegen.rì   c                ó   — g | ]}d |v ¯|‘Œ	S )rÉ   r8   rÀ  s     r:   r  z6_PyTreeCodeGen._format_annotations.<locals>.<listcomp>U  s   € Ð;Ð;Ð; °#¸°(°(˜!°(°(°(r9   r   c              3  ó    K  — | ]	}|d z   V — Œ
dS )z; Nr8   rÀ  s     r:   rð   z5_PyTreeCodeGen._format_annotations.<locals>.<genexpr>\  s&   è è € Ð%GÐ%G°1 a¨$¡hÐ%GÐ%GÐ%GÐ%GÐ%GÐ%Gr9   rÑ   rñ   )rk   r+  r*  Úhas_annotations       r:   Ú_format_annotationsz"_PyTreeCodeGen._format_annotationsP  sz   € àð 	Ø�2à;Ð; YÐ;Ñ;Ô;ˆØð 	Ø�2àð 	OØ˜hŸmšm¨NÑ;Ô;Ñ;Ð;à˜bŸgšgÐ%GÐ%G¸Ð%GÑ%GÔ%GÑGÔGÑGÈ$ÑNÐNr9   Úfn_argsc           
     óÞ  — | j         j        }|j        t          u oL|j        dk    oA|                     d¦  «        j        t          u o |                     d¦  «        j        t          u }d}dd                     |¦  «        › d�}|r§|                     d¦  «        j        }| j         j        d |…         }dd                     d	„ t          |                     d¦  «        j
        | j         j        |d …         ¦  «        D ¦   «         ¦  «        z   d
z   }dd                     |¦  «        › d|› d�}d„ |D ¦   «         }	|                      ||¦  «        }
|
dd                     |	¦  «        › d|› d�z  }
|
S )Nrr   r   r   z{}r  r/  z], self._in_specÚ{c              3  ó,   K  — | ]\  }}d |› d|› �V — ŒdS )ú'z':Nr8   ©r<   r=   r#  s      r:   rð   z2_PyTreeCodeGen.gen_var_bindings.<locals>.<genexpr>p  sF   è è € ð ð á˜˜1ð !˜�L�L˜Q�L�Lðð ð ð ð ð r9   Ú}z([z], z), self._in_specc                óv   — g | ]6}|                      d ¦  «        d                               d¦  «        d         ‘Œ7S ©rÉ   r   rö   ©r’   rÀ  s     r:   r  z3_PyTreeCodeGen.gen_var_bindings.<locals>.<listcomp>  ó9   € ÐOÐOÐOÀ˜aŸgšg c™lœl¨1œo×3Ò3°CÑ8Ô8¸Ô;ÐOÐOÐOr9   r   z , = fx_pytree.tree_flatten_spec(r  )r&  rÀ   r¢   r  Únum_childrenÚchildÚdictrò   r¿   r  Úcontextr5  )rk   r6  r+  r*  rÀ   Úhas_args_kwargs_tupleÚ	fn_kwargsÚfn_signatureÚ
count_argsÚwithout_annotationÚbindingss              r:   Úgen_var_bindingsz_PyTreeCodeGen.gen_var_bindings^  sÊ  € ð Ô"Ô*ˆð ŒL�EÐ!ð .ØÔ$¨Ò)ð.à—’˜aÑ Ô Ô%­Ð.ð.ð —’˜aÑ Ô Ô%­Ð-ð	 	ð ˆ	Ø?˜4Ÿ9š9 WÑ-Ô-Ð?Ð?Ð?ˆØ ð 	SØ Ÿš qÑ)Ô)Ô6ˆJØÔ&Ô0°°*°Ô=ˆGàØ—)’)ð ð å #ØŸš aÑ(Ô(Ô0ØÔ(Ô2°:°;°;Ô?ñ!ô !ðñ ô ñ ô ñð ñð ð S §	¢	¨'Ñ 2Ô 2ÐRÐR°yÐRÐRÐRˆLð PÐOÀYÐOÑOÔOÐØ×+Ò+¨I°|ÑDÔDˆØð VØ	‡Y‚YÐ!Ñ"Ô"ðVð VØDPðVð Vð Vñ 	Vˆàˆr9   Fr)  r,  c               óš  •— | j         €$t          ¦   «                              |||¬¦  «        S | j         j        }t	          |¦  «        dk    r|d         dk    nd}|r|                     dd¦  «         t          ¦   «                              |d d …         ||¬¦  «        }t	          |¦  «        dk    r||                      |||¦  «        z  }|S )Nr)  r   rk   F)r&  r(  r2  r¿   rØ   r0  rK  )rk   r+  r,  r*  r6  Úhas_orig_selfÚfn_definitionr|  s          €r:   r2  z_PyTreeCodeGen.gen_fn_def…  sè   ø€ ð, ÔÐ#Ý‘7”7×%Ò%ØÐ2Àð &ñ ô ð ð Ô"Ô,ˆÝ25°g±,´,ÀÒ2BÐ2B˜ œ vÒ-Ð-ÈˆØð 	(Ø×Ò˜Q Ñ'Ô'Ð'Ý™œ×*Ò*Ø�A�A�AŒJÐ/¸lð +ñ 
ô 
ˆõ ˆy‰>Œ>˜AÒÐØ˜T×2Ò2°7¸IÀ|ÑTÔTÑTˆMØÐr9   Nr3  r4  r   r  r	  r  r  c               ó  •— |€t           }| j        rU| j        j        rI|�8t          |t          t
          f¦  «        r|                      ||d|¬¦  «        dz   S d ||¦  «        › d�S t          ¦   «                              |||¬¦  «        S )Núreturn pytree.tree_unflatten(r6  ú, self._out_spec)r3  )	râ   r&  rÁ   r  r7  r  r  r(  r8  )rk   r4  r  r  r|  s       €r:   r8  z_PyTreeCodeGen.generate_output¬  s²   ø€ ð ˆ?ÝˆGØÔð 	V Ô 0Ô 9ð 	VØÐ ¥Z°½dÅE¸]Ñ%KÔ%KÐ à×4Ò4Ø#ØØ7Ø 'ð	 5ñ ô ð *ñ*ðð _°w°w¸{Ñ7KÔ7KÐ^Ð^Ð^Ð^å‘7”7×*Ò*¨;¸eÈWÐ*ÑUÔUÐUr9   )r&  r½   rA   rB   ©r)  r   rA   r   ©r-  r   rA   r   )r+  r¾   r*  rO   rA   r.   ©r6  r¾   r+  r¾   r*  rO   rA   r.   r  r  )r3   r4   r5   rl   r:  r=  r5  rK  r2  r8  Ú__classcell__©r|  s   @r:   r%  r%  >  s   ø€ € € € € ð4ð 4ð 4ð 4ð 4ð 4ðð ð ð ðEð Eð Eð EðOð Oð Oð Oð%ð %ð %ð %ðX #ð%ð %ð %ð %ð %ð %ð %ð %ðV '+Ø26ðVð Vð Vð Vð Vð Vð Vð Vð Vð Vð Vð Vr9   r%  c                  óT   ‡ — e Zd Zdˆ fd„Zdˆ fd„Zd ˆ fd„Zd!ˆ fd„Zd"d„Zd#d„Zˆ xZ	S )$Ú_ExportCodeGenr&  r½   Úin_shuffle_graphr%   Úout_shuffle_graphÚtree_leaf_namesr¾   Úrootútorch.nn.Module | NonerA   rB   c                ó‚   •— t          ¦   «                              |¦  «         || _        || _        || _        || _        d S rD   )r(  rl   rY  rZ  r[  r\  )rk   r&  rY  rZ  r[  r\  r|  s         €r:   rl   z_ExportCodeGen.__init__Ç  s@   ø€ õ 	‰Œ×Ò˜Ñ%Ô%Ð%Ø 0ˆÔØ!2ˆÔØ.ˆÔØˆŒ	ˆ	ˆ	r9   r)  r   c                óv   •—  t          ¦   «         j        |Ž }| j        �| j        g|¢R }|| _         | j        |Ž S rD   )r(  r:  r\  r,  rY  )rk   r)  r,  r|  s      €r:   r:  z_ExportCodeGen.process_inputsÕ  sG   ø€ Ø*•E‘G”GÔ*¨FÐ3ˆ	ØŒ9Ð ØœÐ/ YÐ/Ð/ˆIØ"ˆŒØ$ˆtÔ$ iÐ0Ð0r9   r-  c                óv   •—  | j         g | j        ¢|¢R Ž }| `t          ¦   «                              |¦  «        }|S rD   )rZ  r,  r(  r=  )rk   r-  Ú	flat_outsÚretr|  s       €r:   r=  z_ExportCodeGen.process_outputsÜ  sC   ø€ Ø*�DÔ*ÐA¨D¬NÐA¸SÐAÐAÐAˆ	ØˆNÝ‰gŒg×%Ò% iÑ0Ô0ˆØˆ
r9   rê   r  r.   c                ó:   •—  t          ¦   «         j        |i |¤Ž}|S rD   )r(  r2  )rk   rê   r  r!  r|  s       €r:   r2  z_ExportCodeGen.gen_fn_defâ  s#   ø€ Ø#•‘”Ô# TÐ4¨VÐ4Ð4ˆØˆr9   r6  r+  r*  rO   c           
     ó  — d„ |D ¦   «         }d                      |¦  «        › }| j        �d|› �}dd                      | j        ¦  «        › d|› dd                      |¦  «        › dd                      | j        ¦  «        › d�	S )	Nc                óv   — g | ]6}|                      d ¦  «        d                               d¦  «        d         ‘Œ7S r>  r?  rÀ  s     r:   r  z3_ExportCodeGen.gen_var_bindings.<locals>.<listcomp>é  r@  r9   r/  zself, r   z, = pytree.tree_leaves((z,))
    z, = self._in_shuffle_graph(r  )rò   r\  r[  )rk   r6  r+  r*  rI  rG  s         r:   rK  z_ExportCodeGen.gen_var_bindingsæ  s»   € ð PÐOÀYÐOÑOÔOÐØ#Ÿyšy¨Ñ1Ô1Ð3ˆØŒ9Ð Ø2 LÐ2Ð2ˆLðdØ	‡Y‚YˆtÔ#Ñ$Ô$ðdð dØ>Jðdð dà	‡Y‚YÐ!Ñ"Ô"ðdð dà?C¿yºyÈÔI]Ñ?^Ô?^ðdð dð dð 	dr9   r4  r   c                ó   — t          |t          t          f¦  «        st          dt	          |¦  «        › �¦  «        ‚dd                     | j        ¦  «        › dd                     d„ |D ¦   «         ¦  «        › d�}d|› d�S )Nz,Expected list or tuple for output_args, got zself._out_shuffle_graph(r/  c                ó,   — g | ]}t          |¦  «        ‘ŒS r8   r¿  ©r<   rs  s     r:   r  z2_ExportCodeGen.generate_output.<locals>.<listcomp>ö  s#   € ÐYvÐYvÐYvÐefÕZ]Ð^_ÑZ`ÔZ`ÐYvÐYvÐYvr9   r  rP  rQ  )r  r7  r  Ú	TypeErrorr¢   rò   r[  )rk   r4  rê   r  r+   s        r:   r8  z_ExportCodeGen.generate_outputñ  s”   € Ý˜+­­e }Ñ5Ô5ð 	ÝØR½tÀKÑ?PÔ?PÐRÐRñô ð ð {¨D¯IªI°dÔ6JÑ,KÔ,KÐzÐzÈtÏyÊyÐYvÐYvÐjuÐYvÑYvÔYvÑOwÔOwÐzÐzÐzˆØH¨vÐHÐHÐHÐHr9   )r&  r½   rY  r%   rZ  r%   r[  r¾   r\  r]  rA   rB   rR  rS  )rê   r   r  r   rA   r.   rT  )r4  r   rê   r   r  r   rA   r.   )
r3   r4   r5   rl   r:  r=  r2  rK  r8  rU  rV  s   @r:   rX  rX  Æ  sË   ø€ € € € € ðð ð ð ð ð ð1ð 1ð 1ð 1ð 1ð 1ðð ð ð ð ð ðð ð ð ð ð ð	dð 	dð 	dð 	dðIð Ið Ið Ið Ið Ið Ið Ir9   rX  c                  óH   — e Zd ZdZdd„Zdd„Zdd
„Zdd„Zdd„Zddœdd„Z	dS )Ú_FindNodesLookupTablezH
    Side table for the graph for the purpose of doing fast queries
    rA   rB   c                ó8   — t          t          ¦  «        | _        d S rD   )r   rC  Útablerj   s    r:   rl   z_FindNodesLookupTable.__init__ÿ  s   € ÝHSÝñI
ô I
ˆŒ
ˆ
ˆ
r9   r¥  r   útuple[str, Target | None]c                ó8   — |j         |j         dk    r|j        nd fS )Nr&   ©rž  rŽ   ©rk   r¥  s     r:   Ú_keyz_FindNodesLookupTable._key  s!   € Ø”¨¬°?Ò(BÐ(B˜œ˜ÈÐMÐMr9   rO   c                óF   — || j         |                      |¦  «                 v S rD   ©rm  rr  rq  s     r:   Ú__contains__z"_FindNodesLookupTable.__contains__  s   € Ø�t”z $§)¢)¨D¡/¤/Ô2Ð2Ð2r9   c                óL   — d | j         |                      |¦  «                 |<   d S rD   rt  rq  s     r:   r0  z_FindNodesLookupTable.insert
  s#   € Ø,0ˆŒ
�4—9’9˜T‘?”?Ô# DÑ)Ð)Ð)r9   c                ól   — | j         |                      |¦  «                                      |¦  «         d S rD   )rm  rr  Úpoprq  s     r:   Úremovez_FindNodesLookupTable.remove  s-   € ØŒ
�4—9’9˜T‘?”?Ô#×'Ò'¨Ñ-Ô-Ð-Ð-Ð-r9   N©rŽ   rž  r.   rŽ   úTarget | Noneú	list[Any]c               óø   ‡— |dk    r4‰€t          d¦  «        ‚g | j        |‰f                              ¦   «         ¢S ‰€#g | j        |d f                              ¦   «         ¢S ˆfd„| j        |d f         D ¦   «         S )Nr&   z,target must not be None for call_function opc                ó*   •— g | ]}|j         ‰k    ¯|‘ŒS r8   rz  )r<   r¥  rŽ   s     €r:   r  z4_FindNodesLookupTable.find_nodes.<locals>.<listcomp>  s%   ø€ ÐQÐQÐQ˜¸4¼;È&Ò;PÐ;P�Ð;PÐ;PÐ;Pr9   )rx   rm  r   )rk   rž  rŽ   s     `r:   Ú
find_nodesz _FindNodesLookupTable.find_nodes  s“   ø€ Ø�Ò Ð Øˆ~Ý$Ð%SÑTÔTÐTØ5�T”Z  V Ô-×2Ò2Ñ4Ô4Ð5Ð5àˆ>Ø3�T”Z  T 
Ô+×0Ò0Ñ2Ô2Ð3Ð3ð RÐQÐQÐQ ¤¨R°¨JÔ!7ÐQÑQÔQÐQr9   r†   )r¥  r   rA   rn  ©r¥  r   rA   rO   rÿ  )rž  r.   rŽ   r{  rA   r|  )
r3   r4   r5   r6   rl   rr  ru  r0  ry  r  r8   r9   r:   rk  rk  ú  s²   € € € € € ðð ð
ð 
ð 
ð 
ð
Nð Nð Nð Nð3ð 3ð 3ð 3ð1ð 1ð 1ð 1ð.ð .ð .ð .ð >Bð 
Rð 
Rð 
Rð 
Rð 
Rð 
Rð 
Rð 
Rr9   rk  c            	      ó,  — e Zd ZdZ ed¬¦  «        	 	 	 d„d…d„¦   «         Zed†d„¦   «         Zej        d‡d„¦   «         Zedˆd„¦   «         Z	 ed¬¦  «        d‰d„¦   «         Z
 ed¬¦  «        dddœdŠd„¦   «         Z ed¬¦  «        	 d‹dŒd$„¦   «         Zd�dŽd'„Z ed¬¦  «        	 	 	 	 d�d�d1„¦   «         Z ed¬¦  «        d‘d3„¦   «         Z ed¬¦  «        d’d5„¦   «         Z ed¬¦  «        d“d7„¦   «         Z ed¬¦  «        d�d”d;„¦   «         Z ed¬¦  «        d�d”d<„¦   «         Z ed¬¦  «        dej        j        fd•d>„¦   «         Z ed¬¦  «        d�d–d@„¦   «         Z ed¬¦  «        	 	 	 d„d—dB„¦   «         Z ed¬¦  «        	 	 	 d„d˜dD„¦   «         Z ed¬¦  «        	 	 	 	 d�d™dG„¦   «         ZedšdJ„¦   «         Z ed¬¦  «        d›dM„¦   «         Z ed¬¦  «        d›dN„¦   «         Z ed¬¦  «        dœdO„¦   «         Z  ed¬¦  «        d�dU„¦   «         Z! ed¬¦  «        dždY„¦   «         Z" ed¬¦  «        dŸd]„¦   «         Z# ed¬¦  «        d^„ fd db„¦   «         Z$ ed¬¦  «        	 d�d¡de„¦   «         Z%d¢df„Z& ed¬¦  «        ddddddddgœd£dr„¦   «         Z'ddddddddgœd¤du„Z(d¥dv„Z) ed¬¦  «        d¦dw„¦   «         Z* ed¬¦  «        d¦dx„¦   «         Z+ ed¬¦  «        	 d�d§d{„¦   «         Z, ed¬¦  «        d¨d~„¦   «         Z- ed¬¦  «        d©d‚„¦   «         Z.d¦dƒ„Z/dS )ªr#   a…  
    ``Graph`` is the main data structure used in the FX Intermediate Representation.
    It consists of a series of ``Node`` s, each representing callsites (or other
    syntactic constructs). The list of ``Node`` s, taken together, constitute a
    valid Python function.

    For example, the following code

    .. code-block:: python

        import torch
        import torch.fx


        class MyModule(torch.nn.Module):
            def __init__(self):
                super().__init__()
                self.param = torch.nn.Parameter(torch.rand(3, 4))
                self.linear = torch.nn.Linear(4, 5)

            def forward(self, x):
                return torch.topk(
                    torch.sum(self.linear(x + self.linear.weight).relu(), dim=-1), 3
                )


        m = MyModule()
        gm = torch.fx.symbolic_trace(m)

    Will produce the following Graph::

        print(gm.graph)

    .. code-block:: text

        graph(x):
            %linear_weight : [num_users=1] = self.linear.weight
            %add_1 : [num_users=1] = call_function[target=operator.add](args = (%x, %linear_weight), kwargs = {})
            %linear_1 : [num_users=1] = call_module[target=linear](args = (%add_1,), kwargs = {})
            %relu_1 : [num_users=1] = call_method[target=relu](args = (%linear_1,), kwargs = {})
            %sum_1 : [num_users=1] = call_function[target=torch.sum](args = (%relu_1,), kwargs = {dim: -1})
            %topk_1 : [num_users=1] = call_function[target=torch.topk](args = (%sum_1, 3), kwargs = {})
            return topk_1

    For the semantics of operations represented in the ``Graph``, please see :class:`Node`.
    Tr‡   NÚowning_moduleúGraphModule | NoneÚ
tracer_clsútype[Tracer] | NoneÚtracer_extrasúdict[str, Any] | NonerA   rB   c                ó   — t          | ddddi ¦  «        | _        i | _        | j        j        | _        d| _        t          ¦   «         | _        || _        || _	        || _
        t          ¦   «         | _        i | _        t          ¦   «         | _        dS )z+
        Construct an empty Graph.
        rì   r\  r8   r   N)r   r·   rh   Úprependrž   r²   rd   Ú_graph_namespaceÚ_owning_moduleÚ_tracer_clsÚ_tracer_extrasr"   Ú_codegenÚ
_co_fieldsrk  Ú_find_nodes_lookup_table)rk   r‚  r„  r†  s       r:   rl   zGraph.__init__O  s‚   € õ    b¨&°"°b¸"Ñ=Ô=ˆŒ
Ø+-ˆÔØ”zÔ)ˆŒØˆŒ	Ý *¡¤ˆÔØ+ˆÔØ%ˆÔØ+ˆÔÝ™	œ	ˆŒØ*,ˆŒÝ(=Ñ(?Ô(?ˆÔ%Ð%Ð%r9   c                ó   — | j         S rD   ©r‹  rj   s    r:   r‚  zGraph.owning_modulee  s   € àÔ"Ð"r9   Úmodc                ó   — || _         d S rD   r’  )rk   r“  s     r:   r‚  zGraph.owning_modulei  s   € à!ˆÔÐÐr9   r«   c                ó    — t          | ¦  «        S )av  
        Get the list of Nodes that constitute this Graph.

        Note that this ``Node`` list representation is a doubly-linked list. Mutations
        during iteration (e.g. delete a Node, add a Node) are safe.

        Returns:

            A doubly-linked list of Nodes. Note that ``reversed`` can be called on
            this list to switch iteration order.
        )r«   rj   s    r:   rH  zGraph.nodesm  s   € õ ˜$ÑÔÐr9   Fr   c                ó¦   — t          t          t          | j        ¦  «        ¦  «        ¦  «        }|j        dk    rt          d|j        › �¦  «        ‚|S )Nr+   zExpected output node, got op=)ÚnextÚiterr  rH  rž  rx   )rk   Úoutput_nodes     r:   r™  zGraph.output_node|  sM   € å�4¥¨¬Ñ 4Ô 4Ñ5Ô5Ñ6Ô6ˆØŒ>˜XÒ%Ð%Ý Ð!QÀÄÐ!QÐ!QÑRÔRÐRØÐr9   )rŽ   Úsortrž  r.   rŽ   r{  rš  rO   r|  c               ó`   — | j                              ||¬¦  «        }|rt          |¦  «        S |S )aÚ  
        Allows for fast query of nodes

        Args:

            op (str): the name of the operation

            target (Optional[Target]): the target of the node. For call_function,
                the target is required. For other ops, the target is optional.

            sort (bool): whether to return nodes in the order they appear on
                         on the graph.

        Returns:

            Iterable of nodes with the requested op and target.
        rp  )r�  r  Úsorted)rk   rž  rŽ   rš  Ú	node_lists        r:   r  zGraph.find_nodesƒ  s;   € ð, Ô1×<Ò<ÀÈ6Ð<ÑRÔRˆ	Øð 	%Ý˜)Ñ$Ô$Ð$ØÐr9   ÚgÚval_mapúdict[Node, Node]Úreturn_output_nodeúArgument | Nonec                óÄ   ‡— |j         D ]V}|‰v rŒ|j        dk    r(t          |j        d         ˆfd„¦  «        }|s|n||fc S |                      |ˆfd„¦  «        ‰|<   ŒWdS )aM  
        Copy all nodes from a given graph into ``self``.

        Args:

            g (Graph): The source graph from which to copy Nodes.

            val_map (Dict[Node, Node]): a dictionary that will be populated with a mapping
                from nodes in ``g`` to nodes in ``self``. Note that ``val_map`` can be passed
                in with values in it already to override copying of certain values.

        Returns:

            The value in ``self`` that is now equivalent to the output value in ``g``,
            if ``g`` had an ``output`` node. ``None`` otherwise.
        r+   r   c                ó   •— ‰|          S rD   r8   ©r‰  rŸ  s    €r:   rã   z"Graph.graph_copy.<locals>.<lambda>¶  s   ø€ °W¸Q´Z€ r9   c                ó   •— ‰|          S rD   r8   r¥  s    €r:   rã   z"Graph.graph_copy.<locals>.<lambda>¸  s   ø€ ¸7À1¼:€ r9   N)rH  rž  Úmap_argrê   Ú	node_copy)rk   rž  rŸ  r¡  r¥  Úrvs     `   r:   Ú
graph_copyzGraph.graph_copyž  s‘   ø€ ð( ”Gð 	Gð 	GˆDØ�wˆˆØØŒw˜(Ò"Ð"Ý˜TœY qœ\Ð+?Ð+?Ð+?Ð+?Ñ@Ô@�Ø!3ÐC�r�r¸"¸d¸ÐCÐCÐCØ ŸNšN¨4Ð1EÐ1EÐ1EÐ1EÑFÔFˆG�D‰MˆMØˆtr9   Úmemoúdict[int, Any] | Nonec                ó¦  — |r|ni }t          | j        ¬¦  «        }|                     | |d¬¦  «        }t          j        | j        ¦  «        |_        |�}t          |t          ¦  «        st          dt          |¦  «        › �¦  «        ‚|\  }}| 
                    |t          |dd¦  «        ¬¦  «        }t          j        |j        ¦  «        |_        |S )a’  
        Explicitly implement __deepcopy__ to prevent excessive recursion depth
        from the default implementation. This uses graph_copy to copy the nodes
        in an iterative way, rather than recursive. It also populates the
        memoization table to prevent unnecessary copies (e.g. references to
        nodes or other parts of the Graph from a custom GraphModule implementation.
        )r„  T)rŸ  r¡  Nz&Expected output_vals to be tuple, got r¢   ©Ú	type_expr)r#   rŒ  rª  ÚcopyÚdeepcopyrŽ  r  r  rx   r¢   r+   r\   r«  )rk   r«  rž  Úoutput_valsÚ
output_valÚold_output_nodeÚnew_output_nodes          r:   Ú__deepcopy__zGraph.__deepcopy__»  sê   € ð Ð#ˆtˆt ˆÝ˜TÔ-Ð.Ñ.Ô.ˆØ—l’lØØØ#ð #ñ 
ô 
ˆõ
 ”] 4¤=Ñ1Ô1ˆŒ
ØÐ"Ý˜k­5Ñ1Ô1ð Ý$ØP½TÀ+Ñ=NÔ=NÐPÐPñô ð ð +6Ñ'ˆJ˜ØŸhšhàÝ! /°6¸4Ñ@Ô@ð 'ñ ô ˆOõ $(¤9¨_Ô-AÑ#BÔ#BˆOÔ Øˆr9   r   rê   útuple[Argument, ...] | Noner  údict[str, Argument] | Noner@   ú
str | Noner¯  ú
Any | Nonec                óÈ  — |sd}n4t          |t          ¦  «        st          dt          |¦  «        › �¦  «        ‚|st	          ¦   «         }n4t          |t
          ¦  «        st          dt          |¦  «        › �¦  «        ‚|dv r…|s|r�t          j        ||f¦  «        D ]j}t          |t          j	        t          j
        t          j        f¦  «        r7t          j        dt          |¦  «        j        › d|› d|› d|› d	�	d
¬¦  «          nŒk|�|n|                      |¦  «        }| j                             |d¦  «        }t%          | ||||||¦  «        }	| j        �0t)          | j        dd¦  «        �| j        j        D ]}
 |
|	¦  «         Œ| j                             ||	¦  «         |                      |	¦  «         | j                             |	¦  «         | xj        dz  c_        |	S )a&  
        Create a ``Node`` and add it to the ``Graph`` at the current insert-point.
        Note that the current insert-point can be set via :meth:`Graph.inserting_before`
        and :meth:`Graph.inserting_after`.

        Args:
            op (str): the opcode for this Node. One of 'call_function', 'call_method', 'get_attr',
                'call_module', 'placeholder', or 'output'. The semantics of these opcodes are
                described in the ``Graph`` docstring.

            args (Optional[Tuple[Argument, ...]]): is a tuple of arguments to this node.

            kwargs (Optional[Dict[str, Argument]]): the kwargs of this Node

            name (Optional[str]): an optional string name for the ``Node``.
                This will influence the name of the value assigned to in the
                Python generated code.

            type_expr (Optional[Any]): an optional type annotation representing the
                Python type the output of this node will have.

        Returns:

            The newly-created and inserted node.
        r8   zargs must be a tuple, got zkwargs must be a dict, got rø  zRaw z value (z.) passed as argument to Graph.create_node(op='z
', target=zu). Use create_*_node() helpers for tensor metadata queries or materialize_symints() for general symbolic expressions.rr   ©Ú
stacklevelNÚ_create_node_hooksr   )r  r  rx   r¢   r   rC  rM   Ú	tree_iterrJ   ÚSymIntÚSymFloatÚSymBoolÚwarningsÚwarnr3   Ú_target_to_strrŠ  r   r   r‚  r\   r¾  rƒ   rž   r�  r0  r²   )rk   rž  rŽ   rê   r  r@   r¯  rÆ  rm   r‰  Úfs              r:   Úcreate_nodezGraph.create_nodeÚ  s@  € ðH ð 	PØˆDˆDå˜d¥EÑ*Ô*ð PÝ$Ð%NÅ$ÀtÁ*Ä*Ð%NÐ%NÑOÔOÐOØð 	SÝ#Ñ%Ô%ˆFˆFå˜f¥dÑ+Ô+ð SÝ$Ð%QÅ4ÈÁ<Ä<Ð%QÐ%QÑRÔRÐRð Ð@Ð@Ð@ÀdÐ@ÈfÐ@ÝÔ'¨¨v¨Ñ7Ô7ð 	ð 	�Ý˜c¥E¤Lµ%´.Å%Ä-Ð#PÑQÔQð Ý”MðV�t C™yœyÔ1ð Vð V¸3ð Vð VØ13ðVð VØ?EðVð Vð Vð $%ðñ ô ð ð �Eðð !Ð,�D�D°$×2EÒ2EÀfÑ2MÔ2Mˆ	ØÔ$×0Ò0°¸DÑAÔAˆÝ��t˜R ¨¨v°yÑAÔAˆð ÔÐ*Ý˜Ô*Ð,@À$ÑGÔGÐSàÔ'Ô:ð ð �Ø��!‘”��àÔ×5Ò5°d¸AÑ>Ô>Ð>à�Š�Q‰ŒˆØÔ%×,Ò,¨QÑ/Ô/Ð/Øˆ	Œ	�Q‰ˆ	Œ	Øˆr9   r   c                ó    —  | j         j        |Ž S )zL
        Processes args so that they can be passed to the FX graph.
        )rŽ  r:  ró   s     r:   r:  zGraph.process_inputs)  s   € ð
 ,ˆtŒ}Ô+¨TÐ2Ð2r9   r-  c                ó6   — | j                              |¦  «        S rD   )rŽ  r=  r0  s     r:   r=  zGraph.process_outputs0  s   € àŒ}×,Ò,¨SÑ1Ô1Ð1r9   Úto_erasec           	     óˆ  — t          |j        ¦  «        dk    r0t          d|› dt          |j        ¦  «        › d|j        › d�¦  «        ‚|j        | k    rt          d|› d�¦  «        ‚|j        rt          j        d|› d	�¦  «         d
S | j        �0t          | j        dd
¦  «        �| j        j	        D ]} ||¦  «         Œ| j
                             |¦  «         |                     ¦   «          d|_        | xj        dz  c_        |                     t          |j        d„ ¦  «        t          |j        d„ ¦  «        ¦  «         d
S )zâ
        Erases a ``Node`` from the ``Graph``. Throws an exception if
        there are still users of that node in the ``Graph``.

        Args:

            to_erase (Node): The ``Node`` to erase from the ``Graph``.
        r   zTried to erase Node z but it still had z users in the graph: ú!zAttempting to remove z from wrong graph!zerase_node(z) on an already erased nodeNÚ_erase_node_hooksTr   c                ó   — d S rD   r8   ©r‰  s    r:   rã   z"Graph.erase_node.<locals>.<lambda>Y  s   € ¨d€ r9   c                ó   — d S rD   r8   rÏ  s    r:   rã   z"Graph.erase_node.<locals>.<lambda>Z  s   € °€ r9   )rØ   rŸ  ÚRuntimeErrorrš   Ú_erasedrÃ  rÄ  r‚  r\   rÍ  r�  ry  Ú_remove_from_listr²   Ú_update_args_kwargsr§  Ú_argsÚ_kwargs)rk   rÊ  rÆ  s      r:   Ú
erase_nodezGraph.erase_node4  s‡  € õ ˆxŒ~ÑÔ Ò"Ð"Ýð9 xð 9ð 9Å3ÀxÄ~ÑCVÔCVð 9ð 9Ø'/¤~ð9ð 9ð 9ñô ð ð Œ>˜TÒ!Ð!ÝÐS°xÐSÐSÐSÑTÔTÐTØÔð 	ÝŒMÐM¨ÐMÐMÐMÑNÔNÐNØˆFð ÔÐ*Ý˜Ô*Ð,?ÀÑFÔFÐRàÔ'Ô9ð ð �Ø��(‘”��àÔ%×,Ò,¨XÑ6Ô6Ð6à×"Ò"Ñ$Ô$Ð$ØˆÔØˆ	Œ	�Q‰ˆ	Œ	ð 	×$Ò$Ý�H”N N NÑ3Ô3Ý�HÔ$ n nÑ5Ô5ñ	
ô 	
ð 	
ð 	
ð 	
r9   r‰  úNode | Noner™   c                ó˜   — |€|                       | j        ¦  «        S |j        | k    rt          d¦  «        ‚t	          | |j        ¦  «        S )aÜ  Set the point at which create_node and companion methods will insert into the graph.
        When used within a 'with' statement, this will temporarily set the insert point and
        then restore it when the with statement exits::

            with g.inserting_before(n):
                ...  # inserting before node n
            ...  # insert point restored to what it was previously
            g.inserting_before(n)  #  set the insert point permanently

        Args:

            n (Optional[Node]): The node before which to insert. If None this will insert before
                the beginning of the entire graph.

        Returns:
            A resource manager that will restore the insert point on ``__exit__``.
        Nz&Node to insert before is not in graph.)Úinserting_afterr·   rš   rx   r™   r‰  ©rk   r‰  s     r:   Úinserting_beforezGraph.inserting_before]  sK   € ð& ˆ9Ø×'Ò'¨¬
Ñ3Ô3Ð3ØŒ7�dŠ?ˆ?Ý Ð!IÑJÔJÐJÝ˜D !¤)Ñ,Ô,Ð,r9   c                ó˜   — |€|                       | j        ¦  «        S |j        | k    rt          d¦  «        ‚t	          | |j        ¦  «        S )aØ  Set the point at which create_node and companion methods will insert into the graph.
        When used within a 'with' statement, this will temporarily set the insert point and
        then restore it when the with statement exits::

            with g.inserting_after(n):
                ...  # inserting after node n
            ...  # insert point restored to what it was previously
            g.inserting_after(n)  #  set the insert point permanently

        Args:

            n (Optional[Node]): The node before which to insert. If None this will insert after
                the beginning of the entire graph.

        Returns:
            A resource manager that will restore the insert point on ``__exit__``.
        Nz%Node to insert after is not in graph.)rÜ  r·   rš   rx   r™   r–  rÛ  s     r:   rÚ  zGraph.inserting_afterv  sK   € ð& ˆ9Ø×(Ò(¨¬Ñ4Ô4Ð4ØŒ7�dŠ?ˆ?Ý Ð!HÑIÔIÐIÝ˜D !¤(Ñ+Ô+Ð+r9   Údefault_valuec                ód   — |t           j        j        u rdn|f}|                      d|||¬¦  «        S )a%  
        Insert a ``placeholder`` node into the Graph. A ``placeholder`` represents
        a function input.

        Args:

            name (str): A name for the input value. This corresponds to the name
                of the positional argument to the function this ``Graph`` represents.

            type_expr (Optional[Any]): an optional type annotation representing the
                Python type the output of this node will have. This is needed in some
                cases for proper code generation (e.g. when the function is used
                subsequently in TorchScript compilation).

            default_value (Any): The default value this function argument should take
                on. NOTE: to allow for `None` as a default value, `inspect.Signature.empty`
                should be passed as this argument to specify that the parameter does _not_
                have a default value.

        .. note::
            The same insertion point and type expression rules apply for this method
            as ``Graph.create_node``.
        r8   r*   )rê   r¯  )r%  Ú	SignatureÚemptyrÇ  )rk   r@   r¯  rÞ  rê   s        r:   r*   zGraph.placeholder�  s=   € ð< #¥gÔ&7Ô&=Ð=Ð=ˆrˆrÀMÐCSˆØ×Ò ¨t¸$È)ÐÑTÔTÐTr9   r„  c                ó–   — dd„}| j         �' || j         |¦  «        st          j        d	d
¬¦  «         |                      d||¬¦  «        S )aˆ  
        Insert a ``get_attr`` node into the Graph. A ``get_attr`` ``Node`` represents the
        fetch of an attribute from the ``Module`` hierarchy.

        Args:

            qualified_name (str): the fully-qualified name of the attribute to be retrieved.
                For example, if the traced Module has a submodule named ``foo``, which has a
                submodule named ``bar``, which has an attribute named ``baz``, the qualified
                name ``foo.bar.baz`` should be passed as ``qualified_name``.

            type_expr (Optional[Any]): an optional type annotation representing the
                Python type the output of this node will have.


        Returns:

            The newly-created and inserted ``get_attr`` node.

        .. note::
            The same insertion point and type expression rules apply for this method
            as ``Graph.create_node``.
        r“  útorch.nn.Moduler„  r.   rA   rO   c                óŽ  — |                      d¦  «        \  }}}	 |                      |¦  «        }n)# t          $ r t          j        d|› d�¦  «         Y dS w xY wt          ||¦  «        sdS t          ||¦  «        }t          |t          j	        j
        ¦  «        s*t          |t          j	        j        ¦  «        s||j        vrdS dS )Nr�   zFailed to fetch module rÌ  FT)Ú
rpartitionÚget_submoduleÚAttributeErrorrÃ  rÄ  rv  r\   r  rJ   r^   ÚModuleÚ	ParameterÚ_buffers)r“  r„  Úmodule_pathrp   r@   Úsubmodr’  s          r:   Ú_get_attr_reference_existsz2Graph.get_attr.<locals>._get_attr_reference_existsÊ  sæ   € ð $2×#<Ò#<¸SÑ#AÔ#AÑ ˆK˜˜DðØ*-×*;Ò*;¸KÑ*HÔ*H��øÝ!ð ð ð Ý”ÐF¸ÐFÐFÐFÑGÔGÐGØ�u�uðøøøõ ˜6 4Ñ(Ô(ð Ø�uå˜& $Ñ'Ô'ˆCõ ˜s¥E¤H¤OÑ4Ô4ðå" 3­¬Ô(:Ñ;Ô;ðð  ¤Ð/Ð/à�uà�4s   ›1 ±"AÁANa  Attempted to insert a get_attr Node with no underlying reference in the owning GraphModule! Call GraphModule.add_submodule to add the necessary submodule, GraphModule.add_parameter to add the necessary Parameter, or nn.Module.register_buffer to add the necessary bufferrr   r¼  r(   r®  )r“  rã  r„  r.   rA   rO   )r‚  rÃ  rÄ  rÇ  )rk   r„  r¯  rí  s       r:   r(   zGraph.get_attr°  s~   € ð4	ð 	ð 	ð 	ð2 ÔÐ)Ð2LÐ2LØÔ ñ3
ô 3
Ð)õ ŒMð#ð ðñ ô ð ð ×Ò 
¨NÀiÐÑPÔPÐPr9   r`   c                ó    — | j         �.| j                              |¦  «        €t          j        d¦  «         |                      d||||¬¦  «        S )a÷  
        Insert a ``call_module`` ``Node`` into the ``Graph``. A ``call_module`` node
        represents a call to the forward() function of a ``Module`` in the ``Module``
        hierarchy.

        Args:

            module_name (str): The qualified name of the ``Module`` in the ``Module``
                hierarchy to be called. For example, if the traced ``Module`` has a
                submodule named ``foo``, which has a submodule named ``bar``, the
                qualified name ``foo.bar`` should be passed as ``module_name`` to
                call that module.

            args (Optional[Tuple[Argument, ...]]): The positional arguments to be passed
                to the called method. Note that this should *not* include a ``self`` argument.

            kwargs (Optional[Dict[str, Argument]]): The keyword arguments to be passed
                to the called method

            type_expr (Optional[Any]): an optional type annotation representing the
                Python type the output of this node will have.

        Returns:

            The newly-created and inserted ``call_module`` node.

        .. note::
            The same insertion point and type expression rules apply for this method
            as :meth:`Graph.create_node`.
        NzœAttempted to insert a call_module Node with no underlying reference in the owning GraphModule! Call GraphModule.add_submodule to add the necessary submoduler)   r®  )r‚  ræ  rÃ  rÄ  rÇ  )rk   r`   rê   r  r¯  s        r:   r)   zGraph.call_moduleô  sh   € ðN ÔÐ*ØÔ"×0Ò0°Ñ=Ô=ÐEåŒMð&ñô ð ð ×ÒØ˜;¨¨fÀ	ð  ñ 
ô 
ð 	
r9   Úmethod_namec                ó6   — |                       d||||¬¦  «        S )aj  
        Insert a ``call_method`` ``Node`` into the ``Graph``. A ``call_method`` node
        represents a call to a given method on the 0th element of ``args``.

        Args:

            method_name (str): The name of the method to apply to the self argument.
                For example, if args[0] is a ``Node`` representing a ``Tensor``,
                then to call ``relu()`` on that ``Tensor``, pass ``relu`` to ``method_name``.

            args (Optional[Tuple[Argument, ...]]): The positional arguments to be passed
                to the called method. Note that this *should* include a ``self`` argument.

            kwargs (Optional[Dict[str, Argument]]): The keyword arguments to be passed
                to the called method

            type_expr (Optional[Any]): an optional type annotation representing the
                Python type the output of this node will have.

        Returns:

            The newly created and inserted ``call_method`` node.

        .. note::
            The same insertion point and type expression rules apply for this method
            as :meth:`Graph.create_node`.
        r'   r®  ©rÇ  )rk   rï  rê   r  r¯  s        r:   r'   zGraph.call_method)  s-   € ðF ×ÒØ˜;¨¨fÀ	ð  ñ 
ô 
ð 	
r9   Úthe_functionr  c                ó8   — |                       d|||||¬¦  «        S )ag  
        Insert a ``call_function`` ``Node`` into the ``Graph``. A ``call_function`` node
        represents a call to a Python callable, specified by ``the_function``.

        Args:

            the_function (Callable[..., Any]): The function to be called. Can be any PyTorch
                operator, Python function, or member of the ``builtins`` or ``operator``
                namespaces.

            args (Optional[Tuple[Argument, ...]]): The positional arguments to be passed
                to the called function.

            kwargs (Optional[Dict[str, Argument]]): The keyword arguments to be passed
                to the called function

            type_expr (Optional[Any]): an optional type annotation representing the
                Python type the output of this node will have.

            name (Optional[str]): The name of the node. If not specified, set to None

        Returns:

            The newly created and inserted ``call_function`` node.

        .. note::
            The same insertion point and type expression rules apply for this method
            as :meth:`Graph.create_node`.
        r&   )r@   r¯  rñ  )rk   rò  rê   r  r¯  r@   s         r:   r&   zGraph.call_functionP  s/   € ðL ×ÒØ˜\¨4°¸dÈið  ñ 
ô 
ð 	
r9   Útensor_nodeútuple[Any, str]c                óf   — d| j         v r| j         d         dfS d| j         v r| j         d         dfS dS )aÎ  Read the example tensor stored on ``tensor_node`` under either
        ``meta['val']`` (export / proxy_tensor convention) or
        ``meta['example_value']`` (dynamo convention).

        Returns ``(value, key)`` where ``key`` is the meta key the value was
        found under (defaulting to ``"val"`` if no meta is present). Callers
        that emit a new node should mirror ``key`` so the new node matches
        the surrounding graph's convention.
        rÆ  rÈ  )NrÆ  )r«  )rô  s    r:   Ú_get_tensor_meta_valzGraph._get_tensor_meta_valz  sK   € ð �KÔ$Ð$Ð$ØÔ# EÔ*¨EÐ1Ð1Ø˜kÔ.Ð.Ð.ØÔ# OÔ4°oÐEÐEØˆ{r9   rl  r{   c                óÖ   — |                       |¦  «        \  }}|                      t          j        j        j        j        ||f¦  «        }|�|                     |¦  «        |j        |<   |S )z0Create an FX node for ``tensor_node.size(dim)``.)	r÷  r&   rJ   ÚopsÚatenÚsym_sizer{   r~  r«  ©rk   rô  rl  rÆ  r°  r¥  s         r:   Úcreate_size_nodezGraph.create_size_node‹  s^   € ð ×,Ò,¨[Ñ9Ô9‰ˆˆSØ×!Ò!¥%¤)¤.Ô"9Ô"=ÀÈSÐ?QÑRÔRˆØˆ?Ø ŸXšX c™]œ]ˆDŒI�c‰NØˆr9   c                óÖ   — |                       |¦  «        \  }}|                      t          j        j        j        j        ||f¦  «        }|�|                     |¦  «        |j        |<   |S )z2Create an FX node for ``tensor_node.stride(dim)``.)	r÷  r&   rJ   rù  rú  Ú
sym_strider{   rË  r«  rü  s         r:   Úcreate_stride_nodezGraph.create_stride_node”  s^   € ð ×,Ò,¨[Ñ9Ô9‰ˆˆSØ×!Ò!¥%¤)¤.Ô";Ô"?À+ÈsÐASÑTÔTˆØˆ?Ø ŸZšZ¨™_œ_ˆDŒI�c‰NØˆr9   c                óÒ   — |                       |¦  «        \  }}|                      t          j        j        j        j        |f¦  «        }|�|                     ¦   «         |j        |<   |S )z7Create an FX node for ``tensor_node.storage_offset()``.)	r÷  r&   rJ   rù  rú  Úsym_storage_offsetÚdefaultÚstorage_offsetr«  )rk   rô  rÆ  r°  r¥  s        r:   Úcreate_storage_offset_nodez Graph.create_storage_offset_node�  sd   € ð ×,Ò,¨[Ñ9Ô9‰ˆˆSØ×!Ò!ÝŒIŒNÔ-Ô5¸°~ñ
ô 
ˆð ˆ?Ø ×/Ò/Ñ1Ô1ˆDŒI�c‰NØˆr9   ÚproducerÚkeypathútuple[object, ...]Úlower_symintú$Callable[[torch.SymInt], Node | int]c                óö  — ddl }ddlm}m}m}m} |}	d}
|
t          |¦  «        k     �rP||
         }|
dz   t          |¦  «        k     r||
dz            nd}t          ||¦  «        r‰t          |t          j	        ¦  «        ro|j
        }|j        dk    r|                      |	|¦  «        }	n?|j        dk    r|                      |	|¦  «        }	n|                      |j        |	|f¦  «        }	|
dz  }
�nxt          ||¦  «        rD|j        dk    r|                      |	¦  «        }	n|                      |j        |	f¦  «        }	|
dz  }
�n$t          |t          j	        ¦  «        r(|                      |j        |	|j
        f¦  «        }	|
dz  }
nât          ||¦  «        r)|                      t$          j        |	ddf¦  «        }	|
dz  }
n©t          ||¦  «        rO|j        }t          |t$          j        ¦  «        r ||¦  «        }|                      |j        |	|f¦  «        }	|
dz  }
nJt          ||¦  «        r(|                      t.          |	|j        f¦  «        }	|
dz  }
nt3          d	|› �¦  «        ‚|
t          |¦  «        k     �°P|	S )
a  Walk an ``unbacked_bindings`` keypath, emitting FX ops on this
        graph to recover the bound SymInt from ``producer``'s result.

        ``lower_symint`` is invoked for the only keypath component that may
        carry a non-literal value: ``DivideByKey`` with a SymInt divisor.
        Callers must provide one (e.g. a wrapper around their sympy interp
        cache).
        r   N)ÚCallMethodKeyÚConvertIntKeyÚDivideByKeyÚInnerTensorKeyr   r~  rË  rr   r  zunrecognized keypath component )ÚoperatorÚ%torch.fx.experimental.symbolic_shapesr  r  r  r  rØ   r  rM   ÚSequenceKeyrÛ   r@   rý  r   r'   r  r&   ÚgetitemrJ   Úsym_iteÚdivisorrÀ  Úfloordivr\   Ú
inner_namerx   )rk   r  r  r	  r  r  r  r  r  r¥  r  r=   ÚnxtrÛ   r  s                  r:   Ú_resolve_unbacked_bindingzGraph._resolve_unbacked_binding¨  sÖ  € ð 	ˆˆˆð	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð ˆØˆØ•#�g‘,”,ÒÑØ˜”
ˆAØ$%¨¡E­C°©L¬LÒ$8Ð$8�'˜!˜a™%”.�.¸dˆCÝ˜!˜]Ñ+Ô+ð Lµ
¸3ÅÔ@RÑ0SÔ0Sð LØ”g�Ø”6˜VÒ#Ð#Ø×0Ò0°°sÑ;Ô;�D�DØ”V˜xÒ'Ð'Ø×2Ò2°4¸Ñ=Ô=�D�Dà×+Ò+¨A¬F°T¸3°KÑ@Ô@�DØ�Q‘�‘Ý˜A˜}Ñ-Ô-ð LØ”6Ð-Ò-Ð-Ø×:Ò:¸4Ñ@Ô@�D�Dà×+Ò+¨A¬F°T°GÑ<Ô<�DØ�Q‘�‘Ý˜A�vÔ1Ñ2Ô2ð LØ×)Ò)¨(Ô*:¸TÀ1Ä5¸MÑJÔJ�Ø�Q‘��Ý˜A˜}Ñ-Ô-ð LØ×)Ò)­%¬-¸$ÀÀ1¸ÑFÔF�Ø�Q‘��Ý˜A˜{Ñ+Ô+ð 
LØœ)�Ý˜g¥u¤|Ñ4Ô4ð 4Ø*˜l¨7Ñ3Ô3�GØ×)Ò)¨(Ô*;¸dÀG¸_ÑMÔM�Ø�Q‘��Ý˜A˜~Ñ.Ô.ð LØ×)Ò)­'°D¸!¼,Ð3GÑHÔH�Ø�Q‘��å$Ð%JÀqÐ%JÐ%JÑKÔKÐKðE •#�g‘,”,ÒÑðF ˆr9   ÚvaluesúSequence[torch.SymInt | int]úlist[Node | int]c                ó’  ‡ ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ — ddl ŠddlŠddlmŠmŠ ddlmŠ d'd	„Šd(d„Št          j        j	         
                    ‰ ¦  «        Š i Ši Ši Šd)ˆˆfd„}‰ j        D �]9}|j        dk    rÐ ‰|¦  «        }t          |t          ¦  «        rJ|j        j        }t          |‰j        ¦  «        r(|‰vr$t          j                             |‰ ¬¦  «        ‰|<   Œxt          |t          j        ¦  «        rKt)          |j        ¦  «        D ]6\  }}t          |t          j        ¦  «        r ||j        j        ||¦  «         Œ7ŒÞ|j                             d¦  «        }|r?|                     ¦   «         D ]*\  }	}
‰                     |	|t7          |
¦  «        f¦  «         Œ+�Œ;ddlmŠ ddlmŠm Š d*ˆfd„Šd+ˆˆˆˆˆˆˆˆˆf	d„Šd,ˆfd„Šd-ˆˆˆˆˆˆˆˆˆ ˆˆˆ fd!„Šg }|D �]c}t          |t          j        ¦  «        rnSt          |tB          ¦  «        r| "                    |¦  «         ŒItG          d"tI          |¦  «        j%        › d#|›d$�¦  «        ‚|j        j        }|j&        r#| "                    tC          |¦  «        ¦  «         Œ§|j'        D ]}	 ‰|	¦  «         Œ ‰|¦  «        }t          |t          j        j        ¦  «        sUt          |tB          tP          f¦  «        stS          d%|›d&|›�¦  «        ‚| "                    tC          |¦  «        ¦  «         �Œ;|j        } ‰||¦  «         | "                    |¦  «         �Œe|S ).ay	  Materialize a list of ``SymInt``/``int`` values as FX subgraphs rooted
        at existing nodes in this graph whose meta produces the referenced
        symbols (typically SymInt placeholders or other sym ops).

        consider a graph with a tensor placeholder
        ``%x`` of shape ``(s32, s32)`` and we want to record this stride
        as an FX value to pass to a later op, two ways to do it.

        * ``g.create_stride_node(%x, 0)`` emits ``%t = aten.sym_stride.int(%x, 0)``.
          The semantics of this op are "ask ``%x`` for its current stride at
          dim 0". If a later pass (e.g. mkldnn channels-last conversion) mutates
          ``%x``'s layout, re-running ``FakeTensorProp`` will overwrite
          ``%t.meta["val"]`` with the NEW stride. This is the right behavior
          when you want a *live* query on the producer.

        * ``g.materialize_symints([%x.meta["val"].stride(0)])`` walks the sympy
          expression ``s32`` and emits an FX subgraph that recomputes it from
          the existing producer of ``s32`` (here the placeholder ``%x`` itself
          via ``aten.sym_size.int(%x, 0)``, or a SymInt placeholder if one
          exists). The resulting node's value is "what ``s32`` is at runtime"
          -- which is determined by the input's shape and is INDEPENDENT of any
          layout change to ``%x``. This is the right behavior when you want to
          *freeze* the trace-time stride into the graph.

        Note: like other ``Graph`` node-creation APIs (``call_function``,
        ``create_size_node``, etc.), nodes are emitted at the graph's current
        insertion point. The default insertion point (``Graph._root.prepend``)
        appends new nodes to the end of the graph, which on a graph that
        already has an ``output`` node means they land *after* ``return``
        (orphaned). Callers typically scope this in
        ``with graph.inserting_before(graph.output_node()):`` so the new
        nodes land in the body.

        Performance: each call performs an O(graph_size) producer-discovery
        scan and builds a per-call ``expr_to_proxy`` hash-cons cache. Prefer
        batching every SymInt you need to lift into a single call (or as few
        calls as possible) over calling it once per value -- this amortises
        the graph scan and lets symints with shared sub-expressions get
        hash-consed into a single subgraph.
        r   N)Ú_run_sympy_handlerÚsympy_interp)ÚPythonReferenceAnalysisr‰  r   rA   r   c                ór   — | j                              d¦  «        }|�|S | j                              d¦  «        S )NrÆ  rÈ  )r«  rz   ©r‰  rÆ  s     r:   Ú	_node_valz,Graph.materialize_symints.<locals>._node_val$  s3   € Ø”&—*’*˜UÑ#Ô#ˆCØˆØ�
Ø”6—:’:˜oÑ.Ô.Ð.r9   rÆ  rB   c                ón   — || j         d<   t          d„ | j        D ¦   «         ¦  «        r|| j         d<   dS dS )zÄSet ``n.meta['val']`` and, if any of ``n``'s input nodes carry
            ``"example_value"``, mirror it there too so the new node matches
            the surrounding graph's meta-key convention.rÆ  c              3  óR   K  — | ]"}t          |t          ¦  «        od |j        v V — Œ#dS )rÈ  N)r  r   r«  rh  s     r:   rð   zCGraph.materialize_symints.<locals>._set_node_val.<locals>.<genexpr>/  s8   è è € ÐUÐUÈ•:˜a¥Ñ&Ô&ÐD¨?¸a¼fÐ+DÐUÐUÐUÐUÐUÐUr9   rÈ  N)r«  Úanyrê   r"  s     r:   Ú_set_node_valz0Graph.materialize_symints.<locals>._set_node_val*  sL   € ð  ˆAŒF�5‰MÝÐUÐUÈaÌfÐUÑUÔUÑUÔUð .Ø*-�”�Ñ'Ð'Ð'ð.ð .r9   Úexprú
sympy.Exprr¥  rl  r{   c                ó  •— t          | ‰j        ¦  «        r‰                     | ||df¦  «         dS t          | ‰j        ¦  «        rµt	          | j        ¦  «        dk    rŸ| j        \  }}t          |‰j        ¦  «        rt          |‰j        ¦  «        r||}}t          |‰j        ¦  «        rTt          |‰j        ¦  «        rAt          |¦  «        dk    r0‰                     |||t          |¦  «        f¦  «         dS dS dS dS dS dS )aC  Register ``(node, dim)`` as a recoverable source for ``expr``.

            - bare ``Symbol``: divisor = 1.
            - ``Symbol * c`` (positive integer constant): divisor = c.
              Recovery is ``sym_size.int(ph, dim) // c``.
            - anything else: skipped (general inverse needs sympy.solve).
            r   Nrr   r   )r  ÚSymbolr�   ÚMulrØ   rê   ÚIntegerr{   )r(  r¥  rl  rs  ÚbÚsym_size_sourcesÚsympys        €€r:   Ú_record_shape_sourcez7Graph.materialize_symints.<locals>._record_shape_sourceF  s1  ø€ õ ˜$ ¤Ñ-Ô-ð Ø ×+Ò+¨D°4¸¸a°.ÑAÔAÐAØ�Ý˜$ ¤	Ñ*Ô*ð 	H­s°4´9©~¬~ÀÒ/BÐ/BØ”y‘��1Ý˜a ¤Ñ.Ô.ð  µ:¸aÀÄÑ3OÔ3Oð  Ø˜a�q�Aå˜q %¤,Ñ/Ô/ðHå" 1 e¤mÑ4Ô4ðHõ ˜A™œ š
˜
à$×/Ò/°°D¸#½sÀ1¹v¼vÐ3FÑGÔGÐGÐGÐGð	Hð 	HÐ/BÐ/BðHð Hð Hð Hð #˜
r9   r*   ©ÚtracerÚunbacked_bindings)ÚBooleanAtom)r  Úfree_unbacked_symbolsrs  c                ó\   •— t          | t          j        j        ¦  «        r ‰| ¦  «        S | S rD   )r  rJ   r  r   )rs  r#  s    €r:   Ú_arg_meta_valz0Graph.materialize_symints.<locals>._arg_meta_valt  s,   ø€ Ý˜!�UœXœ]Ñ+Ô+ð $Ø �y ‘|”|Ð#ØˆHr9   c                óx  •	— | ‰v r‰|          S t          | ‰j        ‰j        ‰j        ‰f¦  «        r ‰‰‰| ¦  «        S  ‰
‰ˆfd„| j        D ¦   «         | ¦  «        }t          |t
          j        j        ¦  «        s|S |‰| <   |j        }|j	        }t          |¦  «        s|S 	 t          ˆ	fd„|j        D ¦   «         ¦  «        }ˆ	fd„|j                             ¦   «         D ¦   «         } ‰| ||i |¤Ž¦  «         n@# t          t          t           f$ r&}t"                               d| |¦  «         Y d }~nd }~ww xY w|S )Nc                ó&   •— g | ]} ‰|¦  «        ‘ŒS r8   r8   )r<   rï   Ú_sympy_interp_cacheds     €r:   r  zKGraph.materialize_symints.<locals>._sympy_interp_cached.<locals>.<listcomp>…  s%   ø€ Ð@Ð@Ð@¨sÐ%Ð% cÑ*Ô*Ð@Ð@Ð@r9   c              3  ó.   •K  — | ]} ‰|¦  «        V — Œd S rD   r8   )r<   rs  r8  s     €r:   rð   zJGraph.materialize_symints.<locals>._sympy_interp_cached.<locals>.<genexpr>�  s-   øè è € Ð!FÐ!F°q - -°Ñ"2Ô"2Ð!FÐ!FÐ!FÐ!FÐ!FÐ!Fr9   c                ó.   •— i | ]\  }}| ‰|¦  «        “ŒS r8   r8   )r<   r=   r#  r8  s      €r:   r>   zKGraph.materialize_symints.<locals>._sympy_interp_cached.<locals>.<dictcomp>‘  s)   ø€ ÐSÐSÐS±t°q¸!˜q - -°Ñ"2Ô"2ÐSÐSÐSr9   z8materialize_symints: skipping meta annotation for %s: %s)r  r-  ÚNumberr+  rê   rJ   r  ÚProxyr¥  rŽ   ræ  r  r  r  ri  Ú
ValueErrorrç  ÚlogÚdebug)r(  Úresultr¥  rŽ   Ú	fake_argsÚfake_kwargsr–   r5  r   r8  r  r'  r;  Úexpr_to_proxyr0  r  s          €€€€€€€€€r:   r;  z7Graph.materialize_symints.<locals>._sympy_interp_cachedy  s«  ø€ à�}Ð$Ð$Ø$ TÔ*Ð*ÝØ�u”} e¤l°E´LÀ+ÐNñô ð Rð $�|Ð$;¸]ÈDÑQÔQÐQà'Ð'Ø'Ø@Ð@Ð@Ð@°d´iÐ@Ñ@Ô@Øñô ˆFõ
 ˜f¥e¤h¤nÑ5Ô5ð Ø�Ø"(ˆM˜$ÑØ”;ˆDØ”[ˆFÝ˜FÑ#Ô#ð Ø�ð	Ý!Ð!FÐ!FÐ!FÐ!F¸D¼IÐ!FÑ!FÔ!FÑFÔF�	ØSÐSÐSÐS¸t¼{×?PÒ?PÑ?RÔ?RÐSÑSÔS�Ø�˜d F F¨IÐ$E¸Ð$EÐ$EÑFÔFÐFÐFøÝ�z­>Ð:ð ð ð Ý—	’	ØNØØñô ð ð ð ð ð ð øøøøðøøøð ˆMs   Â"AC: Ã:D7ÄD2Ä2D7Údútorch.SymIntú
Node | intc                ó~   •—  ‰| j         j        ¦  «        }t          |t          j        j        ¦  «        r|j         n|S rD   )r¥  r(  r  rJ   r  r?  )rG  r•   r;  s     €r:   Ú_lower_symint_divisorz8Graph.materialize_symints.<locals>._lower_symint_divisor›  s6   ø€ Ø$Ð$ Q¤V¤[Ñ1Ô1ˆAÝ'¨­5¬8¬>Ñ:Ô:ÐA�1”6�6ÀÐAr9   Úsymúsympy.Symbolc                óú  •— | ‰v rd S | ‰v �r‰|          \  }}}‰                      t          j        j        j        j        ||f¦  «        } ‰|¦  «        }t          |t          j        ¦  «        r ‰||j        |         ¦  «         |dk    rv‰                      ‰j	        ||f¦  «        }t          |t          j        ¦  «        r ‰||j        |         |z  ¦  «         t          j
                             |‰¬¦  «        ‰| <   n$t          j
                             |‰¬¦  «        ‰| <   d S | ‰v r¿ ‰| ¦  «        st          d| › d�¦  «        ‚‰|          \  }}|D ]U}	t          |	‰¦  «        rCt          |	j        t          j        ¦  «        r$|	j        j        j        j        D ]}
 ‰|
¦  «         ŒŒV‰                     ||‰¬¦  «        }t          j
                             |‰¬¦  «        ‰| <   d S t          d| › �¦  «        ‚)Nr   r2  z#materialize_symints: backed symbol zV has no input producer (backed symbols cannot be recovered from non-placeholder nodes))r	  z%materialize_symints: no producer for )r&   rJ   rù  rú  rû  r{   r  r}  r»  r  r  r?  rx   r  rÀ  r¥  r(  Úfree_symbolsr  )rL  Úphrl  r  Úsym_nodeÚtensorÚdiv_nodeÚproducer_noder  r=   Ús2r  r  Ú_ensure_producedrK  r#  r'  rF  r6  r  rk   r/  Úsym_to_bindingr3  s               €€€€€€€€€€€€r:   rV  z3Graph.materialize_symints.<locals>._ensure_produced©  sN  ø€ Ø�mÐ#Ð#Ø�ØÐ&Ð&Ñ&Ø#3°CÔ#8Ñ ��C˜Ø×-Ò-­e¬i¬nÔ.EÔ.IÈBÐPSÈ9ÑUÔU�Ø"˜ 2™œ�Ý˜f¥e¤lÑ3Ô3ð ?Ø!�M (¨F¬L¸Ô,=Ñ>Ô>Ð>Ø˜a’<�<ð  $×1Ò1Ø Ô)¨H°gÐ+>ñ ô  �Hõ " &­%¬,Ñ7Ô7ð NØ%˜ h°´¸SÔ0AÀWÑ0LÑMÔMÐMÝ).¬¯ª¸È¨Ñ)PÔ)P�M #Ñ&Ð&å).¬¯ª¸È¨Ñ)PÔ)P�M #Ñ&Ø�Ø�nÐ$Ð$Ø,Ð,¨SÑ1Ô1ð Ý(ð7¸cð 7ð 7ð 7ñô ð ð
 *8¸Ô)<Ñ&�˜wØ ð 1ð 1�AÝ! ! [Ñ1Ô1ð 1µjØœ	¥5¤<ñ7ô 7ð 1ð #$¤)¤.Ô"5Ô"Bð 1ð 1˜BØ,Ð,¨RÑ0Ô0Ð0Ð0øØ×9Ò9Ø! 7Ð9Nð :ñ ô �õ &+¤X§^¢^°HÀV ^Ñ%LÔ%L�˜cÑ"Ø�Ý Ð!NÈÐ!NÐ!NÑOÔOÐOr9   z1materialize_symints: expected SymInt or int, got z (r  z&materialize_symints: non-Proxy result z for non-constant target )r‰  r   rA   r   )r‰  r   rÆ  r   rA   rB   )r(  r)  r¥  r   rl  r{   rA   rB   )rs  r   rA   r   )r(  r)  rA   r   )rG  rH  rA   rI  )rL  rM  rA   rB   )*r  r0  Útorch.utils._sympy.interpr  r  Útorch.utils._sympy.referencer   rJ   r  ÚproxyÚGraphAppendingTracerrH  rž  r  r   r¥  r(  r+  r?  r}  r  r»  rÀ  r«  rz   r  r�   r  Úsympy.logic.boolalgr5  r  r  r6  r{   r–  ri  r¢   r3   Ú	is_numberrO  rO   rx   )!rk   r  r1  r¥  rÆ  r(  rl  rV   rJ  rL  r  r-  Útarget_exprrC  Úout_noder5  r  r   r8  rV  rK  r#  r  r'  r;  rF  r6  r  r/  rW  r0  r  r3  s!   `              @@@@@@@@@@@@@@@@@@r:   Úmaterialize_symintszGraph.materialize_symintsç  sî  øøøøøøøøøøøøøøøøøøø€ ð\ 	ˆˆˆàˆˆˆàNÐNÐNÐNÐNÐNÐNÐNØHÐHÐHÐHÐHÐHð	/ð 	/ð 	/ð 	/ð	.ð 	.ð 	.ð 	.õ ””×4Ò4°TÑ:Ô:ˆØ:<ˆð GIÐØNPˆð	Hð 	Hð 	Hð 	Hð 	Hð 	Hð 	Hð, ”Jð 	Oñ 	OˆDØŒw˜-Ò'Ð'Ø�i ‘o”o�Ý˜c¥<Ñ0Ô0ð IØœ8œ=�DÝ! $¨¬Ñ5Ô5ð R¸$ÀmÐ:SÐ:SÝ.3¬h¯nªn¸TÈ&¨nÑ.QÔ.Q˜ dÑ+øÝ ¥U¤\Ñ2Ô2ð IÝ"+¨C¬IÑ"6Ô"6ð Ið I™˜˜QÝ% a­¬Ñ6Ô6ð IØ0Ð0°´´¸dÀCÑHÔHÐHøøàœ9Ÿ=š=Ð)<Ñ=Ô=�Øð OØ(0¯ªÑ(8Ô(8ð Oð O™˜˜WØ&×1Ò1°#¸½eÀG¹n¼nÐ7MÑNÔNÐNÐNùà3Ð3Ð3Ð3Ð3Ð3ð	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð
	ð 	ð 	ð 	ð 	ð 	ð
 	ð  	ð  	ð  	ð  	ð  	ð  	ð  	ð  	ð  	ð  	ð  	ð  	ð  	ðD	Bð 	Bð 	Bð 	Bð 	Bð 	Bð)	Pð )	Pð )	Pð )	Pð )	Pð )	Pð )	Pð )	Pð )	Pð )	Pð )	Pð )	Pð )	Pð )	Pð )	Pð )	Pð )	PðV !#ˆØð 	!ñ 	!ˆAÝ˜!�Uœ\Ñ*Ô*ð 	ØÝ˜A�sÑ#Ô#ð Ø—
’
˜1‘”�Øåð2Ý˜A‘w”wÔ'ð2ð 2Ø+,ð2ð 2ð 2ñô ð ð œ&œ+ˆKØÔ$ð Ø—
’
�3˜q™6œ6Ñ"Ô"Ð"ØØ"Ô/ð &ð &�Ø Ð  Ñ%Ô%Ð%Ð%Ø)Ð)¨+Ñ6Ô6ˆFÝ˜f¥e¤h¤nÑ5Ô5ð 	õ " &­3µ¨+Ñ6Ô6ð Ý(ð?Àð ?ð ?Ø/:ð?ð ?ñô ð ð —
’
�3˜v™;œ;Ñ'Ô'Ð'ÙØ”{ˆHØˆM˜( AÑ&Ô&Ð&Ø�JŠJ�xÑ Ô Ð Ñ Øˆ
r9   r¤   útorch.SymInt | intrI  c                ó:   — |                       |g¦  «        d         S )zDSingle-value convenience wrapper around :meth:`materialize_symints`.r   )r`  )rk   r¤   s     r:   Úmaterialize_symintzGraph.materialize_symintö  s   € ð ×'Ò'¨¨Ñ0Ô0°Ô3Ð3r9   c                ó   — | S rD   r8   rT   s    r:   rã   zGraph.<lambda>ý  s   € ÐPQ€ r9   r¥  Úarg_transformúCallable[[Node], Argument]c                óÂ  — t          |j        |¦  «        }t          |j        |¦  «        }t          |t          ¦  «        st          dt          |¦  «        › �¦  «        ‚t          |t          ¦  «        st          dt          |¦  «        › �¦  «        ‚|                      |j	        |j
        |||j        |j        ¦  «        }t          j        |j        ¦  «        |_        |S )aw  
        Copy a node from one graph into another. ``arg_transform`` needs to transform arguments from
        the graph of node to the graph of self. Example::

            # Copying all the nodes in `g` into `new_graph`
            g: torch.fx.Graph = ...
            new_graph = torch.fx.graph()
            value_remap = {}
            for node in g.nodes:
                value_remap[node] = new_graph.node_copy(node, lambda n: value_remap[n])

        Args:

            node (Node): The node to copy into ``self``.

            arg_transform (Callable[[Node], Argument]): A function that transforms
                ``Node`` arguments in node's ``args`` and ``kwargs`` into the
                equivalent argument in ``self``. In the simplest case, this should
                retrieve a value out of a table mapping Nodes in the original
                graph to ``self``.
        zExpected args to be tuple, got z Expected kwargs to be dict, got )r§  rê   r  r  r  rx   r¢   rC  rÇ  rž  rŽ   r@   r°  r«  )rk   r¥  re  rê   r  Úresult_nodes         r:   r¨  zGraph.node_copyû  sÌ   € õ2 �t”y -Ñ0Ô0ˆÝ˜œ mÑ4Ô4ˆÝ˜$¥Ñ&Ô&ð 	QÝ Ð!OÅ4ÈÁ:Ä:Ð!OÐ!OÑPÔPÐPÝ˜&¥$Ñ'Ô'ð 	TÝ Ð!RÅDÈÁLÄLÐ!RÐ!RÑSÔSÐSØ×&Ò&ØŒG�T”[ $¨°´	¸4¼9ñ
ô 
ˆõ  œ9 T¤YÑ/Ô/ˆÔØÐr9   rC  r   c                ó6   — |                       dd|f|¬¦  «        S )a5  
        Insert an ``output`` ``Node`` into the ``Graph``. An ``output`` node represents
        a ``return`` statement in Python code. ``result`` is the value that should
        be returned.

        Args:

            result (Argument): The value to be returned.

            type_expr (Optional[Any]): an optional type annotation representing the
                Python type the output of this node will have.

        .. note::

            The same insertion point and type expression rules apply for this method
            as ``Graph.create_node``.
        r+   )rž  rŽ   rê   r¯  rñ  )rk   rC  r¯  s      r:   r+   zGraph.output 	  s,   € ð, ×ÒØ °¨yÀIð  ñ 
ô 
ð 	
r9   c                óð   — t          |¦  «        r|j        }nOt          |t          ¦  «        st	          dt          |¦  «        › �¦  «        ‚|}t          |¦  «        r
|dd…         }t          |¦  «        }|S )NzExpected target to be str, got rr   éþÿÿÿ)ræ  r3   r  r.   rx   r¢   rU   rZ   )rk   rŽ   rž  s      r:   rÅ  zGraph._target_to_str:	  s{   € Ý�FÑÔð 	Ø”ˆBˆBå˜f¥cÑ*Ô*ð WÝ$Ð%UÅtÈFÁ|Ä|Ð%UÐ%UÑVÔVÐVØˆBÝ˜‰}Œ}ð Ø˜˜"˜”X�Ý˜‰_Œ_ˆØˆ	r9   rA  rI  rB  rC  rD  rE  r*  rF  rG  rK  r!   c               óÚ   ‡
‡— t          ¦   «         Š
dˆ
fd„Št          dˆfd	„¦   «         }	 |	| ¦  «        5  |                      |‰
|||||||¬
¦	  «	        cddd¦  «         S # 1 swxY w Y   dS )aÑ  
        Turn this ``Graph`` into valid Python code.

        Args:

            root_module (str): The name of the root module on which to look-up
                qualified name targets. This is usually 'self'.

        Returns:

            A PythonCode object, consisting of two fields:
                src: the Python source code representing the object
                globals: a dictionary of global names in `src` -> the objects that they reference.
        r‰  r   rA   r.   c                ó:   •— ‰                      | j        | ¦  «        S rD   )r   r@   )r‰  rJ  s    €r:   Ú	node_reprz$Graph.python_code.<locals>.node_repr|	  s   ø€ Ø×(Ò(¨¬°Ñ3Ô3Ð3r9   rš   r#   úGenerator[None, None, None]c              3  ó¶   •K  — i }| j         D ]}|j        ||<   ‰|_        Œ	 d V — | j         D ]}||         |_        Œd S # | j         D ]}||         |_        Œw xY wrD   )rH  Ú_repr_fn)rš   Úorig_repr_fnsr¥  rn  s      €r:   Úoverride_node_reprz-Graph.python_code.<locals>.override_node_repr	  s’   øè è € àˆMØœð *ð *�Ø&*¤m�˜dÑ#Ø )�”�ð8Ø�
�
�
ð "œKð 8ð 8�DØ$1°$Ô$7�D”M�Mð8ð 8ø˜EœKð 8ð 8�DØ$1°$Ô$7�D”M�Mð8øøøs	   ¢? ¿ArA  N)r‰  r   rA   r.   )rš   r#   rA   ro  )rd   r
   Ú_python_code)rk   rI  rB  rC  rD  rE  r*  rF  rG  rs  rJ  rn  s             @@r:   Úpython_codezGraph.python_codeF	  s  øø€ õ^ ‘L”Lˆ	ð	4ð 	4ð 	4ð 	4ð 	4ð 	4õ 
ð
	8ð 
	8ð 
	8ð 
	8ð 
	8ñ 
Œð
	8ð  Ð Ñ%Ô%ð 	ð 	Ø×$Ò$ØØØØ-Ø-ØØ)Ø'Ø /ð %ñ 
ô 
ð	ð 	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð 	ð 	s   µA Á A$Á'A$rJ  rd   c               óT   — | j                              | j        |||||||||	¬¦
  «
        S )NrA  )rŽ  r  rH  )
rk   rI  rJ  rB  rC  rD  rE  r*  rF  rG  s
             r:   rt  zGraph._python_code™	  sC   € ð Œ}×-Ò-ØŒJØØØØ)Ø)ØØ%Ø#Ø+ð .ñ 
ô 
ð 	
r9   c                óž   ‡— g Šdg}ˆfd„| j         D ¦   «         }d                     ‰¦  «        }d|› d|d         › d�}|D ]}|r|d|z   z  }Œ|S )	zl
        Return a human-readable (not machine-readable) string representation
        of this Graph
        rì   c                ó:   •— g | ]}|                      ‰¦  «        ‘ŒS r8   )Úformat_node)r<   r¥  Úplaceholder_namess     €r:   r  z!Graph.__str__.<locals>.<listcomp>½	  s(   ø€ ÐPÐPÐP¸T�T×%Ò%Ð&7Ñ8Ô8ÐPÐPÐPr9   r/  zgraph(r  r   rÉ   r   )rH  rò   )rk   Úmaybe_return_typenameÚ	node_strsÚ	param_strrV   Únode_strrz  s         @r:   Ú__str__zGraph.__str__³	  sŒ   ø€ ð
 (*Ðð -/¨4ÐàPÐPÐPÐPÀTÄZÐPÑPÔPˆ	Ø—I’IÐ/Ñ0Ô0ˆ	Ø<�YÐ<Ð<Ð!6°qÔ!9Ð<Ð<Ð<ˆØ!ð 	)ð 	)ˆHØð )Ø�X Ñ(Ñ(�øØˆr9   c                ó¬   — 	 ddl m } n# t          $ r t          d¦  «         ‚ w xY wd„ | j        D ¦   «         }t           ||g d¢¬¦  «        ¦  «         dS )z­
        Prints the intermediate representation of the graph in tabular
        format. Note that this API requires the ``tabulate`` module to be
        installed.
        r   )ÚtabulatezŽ`print_tabular` relies on the library `tabulate`, which could not be found on this machine. Run `pip install tabulate` to install the library.c                óN   — g | ]"}|j         |j        |j        |j        |j        g‘Œ#S r8   )rž  r@   rŽ   rê   r  rœ  s     r:   r  z'Graph.print_tabular.<locals>.<listcomp>Ö	  s-   € ÐUÐUÐUÀQ�q”t˜QœV Q¤X¨q¬v°q´xÐ@ÐUÐUÐUr9   )Úopcoder@   rŽ   rê   r  )ÚheadersN)r�  ÚImportErrorÚprintrH  )rk   r�  Ú
node_specss      r:   Úprint_tabularzGraph.print_tabularÅ	  s    € ð	Ø)Ð)Ð)Ð)Ð)Ð)Ð)øÝð 	ð 	ð 	Ýð<ñô ð ð
 ð	øøøð VÐUÈ$Ì*ÐUÑUÔUˆ
ÝØˆH�ZÐ)WÐ)WÐ)WÐXÑXÔXñ	
ô 	
ð 	
ð 	
ð 	
s   ‚	 ‰$c                ó   ‡ ‡— ddˆˆ fd„}t          ¦   «         }t          ¦   «         Š‰ j        D ]É}|j        t          vrt	          d	|› d
|j        › d�¦  «        ‚|j        ‰ urt	          d|› d�¦  «        ‚|‰ j        vrt	          d|› d�¦  «        ‚|j        D ]} |||¦  «         Œ‰                     |¦  «         |j	        |v rt	          d|j	        › d�¦  «        ‚|                     |j	        ¦  «         ŒÊ‰ j
        �rŒ‰ j        D �]…}|j        dk    rJt          |j        ¦  «        s5t          d	|› d|j        › dt          j        |j        ¦  «        › d�¦  «        ‚nOt!          |j        t"          ¦  «        s5t          d	|› d|j        › dt          j        |j        ¦  «        › d�¦  «        ‚|j        dv rÓ|j                             d¦  «        }‰ j
        }t'          |¦  «        D ]¢\  }}t)          ||d¦  «        }	d                     |d|…         ¦  «        }
|	€ t	          d	|› d|j        › d|› d|
› �¦  «        ‚|j        dk    r@t!          |	t          j        j        ¦  «        s!t	          d	|› d|j        › d|› d|
› d�	¦  «        ‚|	}Œ£�Œ…dS dS )aJ  
        Runs various checks on this Graph to make sure it is well-formed. In
        particular:
        - Checks Nodes have correct ownership (owned by this graph)
        - Checks Nodes appear in topological order
        - If this Graph has an owning GraphModule, checks that targets
        exist in that GraphModule
        Nrï   r   r‰  rØ  rA   rB   c                ó–   •— |rd|› d�nd}| j         ‰urt          d| › d|› d‰› �¦  «        ‚| ‰vrt          d| › d|› d‰› �¦  «        ‚d S )Nz
 of Node 'z' r¨  z
Argument 'r:  z«does not belong to this Graph, but was used as an argument! If you are copying nodes from another graph, make sure to use ``arg_transform`` on node_copy() to remap values
zdwas used before it has been defined! Please check that Nodes in the graph are topologically ordered
)rš   rÑ  )rï   r‰  Úcontext_strÚseen_valuesrk   s      €€r:   Ú	check_argzGraph.lint.<locals>.check_argç	  sÆ   ø€ Ø01Ð:Ð, qÐ,Ð,Ð,Ð,°sˆKØŒy Ð$Ð$Ý"ð\ ð \ð \ {ð \ð \àUYð\ð \ñô ð ð
 ˜+Ð%Ð%Ý"ðg ð gð g {ð gð gØ`dðgð gñô ð ð &Ð%r9   zNode z had unknown opcode rÌ  zNode 'z ' does not belong to this Graph!z ' is not added to the side tablezNode redefined name r&   z target z
 has type z but a Callable is expectedz but a str is expected)r(   r)   r�   z" references nonexistent attribute z of r)   r¨  z  does not reference an nn.ModulerD   )rï   r   r‰  rØ  rA   rB   )rg   rH  rž  Ú
_legal_opsrÑ  rš   r�  r  r|   r@   r‚  ræ  rŽ   r@  rJ   rf  r  r.   r’   r  r\   rò   r^   rè  )rk   r�  Ú
seen_namesr¥  rï   Útarget_atomsÚm_itrr  ÚatomÚ	new_m_itrÚseen_qualnamerŒ  s   `          @r:   Úlintz
Graph.lintÛ	  sœ  øø€ ð	ð 	ð 	ð 	ð 	ð 	ð 	ð 	õ  #™uœuˆ
Ý!$¡¤ˆØ”Jð 	&ð 	&ˆDØŒw�jÐ(Ð(Ý"Ð#O¨4Ð#OÐ#OÀTÄWÐ#OÐ#OÐ#OÑPÔPÐPØŒz Ð%Ð%Ý"Ð#R¨DÐ#RÐ#RÐ#RÑSÔSÐSØ˜4Ô8Ð8Ð8Ý"Ð#R¨DÐ#RÐ#RÐ#RÑSÔSÐSØÔ(ð %ð %�Ø�	˜#˜tÑ$Ô$Ð$Ð$Ø�OŠO˜DÑ!Ô!Ð!àŒy˜JÐ&Ð&Ý"Ð#F¸$¼)Ð#FÐ#FÐ#FÑGÔGÐGØ�NŠN˜4œ9Ñ%Ô%Ð%Ð%ð Ôñ "	*Øœ
ð !*ñ !*�Ø”7˜oÒ-Ð-Ý# D¤KÑ0Ô0ð Ý(ð5 Dð 5ð 5°$´+ð 5ð 5ÍÌÐX\ÔXcÑIdÔIdð 5ð 5ð 5ñô ð ðõ & d¤kµ3Ñ7Ô7ð Ý(ð0 Dð 0ð 0°$´+ð 0ð 0ÍÌÐX\ÔXcÑIdÔIdð 0ð 0ð 0ñô ð ð ”7Ð9Ð9Ð9à#'¤;×#4Ò#4°SÑ#9Ô#9�LØ Ô.�EÝ#,¨\Ñ#:Ô#:ð *ð *™˜˜4Ý$+¨E°4¸Ñ$>Ô$>˜	Ø(+¯ª°¸b¸q¸bÔ1AÑ(BÔ(B˜Ø$Ð,Ý".ð!=¨ð !=ð !=°d´kð !=ð !=Ø#'ð!=ð !=Ø-:ð!=ð !=ñ#ô #ð ð  œ7 mÒ3Ð3½JØ%¥u¤x¤ñ=ô =Ð3õ #/ð!=¨ð !=ð !=°d´kð !=ð !=ÀDð !=ð !=Èmð !=ð !=ð !=ñ#ô #ð ð
 !*˜˜ùðE"	*ð "	*ð!*ð !*r9   Úis_impure_nodeúCallable[[Node], bool] | Nonec                óT  ‡‡
— ddl m} |                      ¦   «          dŠ
t          j        j                             ¦   «         rt          j        j        j	        Š
dˆ
ˆfd„}t          ¦   «         }t          | j        ¦  «        D ]T} ||¦  «        sGt          |j        ¦  «        dk    r/|                      |¦  «         |                     |j        ¦  «         ŒUt          |¦  «        dk    }|rt$                               d	|¦  «         | j        �› |d„ |                      d¬¦  «        D ¦   «         ¦  «        }| j                             ¦   «         D ]X\  }}	||v rOt/          |	t          j        j        ¦  «        r0||	j                             ¦   «         z  }|	                     ¦   «          ŒY|S )aÒ  
        Remove all dead code from the graph, based on each node's number of
        users, and whether the nodes have any side effects. The graph must be
        topologically sorted before calling.

        Args:
            is_impure_node (Optional[Callable[[Node], bool]]): A function that returns
            whether a node is impure. If this is None, then the default behavior is to
            use Node.is_impure.

        Returns:
          bool: Whether the graph was changed as a result of the pass.

        Example:

        Before dead code is eliminated, `a` from `a = x + 1` below has no users
        and thus can be eliminated from the graph without having an effect.

        .. code-block:: python

            def forward(self, x):
                a = x + 1
                return x + self.attr_1

        After dead code is eliminated, `a = x + 1` has been removed, and the rest
        of `forward` remains.

        .. code-block:: python

            def forward(self, x):
                return x + self.attr_1

        .. warning::

            Dead code elimination has some heuristics to avoid removing
            side-effectful nodes (see Node.is_impure) but in general coverage
            is very bad, so you should assume that this method is not sound
            to call unless you know that your FX graph consists entirely
            of functional operations or you supply your own custom
            function for detecting side-effectful nodes.
        r   )Ú
OrderedSetTr¥  r   rA   rO   c                óH   •— ‰� ‰| ¦  «        S |                       ‰¦  «        S rD   )Ú	is_impure)r¥  Úimpure_randomr–  s    €€r:   Úhas_side_effectz2Graph.eliminate_dead_code.<locals>.has_side_effectb
  s+   ø€ ØÐ)Ø%�~ dÑ+Ô+Ð+Ø—>’> -Ñ0Ô0Ð0r9   z1The following nodes were dead code eliminated: %sNc              3  ó$   K  — | ]}|j         V — Œd S rD   rz  rÀ  s     r:   rð   z,Graph.eliminate_dead_code.<locals>.<genexpr>v
  s5   è è € ð (ð (Ø�”ð(ð (ð (ð (ð (ð (r9   r(   )rž  r€  )Útorch.utils._ordered_setr™  r•  rJ   Ú_guardsÚTracingContextÚtry_getÚ	_inductorÚconfigÚfallback_randomrg   r  rH  rØ   rŸ  r×  r|   r@   rA  Úinfor‚  r  Únamed_childrenr  r  r%   rš   Úeliminate_dead_codeÚ	recompile)rk   r–  r™  r�  Úremoved_nodesr¥  ÚchangedÚsubgraph_namesÚ
child_nameÚchild_modulerœ  s    `        @r:   r¨  zGraph.eliminate_dead_code+
  sÜ  øø€ ðZ 	8Ð7Ð7Ð7Ð7Ð7ð 	�	Š	‰ŒˆàˆÝŒ=Ô'×/Ò/Ñ1Ô1ð 	CÝ!œOÔ2ÔBˆMð	1ð 	1ð 	1ð 	1ð 	1ð 	1ð 	1õ ™œˆÝ˜TœZÑ(Ô(ð 	-ð 	-ˆDØ"�? 4Ñ(Ô(ð -­S°´©_¬_ÀÒ-AÐ-AØ—’ Ñ%Ô%Ð%Ø×!Ò! $¤)Ñ,Ô,Ð,øå�mÑ$Ô$ qÒ(ˆØð 	YÝ�HŠHÐHÈ-ÑXÔXÐXð ÔÐ)Ø'˜Zð (ð (Ø"&§/¢/°Z /Ñ"@Ô"@ð(ñ (ô (ñ ô ˆNð -1Ô,>×,MÒ,MÑ,OÔ,Oð -ð -Ñ(�
˜Lð  Ð/Ð/µJØ ¥%¤(Ô"6ñ5ô 5Ð/ð ˜|Ô1×EÒEÑGÔGÑG�GØ ×*Ò*Ñ,Ô,Ð,øàˆr9   Úcodegenr"   c                ó   — || _         d S rD   )rŽ  )rk   r¯  s     r:   Úset_codegenzGraph.set_codegen„
  s   € àˆŒˆˆr9   Úmake_transformerú7Callable[[TransformCodeFunc | None], TransformCodeFunc]ú'contextlib.AbstractContextManager[None]c                óŽ   ‡ ‡— ‰ j         j        Š |‰¦  «        ‰ j         _        t          j        dˆˆ fd„¦   «         } |¦   «         S )a-
  Register a transformer function when python code is generated

        Args:
            make_transformer (Callable[[Optional[TransformCodeFunc]], TransformCodeFunc]):
                a function that returns a code transformer to be registered.
                This function is called by `on_generate_code` to obtain the
                code transformer.

                This function is also given as its input the currently
                registered code transformer (or None if nothing is registered),
                in case it is not desirable to overwrite it. This is useful to
                chain code transformers together.

        Returns:
            a context manager that when used in a `with` statement, to automatically
            restore the previously registered code transformer.

        Example:

        .. code-block:: python


            gm: fx.GraphModule = ...


            # This is a code transformer we want to register. This code
            # transformer prepends a pdb import and trace statement at the very
            # beginning of the generated torch.fx code to allow for manual
            # debugging with the PDB library.
            def insert_pdb(body):
                return ["import pdb; pdb.set_trace()\n", *body]


            # Registers `insert_pdb`, and overwrites the current registered
            # code transformer (given by `_` to the lambda):
            gm.graph.on_generate_code(lambda _: insert_pdb)

            # Or alternatively, registers a code transformer which first
            # runs `body` through existing registered transformer, then
            # through `insert_pdb`:
            gm.graph.on_generate_code(
                lambda current_trans: (
                    lambda body: insert_pdb(
                        current_trans(body) if current_trans else body
                    )
                )
            )

            gm.recompile()
            gm(*inputs)  # drops into pdb


        This function can also be used as a context manager, with the benefit to
        automatically restores the previously registered code transformer:

        .. code-block:: python

            # ... continue from previous example

            with gm.graph.on_generate_code(lambda _: insert_pdb):
                # do more stuff with `gm`...
                gm.recompile()
                gm(*inputs)  # drops into pdb

            # now previous code transformer is restored (but `gm`'s code with pdb
            # remains - that means you can run `gm` with pdb here too, until you
            # run next `recompile()`).
        rA   ro  c               3  óP   •K  — 	 d V — ‰ ‰j         _        d S # ‰ ‰j         _        w xY wrD   )rŽ  rè   )Úon_gen_code_oldrk   s   €€r:   Ú on_generate_code_context_managerz@Graph.on_generate_code.<locals>.on_generate_code_context_managerÔ
  s<   øè è € ðBØ���à2A�”Ô/Ð/Ð/ø°/�”Ô/ÐAÐAÐAÐAs   … —%)rA   ro  )rŽ  rè   Ú
contextlibr
   )rk   r²  r¸  r·  s   `  @r:   Úon_generate_codezGraph.on_generate_codeˆ
  so   øø€ ðR œ-Ô9ˆØ*:Ð*:¸?Ñ*KÔ*KˆŒÔ'å	Ô	"ð	Bð 	Bð 	Bð 	Bð 	Bð 	Bñ 
#Ô	"ð	Bð 0Ð/Ñ1Ô1Ð1r9   c                ó�   — t          | j        ¦  «        D ]0}|j                             ¦   «          |                      |¦  «         Œ1d S rD   )r  rH  r«  Úclearr×  rq  s     r:   Ú_clear_nodeszGraph._clear_nodesÝ
  sL   € Ý˜TœZÑ(Ô(ð 	"ð 	"ˆDØŒI�OŠOÑÔÐØ�OŠO˜DÑ!Ô!Ð!Ð!ð	"ð 	"r9   )NNN)r‚  rƒ  r„  r…  r†  r‡  rA   rB   )rA   rƒ  )r“  rƒ  rA   rB   )rA   r«   )rA   r   )rž  r.   rŽ   r{  rš  rO   rA   r|  )F)rž  r#   rŸ  r   r¡  rO   rA   r¢  rD   )r«  r¬  rA   r#   )NNNN)rž  r.   rŽ   r   rê   r·  r  r¸  r@   r¹  r¯  rº  rA   r   r  rS  )rÊ  r   rA   rB   )r‰  rØ  rA   r™   )r@   r.   r¯  rº  rÞ  r   rA   r   )r„  r.   r¯  rº  rA   r   )
r`   r.   rê   r·  r  r¸  r¯  rº  rA   r   )
rï  r.   rê   r·  r  r¸  r¯  rº  rA   r   )rò  r  rê   r·  r  r¸  r¯  rº  r@   r¹  rA   r   )rô  r   rA   rõ  )rô  r   rl  r{   rA   r   )rô  r   rA   r   )r  r   r  r  r	  r
  rA   r   )r  r  rA   r  )r¤   ra  rA   rI  )r¥  r   re  rf  rA   r   )rC  r   r¯  rº  )rŽ   r{  rA   r.   )rI  r.   rB  rO   rC  rO   rD  rO   rE  rO   r*  rO   rF  rO   rG  rK  rA   r!   )rI  r.   rJ  rd   rB  rO   rC  rO   rD  rO   rE  rO   r*  rO   rF  rO   rG  rK  rA   r!   rË   r†   )r–  r—  rA   rO   )r¯  r"   rA   rB   )r²  r³  rA   r´  )0r3   r4   r5   r6   r   rl   Úpropertyr‚  ÚsetterrH  r™  r  rª  r¶  rÇ  r:  r=  r×  rÜ  rÚ  r%  rà  rá  r*   r(   r)   r'   r&   Ústaticmethodr÷  rý  r   r  r  r`  rc  r¨  r+   rÅ  ru  rt  r  rˆ  r•  r¨  r±  rº  r½  r8   r9   r:   r#   r#     so  € € € € € ð-ð -ð^ €]¨$Ð/Ñ/Ô/ð -1Ø*.Ø/3ð	@ð @ð @ð @ñ 0Ô/ð@ð* ð#ð #ð #ñ „Xð#ð Ôð"ð "ð "ñ Ôð"ð ð ð  ð  ñ „Xð ð €]¨%Ð0Ñ0Ô0ðð ð ñ 1Ô0ðð €]¨%Ð0Ñ0Ô0ð 37ÀTðð ð ð ð ñ 1Ô0ðð2 €]¨$Ð/Ñ/Ô/àNSðð ð ð ñ 0Ô/ðð8ð ð ð ð ð> €]¨$Ð/Ñ/Ô/ð
 -1Ø-1ØØ $ðLð Lð Lð Lñ 0Ô/ðLð\ €]¨%Ð0Ñ0Ô0ð3ð 3ð 3ñ 1Ô0ð3ð €]¨%Ð0Ñ0Ô0ð2ð 2ð 2ñ 1Ô0ð2ð €]¨$Ð/Ñ/Ô/ð&
ð &
ð &
ñ 0Ô/ð&
ðP €]¨$Ð/Ñ/Ô/ð-ð -ð -ð -ñ 0Ô/ð-ð0 €]¨$Ð/Ñ/Ô/ð,ð ,ð ,ð ,ñ 0Ô/ð,ð0 €]¨$Ð/Ñ/Ô/ð !%Ø$Ô.Ô4ð	Uð Uð Uð Uñ 0Ô/ðUð@ €]¨$Ð/Ñ/Ô/ðAQð AQð AQð AQñ 0Ô/ðAQðF €]¨$Ð/Ñ/Ô/ð -1Ø-1Ø $ð2
ð 2
ð 2
ð 2
ñ 0Ô/ð2
ðh €]¨$Ð/Ñ/Ô/ð -1Ø-1Ø $ð$
ð $
ð $
ð $
ñ 0Ô/ð$
ðL €]¨$Ð/Ñ/Ô/ð -1Ø-1Ø $Øð'
ð '
ð '
ð '
ñ 0Ô/ð'
ðR ðð ð ñ „\ðð  €]¨%Ð0Ñ0Ô0ðð ð ñ 1Ô0ðð €]¨%Ð0Ñ0Ô0ðð ð ñ 1Ô0ðð €]¨%Ð0Ñ0Ô0ðð ð ñ 1Ô0ðð €]¨%Ð0Ñ0Ô0ð<ð <ð <ñ 1Ô0ð<ð| €]¨%Ð0Ñ0Ô0ðLð Lð Lñ 1Ô0ðLð\ €]¨%Ð0Ñ0Ô0ð4ð 4ð 4ñ 1Ô0ð4ð €]¨$Ð/Ñ/Ô/àFQÀkð"ð "ð "ð "ñ 0Ô/ð"ðH €]¨$Ð/Ñ/Ô/ð 9=ð
ð 
ð 
ð 
ñ 0Ô/ð
ð0
ð 
ð 
ð 
ð €]¨$Ð/Ñ/Ô/ð
 Ø$Ø$ØØ"Ø!Ø,0ðPð Pð Pð Pð Pñ 0Ô/ðPðn Ø$Ø$ØØ"Ø!Ø,0ð
ð 
ð 
ð 
ð 
ð 
ð4ð ð ð ð$ €]¨$Ð/Ñ/Ô/ð
ð 
ð 
ñ 0Ô/ð
ð* €]¨$Ð/Ñ/Ô/ðM*ð M*ð M*ñ 0Ô/ðM*ð^ €]¨$Ð/Ñ/Ô/à>BðVð Vð Vð Vñ 0Ô/ðVðp €]¨%Ð0Ñ0Ô0ð ð  ð  ñ 1Ô0ð ð €]¨%Ð0Ñ0Ô0ðR2ð R2ð R2ñ 1Ô0ðR2ðh"ð "ð "ð "ð "ð "r9   r#   Úoverriderä   ro  c              #  ó~   K  — t           j        }	 | t           _        d V — |t           _        d S # |t           _        w xY wrD   )r"   rå   )rÁ  Útmps     r:   Ú_override_sym_reprrÄ  ã
  sH   è è € õ Ô
€Cð Ø$�ÔØˆˆˆà�ÔÐÐø˜C�ÔÐÐÐÐs   �. ®<c                ó   — | S rD   r8   rT   s    r:   r  r  ï
  s   € Ø€Hr9   rÇ   úCallable[[str], str]c                ó   ‡ — dˆ fd„}|S )NrV   r.   rA   c                ó   •— d}‰› | › |› �S )Nz[0mr8   )rV   ÚresetrÇ   s     €r:   rÆ  z_make_color_fn.<locals>.fô
  s   ø€ ØˆØÐ"˜Ð"˜5Ð"Ð"Ð"r9   ©rV   r.   rA   r.   r8   )rÇ   rÆ  s   ` r:   Ú_make_color_fnrË  ó
  s(   ø€ ð#ð #ð #ð #ð #ð #ð €Hr9   z[33mz[36mz[32mz[34mz[31mz[2mz	[2m[34mz	[2m[32m)ÚyellowÚcyanÚgreenrn  rj  rl  rm  rk  c                ó4   — i | ]\  }}|t          |¦  «        “ŒS r8   )rË  r;  s      r:   r>   r>     s&   € ÐDÐDÐD¡t q¨!ˆa• Ñ"Ô"ÐDÐDÐDr9   z# COUNTER: (\d+)z{} + {}z{} - {}z{} * {}z{} // {}z{} / {}z{} % {}z{} ** {}z{} << {}z{} >> {}z{} & {}z{} | {}z{} ^ {}z{}[{}]z{} @ {})r|   rv   Úmulr  ÚtruedivÚdivr“  ÚpowÚlshiftÚrshiftÚand_Úor_Úxorr  Úmatmulz{} == {}z{} != {}z{} < {}z{} > {}z{} <= {}z{} >= {}z+{}z-{}z~{})	ÚeqÚneÚltÚgtÚleÚgeÚposÚnegÚinvertz{} += {}z{} &= {}z	{} //= {}z	{} <<= {}z{} %= {}z{} *= {}z{} @= {}z{} |= {}z	{} **= {}z	{} >>= {}z{} -= {}z{} /= {}z{} ^= {}z{}[{}] = {})ÚiaddÚiandÚ	ifloordivÚilshiftÚimodÚimulÚimatmulÚiorÚipowÚirshiftÚisubÚitruedivÚixorÚsetitem)r@   r.   r/   r.   r1   r0   rA   rB   )rN   r.   rA   rO   rÊ  )r1   r0   rA   rO   )r}   r.   rŽ   r.   rA   r.   rD   )rÌ   r.   rÍ   rÎ   rA   rÏ   )rÁ  rä   rA   ro  )rN   r.   rA   r.   )rÇ   r.   rA   rÆ  )…Ú
__future__r   Úbuiltinsr¹  r°  rz  Ú	functoolsr%  ÚkeywordÚloggingÚmathr   rã  rÔ   r_  ra  rÃ  Úcollectionsr   Úcollections.abcr   r   r   r   r	   r
   Údataclassesr   r   r   r   r   rJ   Útorch.utils._pytreeÚutilsr   rM   Útorch._Cr   r§  r   Útorch._library.opaque_objectr   r   Útorch.typesr   Útorch.utils._dtype_abbrsr   rì   rL   Ú_compatibilityr   Úimmutable_collectionsr   r¥  r   r   r   r   r   Útensor_typer    Ú	getLoggerr3   rA  Ú__all__r0  Ú_symbolic_tracer$   Úgraph_moduler%   r7  ÚListrC  ÚDictrg   ÚSetÚ	frozensetÚ	FrozenSetr  ÚTuplerd  ÚfromkeysrŽ  r.   ÚTransformCodeFuncr-   ÚkwlistrE   ÚupdateÚ__dict__r?   r7   rF   rG   rH   r¢   rK   rU   rZ   ÚpartialrÕ   rv   rX   ru   rs   Ú	fullmatchr]   rb   rd   r!   r—   r™   r«   r½   rÄ   rÞ   r"   r  r%  rX  rk  r#   rÄ  r  rË  Ú_color_codesr  r  r	  Úreflectable_magic_methodsrç  ré  r8   r9   r:   ú<module>r     sÍ  ðØ "Ð "Ð "Ð "Ð "Ð "Ð "à €€€Ø Ð Ð Ð Ø €€€Ø €€€Ø Ð Ð Ð Ø €€€Ø €€€Ø €€€Ø €€€Ø 	€	€	€	Ø €€€Ø 	€	€	€	Ø €€€Ø €€€Ø €€€Ø #Ð #Ð #Ð #Ð #Ð #Ø MÐ MÐ MÐ MÐ MÐ MÐ MÐ MÐ MÐ MÐ MÐ MÐ MÐ MØ %Ð %Ð %Ð %Ð %Ð %Ø !Ð !Ð !Ð !Ð !Ð !Ø :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :à €€€Ø $Ð $Ð $Ð $Ð $Ð $Ð $Ð $Ð $Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø RÐ RÐ RÐ RÐ RÐ RÐ RÐ RØ $Ð $Ð $Ð $Ð $Ð $Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0à "Ð "Ð "Ð "Ð "Ð "Ø )Ð )Ð )Ð )Ð )Ð )Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IØ #Ð #Ð #Ð #Ð #Ð #ð €gÔ˜Ñ!Ô!€à
,Ð
,Ð
,€ð ð *Ø€L€L€Là'Ð'Ð'Ð'Ð'Ð'Ø)Ð)Ð)Ð)Ð)Ð)ð 	ˆ&Œ+Øˆ&Œ+ØˆŒØˆvÔØ	ˆ6Œ<ðÐ ð �]Š]ØXÐXÐXñô €
ð ˜d 3œi˜[¨$¨s¬)Ð3Ô4Ð ðð ð ð ð �Zñ ô ð ð 7Ð6 w¤~Ð6Ñ6Ô6€Ø × Ò �hÔ'Ñ (Ô (Ð (à.0Ð Ð 0Ð 0Ð 0Ñ 0ðð ð ð ð
 Ð ˜Ð 6¸¼Ñ AÔ AÐ AØ Ð ˜Ð 6¸¼Ñ AÔ AÐ AØ Ð ˜Ð%<¸d¸dÀ4¹j¼jÑ IÔ IÐ IØ Ð ˜ .°%Ñ 8Ô 8Ð 8Ø Ð ˜Ð#=¸u¼|Ñ LÔ LÐ LØ Ð ˜Ð&LÈiÑ XÔ XÐ XØ Ð ˜Ð#IÈ6Ñ RÔ RÐ Rð3ð 3ð 3ð 3ð	&ð 	&ð 	&ð 	&ð $�)Ô# J B¤JÐ/CÑ$DÔ$DÔ$HÈ&ÑQÔQ€ð !�b”jÐ!1Ñ2Ô2Ð ð ˆbŒjÐBÑCÔC€ð #˜œ
Ø3ñô äð ð
ð ð ð ðN#ð N#ð N#ð N#ð N#ñ N#ô N#ð N#ðb € dÐ+Ñ+Ô+Ø
ðð ð ð ð ñ ô ñ „ñ ,Ô+ðð ð ð ð ð.ð .ð .ð .ð .ñ .ô .ð .ð"Fð Fð Fð Fð Fñ Fô Fð Fð4%ð %ð %ð %ð %�*ñ %ô %ð %ð €�$ÐÑÔðTð Tð Tð Tð Tñ Tô Tñ ÔðTð  KOðð ð ð ð ð2 € eÐ,Ñ,Ô,ðc

ð c

ð c

ð c

ð c

ñ c

ô c

ñ -Ô,ðc

ðX'ð 'ð 'ð 'ð '�Gñ 'ô 'ð 'ðTEVð EVð EVð EVð EV�Wñ EVô EVð EVðP1Ið 1Ið 1Ið 1Ið 1I�^ñ 1Iô 1Ið 1Iðh!Rð !Rð !Rð !Rð !Rñ !Rô !Rð !RðH € dÐ+Ñ+Ô+ðA"ð A"ð A"ð A"ð A"ñ A"ô A"ñ ,Ô+ðA"ðH. ð ð  ð  ñ „ð ðð ð ð ðð ð ð ð ØØØØØØ!Ø"ð	ð 	€ð EÐD¨|×/AÒ/AÑ/CÔ/CÐDÑDÔD€
Ø�"”*Ð0Ñ1Ô1€ð ØØØØØØØØØØØØØØðð Ð ð& Ø
Ø
Ø
Ø
Ø
ØØØðð ð  ð€ð ØØØØØØØØØØØØØðð €€€r9   