L i:<UddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Z ddlmZmZddlmZddlmZddl mZmZmZmZmZmZddlZddlmcmZddlm Z!m"Z"ddl#m$Z$d d l%mZ&d d l'm(Z(d d l)m*Z*d d l+m,Z,m-Z-m.Z.m/Z/m0Z0gdZ1er d dl2m3Z3d dl4m5Z5e6e jne8e jre:e jvee j~iZ@e8jgdZBee6eCge6eCfZDGddeZEejDcic] }|eG c}ZHeHjejiZKe8eCeEfeLd<deCdeCdefdZMeMddejeMddejeMddePdeMdd eeMd!d"ejeMd#d$e&eMd%d&ed'eCd(eRfd)ZSd*eCd(eCfd+ZTeje jd,jd-ZXe jd.ZYe jd/ZZe jd0jZ\ded(eRfd1Z]Gd2d3Z^e(d45eGd6d7Z_d8eCd9eCd(eCfd:Z`Gd;d<ZaGd=d>ZbGd?d@eZced4AGdBdCZddDeCfdEZee(dF5GdGdHZfGdIdJefZgGdKdLZhe(d45GdMdNZiedOedPgeCfd(edfdQZjdRZkdSZldTdUdVdWdXdYdZd[d\ZmemjDcic]\}}|el|c}}Zoe jd]Zpd^d_d`dadbdbdcdddedfdgdhdidjdkdlZqdmdndodpdqdrdsdtdudv eqZrdwdxdydzd{d|d}d~dddddddZsycc}wcc}}w)N) defaultdict)IterableIterator)contextmanager) dataclass)AnyCallableLiteral NamedTupleOptional TYPE_CHECKING) _fx_map_arg _NodeIter) dtype_abbrs)_pytree) compatibility)immutable_dict)_get_qualified_name _type_reprArgumentNodeTarget) PythonCodeCodeGenGraph)Tracer) GraphModule) call_function call_methodget_attr call_module placeholderoutputc&eZdZUdZeed<eed<y)_CustomBuiltinzAdditional 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. import_strobjN)__name__ __module__ __qualname____doc__str__annotations__rT/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/torch/fx/graph.pyr&r&:sO Hr0r&_custom_builtinsnamer'r(c<t||t|<|t|<yN)r&r2_illegal_names)r3r'r(s r1_register_custom_builtinr7Os+J<TN4r0infzfrom math import infnanzfrom math import nanNoneTypezNoneType = type(None)torchz import torchdevicezfrom torch import device fx_pytreez$import torch.fx._pytree as fx_pytreepytreez$import torch.utils._pytree as pytreexreturncJ|jdxr|jdS)N__) startswithendswithr?s r1 _is_magicrF]s <<  2!**T"22r0sc4t|jS)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_sublower)rGs r1 _snake_caserKas 1  # # %%r0z(?<=[a-z])([A-Z])z_\1z[^0-9a-zA-Z_]+z&^([a-zA-Z_][0-9a-zA-Z_]*?)(?:_(\d+))?$z,^torch(?:\.(?!_dynamo\.|_inductor\.)[^.]+)*$ct|dd}| t|duSt|dd}|;|dk7r6ttjjfD]}t||d|usyy)Nr*r)r;TF)getattr_torch_but_not_dynamor;nn functional)r( module_namer3guesss r1_is_from_torchrSsw#|T2K$[1== 3 D )D DGOUXX001 EudD)S0  r0cPeZdZdZdZdedeedefdZdedefdZ dedefd Z y ) _NamespaceaA 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. c>i|_t|_i|_yr5) _obj_to_nameset _used_names _base_countselfs r1__init__z_Namespace.__init__s,.%(U+-r0 candidater(r@c|||jvr|j|Stj|}|Ktj d|}|sd}|dj rd|}tj|}|J|j dd\}}|||jvrA|jj|d}tj|||ur|dz }|d|}n t|}||jvr|dz }|d|}||jvr|jj|||j|<|||j|<|S)zCreate 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. __unnamedrr) rW _name_regexmatch_illegal_char_regexsubisdigitgrouprYrZgetr6intadd)r\r^r(rdbasenums r1 create_namez_Namespace.create_names| ?sd&7&77$$S) )!!), =+//Y?I& |##% {O %%i0E$ $$KK1% c ;)t'7'77""&&y!4C!!)S1<q#fAcUO c(C4+++ 1HC&#I4+++ Y'!$ ?%.D  c "r0r3cR|jj||}||usJdy)zpAssociate a unique name with an object. Neither `name` nor `obj` should be associated already. zobj is already associatedN)rW setdefault)r\r3r(maybe_existings r1associate_name_with_objz"_Namespace.associate_name_with_objs0 **55c4@%B'BB%r0cx||jvsJ||j|<|jj|yr5)rWrYrk)r\r(r3s r1_rename_objectz_Namespace._rename_objects:d'''''!%# T"r0N) r)r*r+r,r]r-r rrnrrrtr/r0r1rUrUsT. +S+x}++ZCCCcC###S#r0rUTis_backward_compatiblecPeZdZUdZeed<eeefed<eee ee fed<y)rzZ Represents all the information necessary to exec or save a graph as Python code. srcglobals _lineno_mapN) r)r*r+r,r-r.dictrr rjr/r0r1rrs7 H #s(^$sHSM1233r0rrltargetc||jd}|}|D]#}|js d|d|d}|d|}%|S)N.zgetattr(z, ""))split isidentifier)rlr|elemsres r1_format_targetrsX LL E A ~~1#S2&A#Qqc A  Hr0ceZdZdZdZdZy) _InsertPointcD||_|j|c|_|_yr5)graph_insert orig_insert)r\r new_inserts r1r]z_InsertPoint.__init__s */--'%-r0cyr5r/r[s r1 __enter__z_InsertPoint.__enter__s r0c:|j|j_yr5)rrr)r\typevaluetbs r1__exit__z_InsertPoint.__exit__s!-- r0N)r)r*r+r]rrr/r0r1rrsD .r0rc6eZdZd dddedfdZdZdZdZy ) _node_listrr direction)_prev_nextc,|dvsJ||_||_y)N)rr)rr)r\rrs r1r]z_node_list.__init__s.... "r0c.|jjSr5)r_lenr[s r1__len__z_node_list.__len__szzr0c\t|jj|jdk(S)Nr)rr_rootrr[s r1__iter__z_node_list.__iter__s"))4>>W+DEEr0cXt|j|jdk(rdSdS)Nrr)rrrr[s r1 __reversed__z_node_list.__reversed__ s'$**71JgXXPWXXr0N)r)r)r*r+r r]rrrr/r0r1rrs,#g#':J2K# FYr0rcdeZdZUdZeeed<ejed<e ejed<y) _PyTreeInfoz= Contains extra info stored when we're using Pytrees orig_argsin_specout_specN) r)r*r+r,listr-r.r>TreeSpecr r/r0r1rrs,Cy __v''r0r)frozenc@eZdZUdZeed<eed<eed<eed<dZy)_ParsedStackTracez? Represents the top-most frame of a parsed stack trace filelinenor3codecnd|jd|jd|jd|jS)NzFile: :z in z, code: )rrr3rr[s r1get_summary_strz!_ParsedStackTrace.get_summary_str$s1 {!DKK=TYYKx {SSr0N)r)r*r+r,r-r.rr/r0r1rrs# I K I ITr0r stack_tracec|ytjd}|jjd}t t |dz ddD]}||j}|j |}|s*|jd}|jd}|jd}||dzj} t|||| cSy)Nz$^File \"(.+)\", line (\d+), in (.+)$ rbr) recompilestriprrangelenrdrhr) rpatternlinesidxlinematchesrrr3rs r1_parse_stack_tracer)sjj@AG     % %d +ESZ!^R, ?Sz!--% ==#D]]1%F==#Dq>'')D$T64> > ? r0Fc<eZdZUdZedgefed<dZdeedefdZ dedefd Z de eeffd Z d%defd Z d ZdZdddeedededefdZd ddedeedefdZdedefdZdedefdZdee eeffdZdddddddeded ed!ed"ed#ededefd$Zy )&rct|Sr5)reprrEs r1zCodeGen.As DGr0torch.types.PySymType _sym_reprc d|_d|_y)Nforward)_body_transformer _func_namer[s r1r]zCodeGen.__init__Cs>B(r0argsr@c8djfd|DS)zAHelper to format function arguments in expanded multiline format.c3@K|]}j|ywr5)_format_single_arg).0argr\s r1 z1CodeGen._format_multiline_args..IsDt..s3Dsjoinr\rs` r1_format_multiline_argszCodeGen._format_multiline_argsGswwDtDDDr0rcd|vr:|jdd\}}d|jd|jdSd|dS)z9Helper to format a single argument with optional comment.#r z, # rz, )rrstriplstrip)r\rarg_part comment_parts r1rzCodeGen._format_single_argKsS #:%(YYsA%6 "Hl(//+,E,2E2E2G1HK K#c? "r0c*t|trdSdS)z.^s(.;dG$tfAgYb))r_get_desc_trailersrzip)r\itemsdescsprefixldelimrdelim desc_trailerss r1_format_multiline_containerz#CodeGen._format_multiline_containerWsn--e4//u= hvhb !gg?B5-?X    r0cT|dgt|zS|Dcgc]}d| c}Scc}w)z2Helper to generate description trailers for items.r # )r)r\rrdescs r1rzCodeGen._get_desc_trailersds2 =4#e*$ $*/0$$tf 000s %ctj|}|jDcic]\}}||jvs||}}}||i|Scc}}w)zDHelper to call a method with optional parameters based on signature.)inspect signaturer parameters)r\methodrkwargssigkvfiltered_kwargss r1!_call_method_with_signature_checkz)CodeGen._call_method_with_signature_checkjsT',2LLNRDAqa3>>>Q1a4RRt///Ss AAF expanded_def free_varsmaybe_return_annotationrct|dk(s|ddk7r|jdd|r'|j|}d|jd|d|dSd|jddj |d|dS) 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):'` rr\zdef z( rrr, )rinsertrrr)r\rrrargs_formatteds r1 gen_fn_defzCodeGen.gen_fn_defqs y>Q )A,&"8   Q ' !88CNt's>*:!.add_globalsjs#u||(; +3//$// 3?Kh& ,333""$'H[ ! r0oc|dk(ryt|}t|ddx}rt|tjrt j ||}t||}t|drF|jDcgc] }| }}t|dk(r|S|ddj|dS|S||Scc}w) Nr/z() __origin____args__rrrr) rrMrtyping _GenericAlias_origin_type_maprihasattrr-rr)r*typename origin_typeorigin_typenamerrr) type_reprs r1r5z+CodeGen._gen_python_code..type_reprsBw!!}H%at<<{<a!5!56"2"6"6{K"PK",Z -Dk"R1j)67jjAsIcNADA4yA~ /.-.a/?qAA+*h* *Bs>Cred dim_greendimdim_bluebluerr@ct|tr t|St|trJt |dr>t t |}|t |}|tt|St|tjjtjjfrt |}||}|St|tjr0|j}|j|}|d|jSt|tj rIt#|j%}t'|j(j+dd}d|d|dSt|tr=t-|dk(rd|d d Sdd j/fd |DzdzSt|t"r d d j/fd|DzdzSt|t0rCodeGen._gen_python_code.._get_repr..0s*EA9Q<*Erc3.K|] }|ywr5r/r>s r1rz>CodeGen._gen_python_code.._get_repr..2s&Ay|&ArArzslice()rrrrr1rrr;_ops OpOverloadHigherOrderOperatorenumEnum __class__r)r3Tensorrsizer-dtyperrrslicestartstopstep) rqualified_namer'clsclsnamerJrKr@r)r:s r1r@z+CodeGen._gen_python_code.._get_reprs#t$Cy C'GC,C!4T#Y!?(cC %tE#J'7&899ejj++UZZ-K-KL"5S!9(= %'C+mm$S\\37!!CHH:..C.CHHJ'CII,,S1"5+D6%BBC's8q=yQ0144*E*E!EEKKC&TYY&AS&AAACGGC' #)) 45R #((8K7LByY\YaYaObNccdeeDI&r0r.rc |Dcgc] }| }}|j|jDcgc]\}}|d|c}}dj|Scc}wcc}}w)N = r )extendrr)rrr?resrrr@s r1 _format_argsz.CodeGen._gen_python_code.._format_args8sb*..A9Q<.C. JJFLLNKDAq1#S1/K L99S> !/Ks A%A* nuserc\|vr'||<j|gj|yyr5)rpappend)rXrYnode_to_last_useuser_to_last_usess r1register_last_usesz4CodeGen._gen_python_code..register_last_usesFs7((&* #!,,T26==a@)r0c|jdk(ry|jdk(rjdyj|g}t|jj dk(r|j|t|rHdj |Dcgc] }t|c}dgz}jd|dyjdycc}w) 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$rrrTNone; )opr[riruserskeysrr)rYnodes_to_deleterX to_delete_strbodyr8r]s r1delete_unused_valuesz6CodeGen._gen_python_code..delete_unused_valuesOs ww-'ww(" D!/33D"=O4::??$%* &&t,?# % &56T!W6&A!  c#m"4!5R89 D! 7sC!nodec|jdvr{|j}|rG|k7rA|t|x}r|j}nd}j dd|dyydk7r dd}j d|dyyy)z} Append a summary of the stacktrace to the generated code. This is useful for debugging. >r$r#rz z# rz)# No stacktrace found for following nodesN)rbrrrr[)rirparsed_stack_trace summary_strno_stacktrace_msgrgr8prev_stacktraces r1append_stacktrace_summaryz;CodeGen._gen_python_code..append_stacktrace_summarylsww77".. "o5*51CK1PP-P*<*L*L*NK*,K c#;-.@*A)B"$EF 6%*&(O(S%KK"S):%;$.stringify_shapes-tyy%!8Q#a&!89:!< t@vrxt|j.tBsJj1t5||dtA|j*j>jDfd|j.Dyt=|j*dddk(r|j*j>tFvrrj1tG|j*j>jDfd|j.Ddt5||d|j.dytI|j*} | |j*} | dk(rt|j.tBrt|j.dt,r|j.djKrdtM|j.dk(rLj1t5||dt7|j.d|j.dyj1t5||d| d|j.|j8d|j j dd r jO| y|j(d!k(rqt|j*t,sJj1t5||dt7|j*d|j.|j8dy|j(d"k(rRt|j*t,sJj1t5||dt7|j*y|j(d#k(rc|jd$|jd<j1jQjR|j.dr| nd%ytUd&|j(d'|j*)(Nrz : r) py_sym_types)TensorMetadataval tensor_meta example_valuez: ""z: "Sym(z)"rr#rrT*rr rrrrr* _operatorc3.K|] }|ywr5r/r>s r1rz>CodeGen._gen_python_code..emit_node..sGhYZ RS GhrAc3.K|] }|ywr5r/r>s r1rz>CodeGen._gen_python_code..emit_node..sIj[\)TU,IjrArarMrb is_wrappedFr"r!r$z -> rznode:  )+r"torch.fx.experimental.proxy_tensorrttorch.fx.passes.shape_proprumetarirr;rIlayout sparse_csc sparse_csrstrider<rrKrprrrbr|r-rr[replacerrrcallablerMr) magic_methodsrformatinplace_methodsrrrrprrNotImplementedError)!rimaybe_type_annotation maybe_commentrtrumeta_valstride_annotationdevice_annotationval_strrmaybe_default_argraw_namerPr'rWr@r)r:rgr9r7rrrrrr6rr\rrr5r wrapped_fnss! r1 emit_nodez+CodeGen._gen_python_code..emit_nodesii's9TYY3G2H-I "MKE99==IIMM-PT1UV h 5(//$$$$R; *+8??+<=>& AO8??*;TV%c+hnn"=>?_U]UcUcEd@e?f#$567 BS8T7UUVX* ,7%//9G.5gYb,A).9.1+hnn2M1N_g_m_mOnNoop,q)Dyy}}VT2#=(@!tD6]2Mww-'!$++s333"iiBs9TYYq\3J2K-L"  {{m$9#:;L:Mm_] ;;..sB7tDz)KK4:,c(2 >?M)!$++s333 Dzl#8"9^IVZV_V_`aVbLceiepep=qEEGh^b^g^gGhijl DKKr:kI ,,?KK*4;;+?+?@GGIj`d`i`iIjkllo:,'<&=S499UV.?sD4$Dz )rz)#osenvironrir-rr2r _color_fns _identityrrr{rreversed _input_nodesr enumerater[rr;fxrrrrrr countr_counter_regexpsearchrjrhrr)1r\nodesrrrrrrrr3r`r(r^ri input_noderhrori wrap_name wrap_stmtsrprologue lineno_map prologue_len new_linescur_idxrcounterrfn_coderWr@r)r:rgr8r9r7rr(rr\rnr6rrr5r]rs1` ````` ` @@@@@@@@@@@@@@@@@@r1_gen_python_codezCodeGen._gen_python_codes  " #%') /1T' JJNN13 73 > ( JJNN13 73 >  # C 4/446 "ND(1c tS ! " + +D U#C";/IU#C!*-Hf%DC!IC HD '3 '3 'D "# & "04S(]0C "  ".046 A$ Ad A UO 5D"// 5 ":t4 5 5 "t "6 AD A, =8 = =E HDE HE HE HN!' 'GAt)$/ KK+aS+ , dO  & ' t9> KK ! { a "6588==9I#UykD6$<#UVJJ  ! !))$/D224 $KD% tU # $99 OO  #A &% : 02 ~~d+a/ ! GGDM''- 'D%,,T2G"gmmA./L89  &  'yy#**40yyD4::d3CDD       '8DDM$Vs7O#)Nr)r)r*r+rr r-r.r]rrrrrrrrboolr rr rrrrrrUrrr/r0r1rr>s;LIx01367K)E49EE#c#c#JE#s(OJ  3  1 0# ^9^"%^  ^ ^2@D 1# 1/7} 1  1 C C ssDsCx$9$$"WEWE WE  WEWEWEWEWE WEr0rceZdZdeffd ZdedefdZdedefdZdee d e de fd Z d d d e ffd Z ddde effdZxZS)_PyTreeCodeGen pytree_infoc0t|||_yr5)superr]r)r\rrHs r1r]z_PyTreeCodeGen.__init__Ps (3r0inputsr@c*tj|}|Sr5)r>arg_tree_leaves)r\r flat_argss r1rz_PyTreeCodeGen.process_inputsTs**F3 r0outc|j|jj|St|ttfs|g}|jjJt j ||jjSr5)rrrrrr>tree_unflattenr\rs r1rz_PyTreeCodeGen.process_outputsXsp    #t'7'7'@'@'HJ#e}-%C((444$$S$*:*:*C*CDDr0rrc|sy|Dcgc] }d|vs| }}|sy|rddj|zSddjd|DzdzScc}w)z=Helper to format annotations for variables in pytree codegen.rr c3&K|] }|dz yw)z; Nr/rr?s r1rz5_PyTreeCodeGen._format_annotations..ls%G1a$h%Grrr)r\rrr?has_annotations r1_format_annotationsz"_PyTreeCodeGen._format_annotations`sb%.;#(!;; hmmN;; ;bgg%G%GGG$N N.s(  AqA3b  s}z([z], z), self._in_specrrrz , = fx_pytree.tree_flatten_spec(r)rrr rrr rrr num_childrenchildren_specsr{rrcontextrr)r\rrrfn_args has_orig_self fn_definitionhas_args_kwargs_tuple fn_kwargs fn_signature count_argsr?without_annotationrHs r1r z_PyTreeCodeGen.gen_fn_defns$    #7%2& "",,25g,2Bv-    Q '* AJ/l+  y>A   ((--6L$$,,99Q>L$$,,;;A>CCuLL$$,,;;A>CCtK " Ityy122BCL$!--55DDQGTT **44[jAii $' ,,44CCAFNN ,,66z{C% "$DIIg$6#7s9+EUV JS!SA!''#,q/"7"7"QRV VM "Ts#-JNrrc|jrS|jjr=|,t|ttfr|j ||ddzSdt |dSt|!||S)Nzreturn pytree.tree_unflatten(z, self._out_spec)r) rrrrrrrrr)r\rrrHs r1rz_PyTreeCodeGen.generate_outputs    0 0 9 9 Z dE]%K44#U,K**4D4E3FFWX7*;e*D Dr0)r)r*r+rr]rrrrr-rrr r r __classcell__)rHs@r1rrOs4K4ccE3E3E OT#Y Od Os OKPACGAFFJEXc]EEr0rczeZdZdZdZdeeeeffdZ de fdZ de ddfdZ de ddfd Zdd d ed ed fdZy)_FindNodesLookupTablezH Side table for the graph for the purpose of doing fast queries c,tt|_yr5)rr{tabler[s r1r]z_FindNodesLookupTable.__init__sKV L  r0r@cV|j|jdk(r |jfSdfSNrrbr|r\ris r1_keyz_FindNodesLookupTable._keys(?(BMMMMr0cB||j|j|vSr5rrrs r1 __contains__z"_FindNodesLookupTable.__contains__stzz$))D/222r0riNcFd|j|j||<yr5rrs r1r z_FindNodesLookupTable.inserts,0 499T?#D)r0c^|j|j|j|yr5)rrpoprs r1removez_FindNodesLookupTable.removes! 499T?#''-r0r|rbr|rc |dk(r%|Jg|j||fjS|!g|j|dfjS|j|dfjDcgc]}|j|k(s|c}Scc}wr)rrdr|)r\rbr|ris r1 find_nodesz _FindNodesLookupTable.find_nodess  % %%5TZZV -2245 5 >3TZZT +0023 3"&RJ!7!X$++QWBWXXXs /B B )r)r*r+r,r]rr-r rrrrrr rrr/r0r1rrs} NE#x'7"78N3D3141D1.4.D.CG Y YXh-? Yr0rc4eZdZdZed dPdeddeedd eeee ffd Z e d Z e jd edfd Z e defdZeddefdZedddddededdefdZed dQdddeeefddfdZdRdSdZed dTdedddeeddeeed fd!eed"ee defd#Zedd$Zedd%Zedd&eddfd'ZeddRd(eefd)ZeddRd(eefd*Zeddej<j>fd!ed"ee d+e defd,Z eddRd-ed"ee defd.Z!ed dPd/edeeddeeed fd"ee def d0Z"ed dPd1edeeddeeed fd"ee def d2Z#ed dTd3e$d4e fdeeddeeed fd"ee d!eedef d5Z%edd6fd7ed8e$egd fdefd9Z&eddRd:d d"ee fd;Z'dee(defd<Z)eddddddd=d>ed?ed@edAedBedCede*fdDZ+dddddd=d>edEe,d?ed@edAedBedCede*fdFZ-defdGZ.eddHZ/eddIZ0ed dRdJee$egefdefdKZ1eddLe2fdMZ3eddNe$ee4ge4ffdOZ5y)Ura ``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`. TruN owning_moduler tracer_clsr tracer_extrasct|ddddi|_i|_|jj|_d|_t |_||_||_ ||_ t|_ i|_ t|_y)z+ Construct an empty Graph. rrootr/rN)rrrYprependrrrU_graph_namespace_owning_module _tracer_cls_tracer_extrasr_codegen _co_fieldsr_find_nodes_lookup_table)r\rrrs r1r]zGraph.__init__sw b&"b"= +-zz))  * +%+  *,(=(?%r0c|jSr5rr[s r1rzGraph.owning_module+s"""r0modc||_yr5r)r\rs r1rzGraph.owning_module/s !r0r@ct|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. )rr[s r1rz Graph.nodes3s$r0Fcvttt|j}|jdk(sJ|S)Nr$)nextiterrrrb)r\ output_nodes r1rzGraph.output_nodeBs24 456 ~~)))r0)r|sortrbr|rrcZ|jj||}|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. r)rrsorted)r\rbr|r node_lists r1rzGraph.find_nodesHs3*11<<6<R )$ $r0gval_mapzOptional[Argument]c|jD]V}|vr|jdk(r(t|jdfd}|s|cS||fcS|j |fd|<Xy)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$rc|Sr5r/rXrs r1rz"Graph.graph_copy..zs WQZr0c|Sr5r/r s r1rz"Graph.graph_copy..|s 71:r0N)rrbmap_argr node_copy)r\rrreturn_output_noderirvs ` r1 graph_copyzGraph.graph_copybsp(GG GDwww("TYYq\+?@!3rC"dC NN41EFGDM  Gr0cd|r|ni}t|j}|j||d}tj|j |_|Yt |tsJ|\}}|j|t|dd}tj|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. )rT)rrNr type_expr) rrrcopydeepcopyrrrr$rMr)r\memor output_vals output_valold_output_nodenew_output_nodes r1 __deepcopy__zGraph.__deepcopy__st T-- .ll4$lO ]]4==1  "k51 11*5 'Jhhgovt&L'O$(99_-A-A#BO r0r)r.rrr3rc P|sd}nt|tsJd|s t}nt|tsJd||n|j |}|j j |d}t|||||||}|j:t|jdd#|jjD] } | | |j j|||j||jj||xjdz 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. r/zargs must be a tuplezkwargs must be a dictN_create_node_hooksr)rrrr{_target_to_strrrnrrrMrrrrrr r) r\rbr|rrr3rr^rXfs r1 create_nodezGraph.create_nodesHDdE* B,B B*#%Ffd+ D-D D+ ,D$2E2Ef2M $$00DA tRvy A    ***,@$GS'':: !  55dA> Q %%,,Q/ Q r0c4|jj|S)zL Processes args so that they can be passed to the FX graph. )rrrs r1rzGraph.process_inputss ,t}}++T22r0c8|jj|Sr5)rrrs r1rzGraph.process_outputss}},,S11r0to_erasec t|jdkDr2td|dt|jd|jd|j|k7rtd|d|jrt j d|d y |j:t|jd d #|jjD] }|| |jj||jd |_|xjd zc_ |jt|j dt|j"dy )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``. rzTried to erase Node z but it still had z users in the graph: !zAttempting to remove z from wrong graph!z erase_node(z) on an already erased nodeN_erase_node_hooksTrcyr5r/rXs r1rz"Graph.erase_node..r0cyr5r/r(s r1rz"Graph.erase_node..r)r0)rrc RuntimeErrorr_erasedwarningswarnrrMr&rr_remove_from_listr_update_args_kwargsr _args_kwargs)r\r#rs r1 erase_nodezGraph.erase_nodesB x~~  "&xj0B3x~~CVBWX''/~~&6a9  >>T !!6xj@RST T    MMKz1LM N     ***,?FR''99 (   %%,,X6""$ Q  $$ HNNN 3 H$$n 5 r0rXc||j|jS|j|k(sJdt||jS)aSet the point at which create_node and companion methods will insert into the graph. When used within a 'with' statement, this will temporary 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__``. z&Node to insert before is not in graph.)inserting_afterrrrrr\rXs r1inserting_beforezGraph.inserting_beforesE& 9'' 3 3ww$H HHD!)),,r0c||j|jS|j|k(sJdt||jS)aSet the point at which create_node and companion methods will insert into the graph. When used within a 'with' statement, this will temporary 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__``. z%Node to insert after is not in graph.)r7rrrr[r6s r1r5zGraph.inserting_aftersE& 9((4 4ww$G GGD!((++r0 default_valuecn|tjjurdn|f}|jd|||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``. r/r#)rr)r Signatureemptyr )r\r3rr9rs r1r#zGraph.placeholder6s;<#g&7&7&=&==rMCS t$)TTr0rPcdtjjdtdtfd}|j r*||j |st jdd|jd|| 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``. rrPr@c|jd\}}} |j|}t ||syt ||}t|tjjs3t|tjjs||jvryy#t$rtjd|dYywxYw)Nr~zFailed to fetch module r%FT) rpartition get_submoduleAttributeErrorr-r.r1rMrr;rOModule Parameter_buffers)rrP module_pathr`r3submodrVs r1_get_attr_reference_existsz2Graph.get_attr.._get_attr_reference_existsqs$2#<#=B>a 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 bufferrb) stacklevelr!r) r;rOrBr-rrr-r.r )r\rPrrGs r1r!zGraph.get_attrWsw4  25   2   &@   '  MM#  NiPPr0rQc|jr0|jj|tjd|j 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`. zAttempted to insert a call_module Node with no underlying reference in the owning GraphModule! Call GraphModule.add_submodule to add the necessary submoduler"r)rr@r-r.r )r\rQrrrs r1r"zGraph.call_modulesZL   $"4"4"B"B;"O"W MM&  ;f    r0 method_namec.|jd||||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 rr )r\rJrrrs r1r zGraph.call_methods(F ;f    r0 the_function.c0|jd|||||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)r3rrL)r\rMrrrr3s r1rzGraph.call_functions*L \4di   r0c|Sr5r/rEs r1rzGraph. sRSr0ri arg_transformcjt|j|}t|j|}t|tsJt|t sJ|j |j|j|||j|j}tj|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``. ) r rrrrr{r rbr|r3rrr)r\rirPrr result_nodes r1r zGraph.node_copys2tyy-0m4$&&&&$'''&& GGT[[$ 499  99TYY/ r0resultc.|jdd|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$)rbr|rrrL)r\rSrs r1r$z Graph.outputAs'&yI   r0ct|r |j}n$t|tsJ|}t |r|dd}t |}|S)Nrb)rr)rr-rFrK)r\r|rbs r1rzGraph._target_to_strXsH F Bfc* **B}"X _ r0rrrrrrrc  tdtffd tdtf fd }||5|j ||||||cdddS#1swYyxYw)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. rXc<j|j|Sr5)rnr3)rXrs r1 node_reprz$Graph.python_code..node_reprs((3 3r0rc3Ki}|jD]}|j||<|_ d|jD] }|||_y#|jD] }|||_wxYwwr5)r_repr_fn)r orig_repr_fnsrirYs r1override_node_reprz-Graph.python_code..override_node_reprs~M  *&*mm d# )  * 8 "KK8D$1$$7DM8EKK8D$1$$7DM8s*A.AA.A++A.rN)rUrrr _python_code) r\rrrrrrr]rrYs @@r1 python_codezGraph.python_codecs{ZL  4 4  8e 8  8  % $$--)%   s AA!rc \|jj|j|||||||S)Nr)rrr)r\rrrrrrrs r1r^zGraph._python_codes<}}-- JJ  ))%.  r0cg}dg}|jDcgc]}|j|}}dj|}d|d|dd}|D] }|s|d|zz }|Scc}w)zl Return a human-readable (not machine-readable) string representation of this Graph rr zgraph(rrrr)r format_noder)r\placeholder_namesmaybe_return_typenameri node_strs param_strrGnode_strs r1__str__z Graph.__str__s (*-/4EIZZPTT%%&78P PII/0 YKq!6q!9 :! <! )HX(( ) QsAc ddlm}|jDcgc];}|j|j |j |j|jg=}}t||gdy#t$r tdwxYwcc}w)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.)opcoder3r|rr)headersN) rj ImportErrorprintrrbr3r|rr)r\rjrX node_specss r1 print_tabularzGraph.print_tabulars  )KO**UQqttQVVQXXqvvqxx@U U Z)W X   <    VsA.AB.Bc  ddtdttddf fd }t}t jD]}|jt vrt d|d|jd|jurt d |d |jvrt d |d |jD] }|||  j||j|vrt d |jd|j|jjrjD]}|jd k(rQt|jstd|d|jdt!j"|jdt%|jt&s.check_args01Jqc,sKyy$" Q{m4UUYTZ\ +%" Q{m4``d_eg&r0zNode z had unknown opcode r%zNode 'z ' does not belong to this Graph!z ' is not added to the side tablezNode redefined name rz 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"rz does not reference an nn.Moduler5)rr rXrrb _legal_opsr+rrrrkr3rrr| ValueErrorr;r2rr-rrrMrrOrB) r\ru seen_namesrir target_atomsm_itrratom new_m_itr seen_qualnamerts ` @r1lintz Graph.lints 4 HTN d  #u !$ JJ &Dwwj("U4&0DTWWIQ#OPPzz%"VD61Q#RSS4888"VD61Q#RSS(( %#t$ % OOD !yyJ&"%9$))A#FGG NN499 % &    *77o-#DKK0(#D6$++jX\XcXcIdHef55 &dkk37(#D6$++jX\XcXcIdHef007799#';;#4#4S#9L ..E#,\#:*4$+E4$> (+bq1A(B $,"."'vXdkk]Bd#'&]O!=# 77m3J%uxx=#/"'vXdkk]!D6m_]=!=# !*!*! * r0is_impure_nodec ddlm}|jd tjj j r$tjjj fd}d}t|jD]7}||r t|jdk(s%|j|d}9|j|d|j!dD}|jj#D]\\}}||vs t%|tj&j(s0||j*j-z}|j/^|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) OrderedSetTc:|S|jSr5) is_impure)ri impure_randomrs r1has_side_effectz2Graph.eliminate_dead_code..has_side_effectvs#)%d++>>-0 0r0Fc34K|]}|jywr5rrs r1rz,Graph.eliminate_dead_code..s((rr!)rb)torch.utils._ordered_setrr~r;_guardsTracingContexttry_get _inductorconfigfallback_randomrrrrcr3rrnamed_childrenrrrreliminate_dead_code recompile) r\rrrchangedrisubgraph_names child_name child_modulers ` @r1rzGraph.eliminate_dead_code?s3Z 8  == ' ' / / 1!OO22BBM 1TZZ( D"4(S_-A%     )'("&//Z/"@(N-1,>,>,M,M,O -( L/J %(("6"65|11EEGGG **, -r0codegenc||_yr5)r)r\rs r1 set_codegenzGraph.set_codegens  r0make_transformercjj|j_tjfd}|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()`). c3fK dj_y#j_wxYwwr5)rr)on_gen_code_oldr\sr1 on_generate_code_context_managerz@Graph.on_generate_code..on_generate_code_context_managers( B2A // /s11.1)rr contextlibr)r\rrrs` @r1on_generate_codezGraph.on_generate_codesKR--99*:?*K '  " " B # B 011r0)NNN)Fr5)r@r)NNNN)6r)r*r+r,rr rr{r-rr]propertyrsetterrrrrrrrrrr rrr3r7r5rr;r<r#r!r"r r rr r$rrrr_rUr^rhrpr~rrrTransformCodeFuncrr/r0r1rrs-^$/26/326 @ .@T(^,@ S#X/ @0@*##"-!8""  z    %0T1 %07;$"*8"4CG12$/HM#'d #3 08*$/ 2626"#'< <<u_-. < c:o./ < sm <C=< <0<|%0313 %0212$/% 4% D% 0% N$/-(4.-0-.$/,$,0,.$/$($..44 UUC=U U  U0U@$/AQsAQx}AQPTAQ0AQF$/2626#' / / u_-./ c:o./ / C= /  / 0/ b$/2626#' $ $ u_-.$ c:o./ $ C= $  $ 0$ L$/2626#'" ' sCx(' u_-.' c:o./ ' C= ' sm '  ' 0' R$/HS  )14&*2D)E   0 D$/ Z HSM 0 , Xf%5 # $/ $$"LL L  L  LLL L0Lf$$"            ,$$/ 0 *$/L*0L*\$/AER&x '=>R R0Rh%0 7 1 %0R2"H->$?#@BS#STR21R2r0roverriderc#Ktj} |t_d|t_y#|t_wxYwwr5)rr)rtmps r1_override_sym_reprrs3   C $ Cs?/ ? <?c|Sr5r/rEs r1rrs Hr0cfd}|S)Ncd}||S)Nzr/)rGresetrs r1rz_make_color_fn..fss5'""r0r/)rrs` r1_make_color_fnrs# Hr0zzzzzzz z )yellowcyangreenr:r6r8r9r7z# COUNTER: (\d+)z{} + {}z{} - {}z{} * {}z{} // {}z{} / {}z{} % {}z{} ** {}z{} << {}z{} >> {}z{} & {}z{} | {}z{} ^ {}z{}[{}]z{} @ {})rkrfmulfloordivtruedivdivrpowlshiftrshiftand_or_xorgetitemmatmulz{} == {}z{} != {}z{} < {}z{} > {}z{} <= {}z{} >= {}z+{}z-{}z~{}) eqneltgtlegeposneginvertz{} += {}z{} &= {}z {} //= {}z {} <<= {}z{} %= {}z{} *= {}z{} @= {}z{} |= {}z {} **= {}z {} >>= {}z{} -= {}z{} /= {}z{} ^= {}z {}[{}] = {})iaddiand ifloordivilshiftimodimulimatmulioripowirshiftisubitruedivixorsetitem)tbuiltinsrrrF functoolsrkeywordmathrrr.r- collectionsrcollections.abcrrr dataclassesrrr r r r r r;torch.utils._pytreeutilsrr>torch._Crr rtorch.utils._dtype_abbrsrrr=_compatibilityrimmutable_collectionsrrirrrrr__all___symbolic_tracer graph_modulerrListr{DictrXSet frozenset FrozenSetrTupler0fromkeysrvr-rr&kwlistobjectr6update__dict__r2r.r7r8r9rr<rrFrKpartialrrfrIrerc fullmatchrNrSrUrrrrrrrrrrrrrr _color_codesrrrreflectable_magic_methodsrr)rrs00r1rs  #.%!NN $$60")1II -')  &++&++ v 6<< ]]X d3i[$s)34  Z  (/~~6!!VX+6h''(.0$sN*+03Cc  6A 6A%Es !N8N