~L ivUdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddl mZmZmZmZmZmZmZmZmZmZmZmZddlmZddlZddlZddl m!cm"Z#ddl$m%Z%ddl&m%Z'm(Z)ddl*m+Z+m,Z,m-Z-ddl.m(Z(ed Z/ed Z0e jbd k\Z2ee3e4d <ee5e6e5d ffe4d<e jbd k\r e jnZ8ndZ8e5e4d< ddl9Z9e9jtZ:ejzZ>de4d<dZ?de3fdZ@GddZAeAZBeCddD]ZDeBeEdeD<de3fdZFdodeGfdZHGddZIeIZJdZKdpd eLfd!ZMd"ZNd#ZOde3fd$ZPdeQeGfd%ZRd&ZSd'ZTd(ZUd)ZVGd*d+ZWd,ee/e0fdee/e0ffd-ZXd,ee/e0fdee/e0ffd.ZYGd/d0ejZ[dqd1Z\d,ee/e0fdee/e0ffd2Z]d,ee/e0fdee/e0ffd3Z^d4Z_de3fd5Z`de3fd6Zade3fd7Zbde3fd8Zcd9Zdd:Zedrd;ZfiageheGeQefe4d<<d=Zid>Zjd?Zkd@ZldAZmdrdBZnde6eGeLffdCZoiapeheGeheGeQeffe4dD<iZqehe6eGeGfeLfe4dE<dFZrdGZsde3fdHZtde3fdIZude3fdJZvdKZwdLZxde3fdMZyde3fdNZzejjjrddOl~mZddPlmZde3fdQZde3fdRZnde3fdSZdTZ dsdUeejj j fdVZdWeGdXeQeGdYe6ed ffdZZejd[Zdrd\Zde3fd]Zdrd^Zehd_eQd`e6dae j$dbe j.dce j0dde j2deiZdrdfZdrdgZde3fdhZde3fdiZGdjdkej&ZdlZdeeGfdmZe jbdnk\rye]ej.j0e]ej.j2e]ej.j4e]ej.j6yy#e;$rddltypingtyping_extensions)hasattrr"r r isinstancetypeanns Y/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/torch/_jit_internal.pyis_finalr+UsF\" G NN= = G _ % ECe)EceZdZdZy)BroadcastingListClscyNr)selftypess r* __getitem__zBroadcastingListCls.__getitem___sr,N)__name__r" __qualname__r3rr,r*r.r.^sr,r.BroadcastingListcy)a Function that returns True when in compilation and False otherwise. This is useful especially with the @unused decorator to leave code in your model that is not yet TorchScript compatible. .. testcode:: import torch @torch.jit.unused def unsupported_linear_op(x): return x def linear(x): if torch.jit.is_scripting(): return torch.linear(x) else: return unsupported_linear_op(x) Frrr,r* is_scriptingr:js& r,c`t|dr |jSt|tjj r |j St|ddr |j}n2t|tjr |j}n td|dk(rd}|j}|dk(r |j S|td|dtj|r$|j!d d }|j!d d }|r |d k(rd }nd|z}d|vrtd|d|d|dz|zS)N_jit_override_qualnamer4z)Could not get name of python class objectz_lambdaztorch._classesz(Could not get qualified name for class 'z': __module__ can't be None.<_>__main__ __torch__z __torch__..z': 'z' is not a valid identifier)r%r<r&torch_CScriptFunctionqualified_namegetattrr4enumEnumname RuntimeErrorr"package_mangling is_mangledreplace)obj mangle_namerK module_names r*_qualified_namerSsWs,-)))#uxx../!!!sJ%|| C #xxFGG z..K&&!!!6tf=( (  "";/!))#s3 !))#s3  * $%K'4K d{6tf=v0 2   t ##r,ceZdZdZdZdZy) SourceLoaderci|_yr0contentr1s r*__init__zSourceLoader.__init__s  r,c"||j|<yr0rW)r1fnsources r*cachezSourceLoader.caches! Rr,c8|jj|Sr0)rXget)r1r\s r* get_sourcezSourceLoader.get_sources||##r,N)r4r"r5rZr^rarr,r*rUrUs"$r,rUc^fddtttfffd fdfdS)a_ Creates a resolution callback that will look up qualified names in an environment, starting with `lookup_base` for the base of any qualified names, then proceeding down the lookup chain with the resolved object. You should not use this directly, it should only be used from the other createResolutionCallbackFrom* functions. czd|vr+|jdd\}}t||}||St||S)NrC)maxsplit)splitrH)rGmodulebaseremaining_pieces module_valuelookupInModules r*rkz7createResolutionCallbackFromEnv..lookupInModulesM . %3%9%9#%9%J "D""640L!"2LA A6>2 2r,r cd}|t|kr"||dvr|dz }|t|kr||dvr|d|dk(rd|fS|d|j|}| Jd|d||t|k(s||dk7r||fS||dk(sJg}||dk7r5d}|dz }||d|\}}|j|||z }||dk7r5t|dkDr|t||dzfS||d|dzfS) Nr),[]rdz()rzUnresolvable type rnro)lenstripappendtuple) exprrgirhpartspart_lenpartrkparseNestedExprs r*ryz8createResolutionCallbackFromEnv..parseNestedExprsP #d)mQ > FA#d)mQ > 8t q5Ld2Ahnn.7@#5d2AhZ!@@ D >T!W^7NAw#~~1gnH FA,T!"Xv>ND( LL  MA 1gn u:>e %q1u, ,a>1q5( (r,cl ||\}}|t|k(sJd|S#t$r YywxYw)Nz;whole expression was not parsed, falling back to c++ parser)rp Exception)rtrgvalue len_parsedrys r* parseExprz2createResolutionCallbackFromEnv..parseExprsU  /f = E:T* M *L    s "& 33c|Sr0r)rt lookup_baser~s r*z1createResolutionCallbackFromEnv..s $ 4r,)rsrint)rrkr~rys`@@@r*createResolutionCallbackFromEnvrs)3)sCx)8 54r, frames_upctj}d}||dzkr|J|j}|dz }||dzkr|J|j|jGfdd}t |S)a\ Creates a function which, given a string variable name, returns the value of the variable in the scope of the caller of the function which called createResolutionCallbackFromFrame (by default). This is used to enable access in-scope Python variables inside TorchScript fragments. frames_up is number of additional frames to go up on the stack. The default value is 0, which correspond to the frame of the caller of createResolutionCallbackFromFrame. Also for example, if frames_up is set to 1, then the frame of the caller's caller of createResolutionCallbackFromFrame will be taken. For example, the following program prints 2:: def bar(): cb = createResolutionCallbackFromFrame(1) print(cb("foo")) def baz(): foo = 2 bar() baz() rrdceZdZfdZy).createResolutionCallbackFromFrame..envcl|vr|S|vr|S|ttvrtt|Syr0)dirbuiltinsrH)r1key f_globalsf_localss r* __getattr__z:createResolutionCallbackFromFrame..env.__getattr__?sDh}$ ! ~%H %x--&r,Nr4r"r5r)rrsr*envr>s .r,r)inspect currentframef_backrrr)rframerurrrs @@r*!createResolutionCallbackFromFramers:  "E A i!m      Q i!m    ~~HI.. +35 11r,ci}|j|jt|jjD]!\}}|j |j ||<#|S)zC Get a dictionary of closed over variables from a function )update __globals__ enumerate__code__ co_freevars __closure__ cell_contents)r\capturesindex captured_names r* get_closurerJs^H OOBNN# )"++*A*A BF}"$.."7"E"EF Or,cRt|Gfdd}t|S)z Create a resolutionCallback by introspecting the function instead of looking up the stack for the enclosing scope ceZdZfdZy);createResolutionCallbackFromClosure..closure_lookupc|vr|Stt|rtt|Stt|rtt|Syr0)r%r#rHr)r1rclosures r*rzGcreateResolutionCallbackFromClosure..closure_lookup.__getattr__sEg~s|#%vs++3'x--r,Nr)rsr*closure_lookuprs r,r)rr)r\rrs @r*#createResolutionCallbackFromClosurers( "oG   +>+; <'> >9//5 i"""L (//#&'A 166{az!&&)S__EYrd*;<== q A vv{{L36.. s~~ .d   %  77 | #5A(5K 1 2#L,!3199 =8D!33!2!2!8!88 3,c2 2! $@8I45 A +B4/GH  sG: AH: HHHc |jDcgc]-}tjt||r t||/}}|Dcgc]'}tj|rt |ds&|)}}i|D]6}j t|j t|8fd}|Scc}wcc}w)z This looks at all the methods defined in a class and pulls their closed-over variables into a dictionary and uses that to resolve variables. rc8|vr|Stt|dSr0)rHr)rrs r*lookup_in_classz@createResolutionCallbackForClassMethods..lookup_in_classQs# (?C= 8S$/ /r,) rrrrH isbuiltinr%rrr)rrKrr\rrs @r*'createResolutionCallbackForClassMethodsr;sLL     WS$/ 0 T C  X"7#4#4R#8WR=W2 XC XH4 B(.r2340 +  Ys2B:B?# B?0B?cnfd}j jj}|_nRj jj}|_n&jjd}n td||_|||_|||_dt|<|S)z Dispatches to either of 2 script functions based on a boolean argument. In TorchScript, the boolean argument must be constant so that the correct function to use can be determined at compile time. cf}|vr|}nt|kr|}|r|i|S|i|Sr0)rp)rkwargs dispatch_flag arg_indexrdefaultif_falseif_trues r*r\zboolean_dispatch..fnisR v "8,M T " OM D+F+ +T,V, ,r,Nz&only one function can have a docstring)rrrrr)__doc__rLr"r4r) rrrrrrR func_namer\docs ````` r*boolean_dispatchrZs - -8#3#3#?    !goo&Aoo    !goo&=CDDBJ#   r Ir,c(eZdZdZdZdZdZdZdZdZ y) FunctionModifierszn Used to denote the behavior of a function in TorchScript. See export() and ignore() for details. z:unused (ignored and replaced with raising of an exception)z>ignore (leave as a call to Python, cannot be torch.jit.save'd)z7export (compile this function even if nothing calls it)z>default (compile if called from a exported function / forward)zNif this method is not scripted, copy the python method onto the scripted modelzB_drop (function is fully ignored, declaration can be unscriptable)N) r4r"r5rUNUSEDIGNOREEXPORTDEFAULTCOPY_TO_SCRIPT_WRAPPER_DROPrr,r*rrs. JF MF FFNGX QEr,rr\c0tj|_|S)a This decorator indicates that a method on an ``nn.Module`` is used as an entry point into a :class:`ScriptModule` and should be compiled. ``forward`` implicitly is assumed to be an entry point, so it does not need this decorator. Functions and methods called from ``forward`` are compiled as they are seen by the compiler, so they do not need this decorator either. Example (using ``@torch.jit.export`` on a method): .. testcode:: import torch import torch.nn as nn class MyModule(nn.Module): def implicitly_compiled_method(self, x): return x + 99 # `forward` is implicitly decorated with `@torch.jit.export`, # so adding it here would have no effect def forward(self, x): return x + 10 @torch.jit.export def another_forward(self, x): # When the compiler sees this call, it will compile # `implicitly_compiled_method` return self.implicitly_compiled_method(x) def unused_method(self, x): return x - 20 # `m` will contain compiled methods: # `forward` # `another_forward` # `implicitly_compiled_method` # `unused_method` will not be compiled since it was not called from # any compiled methods and wasn't decorated with `@torch.jit.export` m = torch.jit.script(MyModule()) )rr_torchscript_modifierr\s r*exportr sT 177B Ir,ct|trZ|}t|jdtj |j r%t|j dtj |Stj |_|S)a This decorator indicates to the compiler that a function or method should be ignored and replaced with the raising of an exception. This allows you to leave code in your model that is not yet TorchScript compatible and still export your model. Example (using ``@torch.jit.unused`` on a method):: import torch import torch.nn as nn class MyModule(nn.Module): def __init__(self, use_memory_efficient): super().__init__() self.use_memory_efficient = use_memory_efficient @torch.jit.unused def memory_efficient(self, x): import pdb pdb.set_trace() return x + 10 def forward(self, x): # Use not-yet-scriptable memory efficient mode if self.use_memory_efficient: return self.memory_efficient(x) else: return x + 10 m = torch.jit.script(MyModule(use_memory_efficient=False)) m.save("m.pt") m = torch.jit.script(MyModule(use_memory_efficient=True)) # exception raised m(torch.rand(100)) r)r&propertysetattrfgetrrfsetr)r\props r*unusedrsmP"h II.0A0H0H  99  24E4L4L  077B Ir,c*eZdZdZdedededdfdZy)_IgnoreContextManagerc yr0r)r1rs r*rZz_IgnoreContextManager.__init__  r,exc_type exc_value tracebackr Ncyr0r)r1rrrs r*__exit__z_IgnoreContextManager.__exit__ rr,)r4r"r5rZrrrr,r*rr s(      r,rc 4tr}tj|_|St t st d|jdd}|rtjdt|nrtjdtfd}|S)a& This decorator indicates to the compiler that a function or method should be ignored and left as a Python function. This allows you to leave code in your model that is not yet TorchScript compatible. If called from TorchScript, ignored functions will dispatch the call to the Python interpreter. Models with ignored functions cannot be exported; use :func:`@torch.jit.unused ` instead. Example (using ``@torch.jit.ignore`` on a method):: import torch import torch.nn as nn class MyModule(nn.Module): @torch.jit.ignore def debugger(self, x): import pdb pdb.set_trace() def forward(self, x): x += 10 # The compiler would normally try to compile `debugger`, # but since it is `@ignore`d, it will be left as a call # to Python self.debugger(x) return x m = torch.jit.script(MyModule()) # Error! The call `debugger` cannot be saved since it calls into Python m.save("m.pt") Example (using ``@torch.jit.ignore(drop=True)`` on a method): .. testcode:: import torch import torch.nn as nn class MyModule(nn.Module): @torch.jit.ignore(drop=True) def training_method(self, x): import pdb pdb.set_trace() def forward(self, x): if self.training: self.training_method(x) return x m = torch.jit.script(MyModule()) # This is OK since `training_method` is not saved, the call is replaced # with a `raise`. m.save("m.pt") .. testcleanup:: import os os.remove('m.pt') zCArgument to @torch.jit.ignore must be a bool or a function but got drop_on_exportNzignore(drop_on_export=True) has been deprecated. TorchScript will now drop the function call on compilation. Use torch.jit.unused now. {})categoryzzignore(True) has been deprecated. TorchScript will now drop the function call on compilation. Use torch.jit.unused now. {}cdrtj|_|Stj|_|Sr0)rrrr)r\drops r* decoratorzignore..decoratorps0 '8'?'?B $ (9'?'?B $ r,) callablerrrr&boolrLpopwarningswarn FutureWarning)rrr\rr s` r*ignorer'sB~#4#;#;  dD !QRVQW X  ZZ 0$7N  @"    @"  r,c0tj|_|Sr0)rrrr s r*_dropr)zs066B Ir,c0tj|_|Sr0)rrrr s r*_copy_to_script_wrapperr+s0GGB Ir,ct|D]D}t||st||}t|s(t |t j usDyy)NTF)rr%rHr!get_torchscript_modifierrr)modrKitems r*module_has_exportsr0sNC  3 3%D~+D15F5M5MM  r,cjt|}|y|tjuxs|tjuSNF)r-rrr)r\rs r* should_dropr3s7 #B 'D | $++ + Nt7H7N7N/NNr,ct|}|tjuxs&|tjuxs|tjuSr0)r-rrrrr\r.s r*rrsH "2 &C  ''' * #** * * #)) )r,c<t|}|tjuSr0)r-rrr5s r* _is_drop_fnr7s "2 &C #)) ))r,cNttj||dtS)N)r)r&rgetattr_static staticmethodrr\s r* is_static_fnr<s g,,S"dC\ RRr,cBtj||jSr0)rr9__func__r;s r* get_static_fnr?s  ! !#r * 3 33r,ct|syt|dr |j}t|dtj S)Nr>r)r!r%r>rHrrr s r*r-r-s6 B<r: [[ 2.0A0I0I JJr,c.t|}|y||_yr0)r-r)orignewrs r*copy_torchscript_modifierrDs #D )D | $Cr,_overloaded_fnsaP Example usage of overload function: @torch.jit._overload def my_function(x: type0) -> type0: # decl 1 pass @torch.jit._overload def my_function(x: type1) -> type1: # decl 2 pass def my_function(x): # implementation if isinstance(x, type0): return x elif isinstance(x, type1): return x c t|\}}}d|dt|d|d|d dj|zdztzS)NzImplementation for the z "zk" is missing. Please make sure a definition is provided and defined after all overload declarations. File "z", line z:  )rrSr_OVERLOAD_EXAMPLE)rrP sourcelines file_linenofilenames r*,get_overload_no_implementation_error_messagerMsj)B3)G&Kh !$r/#*>)?@ (;-s 4 ''+        r,c t|}|jj dj }d}d}t |dk7s||dsU||dsId}|dj|jjddd z }|d tzz }t|yy#t$rtjd|dYywxYw) Nz=Unable to retrieve source for @torch.jit._overload function: rCrc6t|tjSr0)r&rPassxs r*is_passz%_check_overload_body..is_passs!SXX&&r,ct|tjxrBt|jtjxr|jjt uSr0)r&rExprr|rEllipsisrQs r* is_ellipsisz)_check_overload_body..is_ellipsissA q#(( # *177CLL1 * ) r,rdzHOnly `pass` statement or `...` can be the body of overload declaration: rHrz$ <- Expecting `pass` or `...` here! ) rrr$r%rrrprr]rfrIrL)func parsed_defrrSrWmsgs r*_check_overload_bodyr[st_  >>  q ! & &D'  4yA~gd1g.+d1g2F W  tyy**006r:;; 69JJJ3 3G.)   KD6QR S   s B%%"C  C ct|t|}tj|}| g}|t|<|j ||Sr0)r[rSrEr`rr)rX qual_namefn_overload_lists r* _overloadr_sN%I&**95%5 "D! Kr,c,tj|Sr0)rEr`r]s r*_get_fn_overloadsrbs   y ))r,ct|=yr0)rEras r*_clear_fn_overloadsrds  "r,ctj}tdD]}|J|j}|J|jj }|jj }||fSNr6)rrrangerf_codeco_nameco_firstlineno)method current_framer? class_nameline_nos r*get_class_name_linenorosy((*M1X-  % %%,, -  $$ $%%--J""11G w r,_overloaded_methods_overloaded_method_class_filenoc:t|t|}tj|d}| i}|t|<t |\}}|j|d}|g}|||<|t ||f<nt ||f}||k7r t d|j||S)NzmCannot currently overload the same method name in two different classes with the same name in the same module)r[rSrpr`rorqrLrr)rXr]class_name_maprmrnmethod_overloadsexisting_linenos r*_overload_methodrv8s%I(,,Y=N)7I&/5J%))*d;%5z"CJ'J(?@99j:QR g %A  D! Kr,cTt|dsyt|}tj|d}|y|j|jd}|yt |d}t |d}|t t |dz}||k\r||kstdt|z|S)Nr4rdrzKOverloads are not usable when a module is redeclared within the same file: ) r%rSrpr`r4rrpAssertionErrorr)rk mod_classr]rs overloadsmethod_line_nomod_class_filenomod_end_filenos r*_get_overloaded_methodsr~Ss 6: &'I(,,Y=N""9#5#5t%,Ei,PQR,S(TTN . .>^3S Y&k    r,c|tjur tdt|dsyt |}|j dvxr|t uS)Nr r"Frr#)r#r 'raise_error_container_parameter_missingr%r r"rsr) ann_origins r*is_tuplerjsH fll/8 3 %CJ >>3 3 K e8KKr,c|tjur tdt|dsyt |}|j dvxr|t uS)Nr r"Fr)r#r rr%r r"rrs r*is_listrwF fkk/7 3 %CJ >>3 3 J d8JJr,c|tjur tdt|dsyt |}|j dvxr|t uS)Nrr"Fr)r#rrr%r r"dictrs r*is_dictrrr,c|tur tdt|txs0t |dxr"|j dk(xrt |tuS)Nrr"r#)rrr&rr%r"r r(s r*is_unionrsR e|/8 c+ , \" ' NNh & ' _ %r,cr|tur tdd}d}||xst|xr||S)Nr cbt|dxr"|jdk(xrt|tuS)Nr"r#)r%r"r r r(s r*is_optional_as_optionalz,is_optional..is_optional_as_optionals3 C & .(* .CH, r,c^t|}t|dk(xrd|vxs td|vSrf)rrpr')r)ann_argss r*is_union_as_optionalz)is_optional..is_union_as_optionals2C=8}!Rtx'7'Q4:;QRr,)r rr)r)rrs r* is_optionalrs> h/ ; S #3 ' XHSM,W>RSV>WXr,cJ|tur tdt|tuS)Nz_Attempted to use Future without a contained type. Please add a contained type, e.g. Future[int])rrLr r(s r* is_futurers, f}   c?f $$r,c6|turyt|tuS)NT)rr r(s r*is_awaitrs f} c?f $$r,)PyRRef)RRefcJ|tur tdt|tuS)Nz[Attempted to use RRef without a contained type. Please add a contained type, e.g. RRef[int])rrLr r(s r*is_rrefrs, $;  #$&&r,c"t|tSr0)r&rrPs r*is_rref_instancers#v&&r,cyr2rrs r*rrsr,cDt|sytj|Sr0)r!rr`r s r*_try_get_dispatched_fnrs B<  ! !" %%r,locc | t}t|tr t|dsJt|dr5|jDcgc]}||j vr|j |!}}ng}t jdddkrt|di}nNtj|}t|dk(r+t|drtj|j}g}|jD]}||vr||}t|trD|B||j}|,t!d|d |j"d |j%|}t&j(j*j-|||} |j/| |j/t&j0j2j5t7|j"|j||fScc}w) N_fields_field_defaultsr6r__annotations__r__base__zUnknown type annotation: 'z' in NamedTuple zh. Likely due to partial support for ForwardRef parameters in NamedTuples, see #95858. Issue occurred at )rrrsr%rrsys version_inforHrget_annotationsrprr&r__forward_arg__ ValueErrorr4 highlightrDjit annotations ann_to_typerrrE TensorType getInferredr') rPrrcbfielddefaultsobj_annotationsr field_typercb_typethe_types r*_get_named_tuple_propertiesrs  {l c5 !gc9&== =s%& +++    &   g%!#'8"=!11#6  1 $j)A%55cllCOK3B O #(/JH*j1coz99:#$4ZL@PQTQ]Q]P^_..1mmo->@ & yy,,88S#NH   x (   uxx22>>@ Ag3Bh 9  s{{K AAK s$G' unqual_name field_namesrc<tj|||}||S)N)r) collections namedtuple)trrr TupleTypes r*_create_named_tupler+s" &&{K(SI a=r,c#4Ktjj}tjjdd dtjj|d|dy#tjj|d|dwxYwwNrrd)rDrE_jit_get_emit_hooks_jit_set_emit_hooks)hookss r*_disable_emit_hooksr5sl HH ( ( *E HH  t,9  $$U1XuQx8$$U1XuQx8s?BA-'B-(BBcdd}dd}y)Nctjj|_tjj ddyr0)rDrErrrrYs r* __enter__z0_disable_emit_hooks_decorator..__enter__As*XX113  $$T40r,cxtjj|jd|jdyr)rDrErr)r1rs r*rz/_disable_emit_hooks_decorator..__exit__Es& $$TZZ]DJJqMBr,r Nr)_DecoratorContextManagerrrs r*_disable_emit_hooks_decoratorr?s 1Cr,cNtj|syt|tSr2)risclassrr{rs r* _is_exceptionrIs ??3  c9 %%r,cl|jdrtd|d|dtd|d|d)NictzAttempted to use z: without contained types. Please add contained type, e.g. z [int, int]z= without a contained type. Please add a contained type, e.g. z[int])endswithrL) target_types r*rrOs]E" }-@m: '   K=)= -u  r,rrrsrr r r cJtj|x}r t|yyr0)_RAW_TYPE_NAME_MAPPINGr`r)rrKs r*check_args_existrhs%%))+66t6/57r,cN|gk(s |ik(s|dk(rtjdyy)NrzThe inner type of a container is lost when calling torch.jit.isinstance in eager mode. For example, List[int] would become list and therefore falsely return True for List[float] or List[str].)r$r%rs r*check_empty_containersrms+ byC2I   "+r,cDt|}t||y|tus|tjur\t |t |tsyt|d}t|}|D]!}|rt||ryt ||r!yy|tjus|turt |t |tsyt|d}t|d}|jD]=\}} t ||syt|} | rt| |r.yt | |r=yy|tjus|tur~t |t |tsyt|} t|t| k7ryt|| D]/\}} t| } | rt|| r yt || r/yy|t ust#|t$r>|yt|}|D]+}t|}|rt||cSt ||s+yy)NFrTrd)r rrr#r rr&rcontainer_checkerrrrr rsrpziprrr)rPr origin_typearg_type arg_originelkey_typeval_typerval val_origin arg_typesel_type el_origin inner_typesrt_origins r*rrzs[)K[!   v{{ :s##t$K(+)  B(X6 H-    #{d':s##t$K(+K(+ HCc8,#H-J(h7 X.   $ u(<s##u%[) s8s9~ %sI. KB"7+I(W5 G,    %" ;{+  A!!}H(a00C#   r,c t|tjjr1t|ts t d|D]}t ||syyt|}|r t||St|t||S)NzPThe second argument to `torch.jit.isinstance` must be a type or a tuple of typesTF) r&rabc ContainerrsrL _isinstancer rr)rPrt_typers r*rrs+{889+u-&  " F3' [)K k22[! c; ''r,cDeZdZdeej ffd ZdZxZS)_TensorExtractortensorsc2t||i|||_yr0)superrZr)r1rrr __class__s r*rZz_TensorExtractor.__init__s $)&) r,clt|tjr|jj |yt|t ryt|t s t|ryt|tryt|tjjryt|tjryy)NrG) r&rDTensorrrrrCFuturerCAwaitcudaEvent threadingThread)r1rPs r* persistent_idz_TensorExtractor.persistent_ids c5<< ( LL   $ c8 $ c7 #'7'< c6 " c5::++ , c9++ ,r,) r4r"r5rrDrrZr __classcell__)rs@r*rrstELL'9r,rclg}ttjd|}|j||S)z This function is exclusively called from C++. See ``torch/csrc/jit/python/python_ivalue.h``. It extracts the tensors contained in the given object, through pickling. )protocolr)rioBytesIOdump)rPr extractors r*_extract_tensorsrs.#%G GLI NN3 Nr,ct|tjjr#t |j j St|tjjr |jSyr0) r&rDr ScriptModuler_c_typerFrGrs r* _get_model_idr sN#uyy--.366<<>"" C11 2!!!r,)r )T)r)Fr)NN)rrrr contextlibrIrrpicklerrrr2r#r$weakrefrrrrrrr r r r r rr$rrDtorch.distributed.rpctorch.package._manglingpackage _manglingrM torch._awaitsrtorch._Crrrtorch._sourcesrrr torch.futuresrrrrr"rr'rs UnionTyper_threadr ImportError _dummy_threadWeakKeyDictionaryrFAKE_FILENAME_PREFIXr+r.BroadcastingList1rgruglobalsr:rrSrUrrrrrrrrrrrrrrr rAbstractContextManagerrr'r)r+r0r3rr7r<r?r-rDrErrIrMr[r_rbrdrorprqrvr~rrrrrrr distributedrpc is_availabletorch._C._distributed_rpcrrrrrrE_jit_tree_views SourceRangerrcontextmanagerrrrrrrrrrPicklerrrr rJ__new__ __format____repr____str__rr,r*r/s         ( 22 8KK t_ T] --8 uT{8eD#I..//w &HGN /T() q!:A(9GI $%:d.C$cC$L$$ >5B1212h t=,d*tCy>,Tn>4n Q Q +xB+HRV$4+\6xB6HRV$46t J== fRhr2v8BF#3 R 0Xb"f5E OtO*t* STS4K%.0c4>)*/$  @ *# U38_ 4=?T#tCh$7889>?AeCHos&:!;@6. LT L KD K KD KY$%d%%T%  %%'0*''''  &;? OB %((**66 7OBdcCHo  99C&$&  && 7 KK KK OOZ LL'6  ?4?D(T(2v~~< (3-w $))   $))   $))   $))   M.&%%H&s+P66QQ