L iEBddlZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl Z ddl m Z m Z mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z ddl!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5ddl6m7Z7ddl8m9Z9e jtjvjyrddl m=Z=dd l!m>Z>m?Z?dd l@mAZAGd d ZBGd dZCdZDdZEdZFdZGdZHdZIdZJdZKdZLdZMdeNejfdZPdZQdZRd dZSd dZTgdZUy)!N)dedent)_GeneratorTypeAnyType AwaitTypeBoolType ComplexType DeviceObjTypeDictTypeEnumType FloatType FutureType InterfaceTypeIntTypeListTypeNoneType NumberType OptionalType StreamObjType StringType TensorType TupleType UnionType)_Await_qualified_nameAnyBroadcastingList1BroadcastingList2BroadcastingList3DictFutureis_awaitis_dict is_future is_ignored_fnis_list is_optionalis_tupleis_unionListOptionalTupleUnion)get_source_lines_and_file)_get_script_class)RRefType)is_rrefRRef)OpOverloadPacketceZdZdZdZy)Modulec ||_||_yN)namemembers)selfr8r9s [/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/torch/jit/annotations.py__init__zModule.__init__Gs  ct |j|S#t$rtd|jd|dwxYw)NzModule z has no member called )r9KeyError RuntimeErrorr8r:r8s r; __getattr__zModule.__getattr__KsJ <<% % $))$:4&A  s&7N)__name__ __module__ __qualname__r<rBr=r;r5r5Fs r=r5c ~eZdZeddej iej eddeieeee e e e d Z dZdZy) EvalEnvtorchTensortypingr+) rIrJrKr+r)rr*r,r Awaitc||_tjjj rt |j d<yy)Nr2)rcbrI distributedrpc is_availabler2env)r:rNs r;r<zEvalEnv.__init__bs4    - - /#DHHV  0r=c||jvr|j|S|j|j|Stt|dSr7)rRrNgetattrbuiltinsrAs r; __getitem__zEvalEnv.__getitem__gsC 488 88D> ! 88 88D> !xt,,r=N)rCrDrEr5rIrJr+r)rr*r,r rrRr<rVrFr=r;rHrHTsQ(ELL!9:,,GU#34 C$ -r=rHc>t|trt|j|}n t||}||r|\}}|dd}||f}|Fd\}} t dj t |d}t|}| t|||}|S#t$rYwxYw)Nr.)NNr) isinstancer3try_real_annotationsoprjoinr- get_type_line TypeErrorparse_type_line) fnrNloc is_method signature param_types return_type type_linesources r; get_signaturerhos"&'(4 (S1  $- [!!"o  +. & 6 BGG$=b$A!$DEFF%f-I  ' 3 Tuple[Tensor] # type: (Tensor, Tuple[Tensor, Tensor]) -> Tensor z6Failed to parse the argument list of a type annotationNz4Failed to parse the return type of a type annotation) split_type_linerrH NameError SyntaxErrorr@rYtuple ann_to_type) rfrNra arg_ann_str ret_ann_strarg_anneret_annann arg_typess r;r_r_s /y9K R> gu %* R> 3::3S#&:I: k'3/ //! { # D   { # B   ;s4A7BB=7B BBB:) B55B:c B d |jd}tt|}tt fd|}t j d tt fd|}t |dk(rbt j d tt fd|}t |dkDr&td t|ddzd zd zd zy t |dk(r|ddjSd }g}|D]%\}}d|vr||f}n |vs|j|'|1tddj|Dcgc]}|d c}zdz fd}t||} dj| } |djd| Scc}w)zCTry to find the line containing a comment with the type annotation.# type: c|dvSNr.rF)line type_comments r;zget_type_line..s,$q'*Ar=z!# type:\ ignore(\[[a-zA-Z-]+\])?$c.j|d Srsearch)r type_patterns r;rzget_type_line..sl.A.A$q'.J*Jr=rz&#[ ]*type[ ]*(?!: ignore(\[.*\])?$):c,j|dSrr)rwrong_type_patterns r;rzget_type_line.. s 2 9 9$q' Br=zThe annotation prefix in line z* is probably invalid. It must be '# type:'zl See PEP 484 (https://www.python.org/dev/peps/pep-0484/#suggested-syntax-for-python-2-7-and-straddling-code)z for examplesNr.z# type: (...) -> z_Return type line '# type: (...) -> ...' not found on multiline type annotation for type lines: zl (See PEP 484 https://www.python.org/dev/peps/pep-0484/#suggested-syntax-for-python-2-7-and-straddling-code)cd||jtzd}|jSr7)findrstrip)r item_typers r;get_parameter_typez)get_type_line..get_parameter_type+s0<03|3DDFG   r=z, z...)splitlist enumeratefilterrerrr@rzrappendr\mapreplace)rglines type_lineswrong_type_lines return_lineparameter_type_linesline_numrrtypesparameter_typesrrrs @@@r;r]r]sL LL E 5! "EfA5IJJ::DELfJJWXJ :!ZZ(TU BE J   1 $0&q)!,-.?@BB# #  ZA !}Q%%''K$.$ $ &#T*K  T ! ' ' - .  1iiZ8Ta89 :~ ~  ! "$8 9Eii&O q> ! !% 999s Fctd} |jd}|||j ||dzdj fS#t$r tddwxYw)aSplit the comment with the type annotation into parts for argument and return types. For example, for an input of: # type: (Tensor, torch.Tensor) -> Tuple[Tensor, Tensor] This function will return: ("(Tensor, torch.Tensor)", "Tuple[Tensor, Tensor]") rz->z4Syntax error in type annotation (couldn't find `->`)N)rindex ValueErrorr@r)rf start_offset arrow_poss r;rr5suy>LOOD) \) , 2 2 4i A 6P6V6V6X XX  B  s AAc tj|jgjj Dcgc]}|j c}z}tfd|Dryjj Dcgc]}t|j |}}tj|}||fS#t$rYywxYwcc}wcc}w)z8Try to use the Py3.5+ annotation syntax to get the type.Nc3:K|]}|juywr7)empty).0rsigs r; z'try_real_annotations..Vs 23#))  2s) rjrcrreturn_annotation parametersvalues annotationallr)r`rap all_annotsrrers @r;rZrZIs#''(!nn335, ,J 2z 229<9N9N9PQAQ\\3/QIQc33S9K k !! , RsCC C C CrcFt|}|std|jd|Dchc]}t|j}}|Dcgc]}t ||}}t jj|}|stjS|Scc}wcc}w)NzNo enum values defined for: '') rr __class__typevaluetry_ann_to_typerI_Cunify_type_listrget)rra enum_valuesvrtir_typesress r;get_enum_value_typer`s#'7K 8 QGHH$/ 0qT!''] 0E 0167A3'7H7 (( " "8 ,C {{} J 17s B Bc t|tjryt|tjtjtj tj tjtjtjtjtjf rtjdyy)NTzTorchScript will treat type annotations of Tensor dtype-specific subtypes as if they are normal Tensors. dtype constraints are not enforced in compilation either.F) issubclassrIrJ LongTensor DoubleTensor FloatTensor IntTensor ShortTensor HalfTensor CharTensor ByteTensor BoolTensorwarningswarn)rs r; is_tensorrrs#u||$          OO                    H  r=cyr7rF)inps r; _fake_rcbrs r=c  tj|}|tjjurt j S|tjStj|rt|rt jSt|rDt|dk(r|ddk(r tgSt|Dcgc]}t||c}St|rt|d|}|r t!|St#|rrt|d|}t|d|}|"t%d|dd|j'|"t%d|dd|j't)||St+|rqt-|dt/dr|d}n|d}t||} d} | s3J| j1t3|t3|t3|t5| St7|rt9|t:t<t>hk(rtAjSg} tj|D]{}|#| jCtjt||} d} | s3J| j1t3|t3| t3|| jC| }tE| StFjHjJjMr#tO|rtQt|d|StS|rtUt|d|StW|r0|rt|d|ntYj} t[| S|t<urt]jS|t>urt_jS|t:us|tFj`urtcjS|tdurtgjS|thurtkjS|tlurtYjS|t/durtjStj|r!to|drtq|jrS|tFjturtwjS|tFjxurt{jS|tFj|urtjS|tFjurtcjS|tFjurtcjStj|rt-|tjrqt|;tFjjj||}|j}n t|}t|t||t|Stj|rXt|}||StFjj|r*tFjjj||S|t}tFjj|||Scc}w)Nr.rrFUnknown type annotation: '' at zWUnsupported annotation {} could not be resolved because {} could not be resolved. At {}__torch_script_interface__)RrKget_argsrj Signaturerr getInferredrrisclassrr'rrrr%rr"r highlightr r&rrformatreprrr(setintfloatcomplexrrrrIrOrPrQr1r0r#r r!rrr rSymIntrrzrboolrrhasattrrrdevicer GeneratorrStreamrdtypeqschemeenumEnumr/r_script_recursive_compile_classqualified_namerr rr _jit_internalcan_compile_classrr_resolve_type_from_object)rrarNann_argsa elem_typekeyr contained valid_typemsginner maybe_type elementTypescripted_classr8maybe_script_classs r;rrs*s#H g%%%%%'' {||~s #~~} x=A (1+"3R= 8Da/!S1DEEs|#HQK5 I& &s|hqk3/ S1 ;,Xa[Ms}}>OP  =,Xa[Ms}}>OP U##3 hqk4: .  I  I$Y4 hL3::d3ii$s)LLzJ''} x=S%1 1>># #% %Ay X\\^,(C0JlC Qszz$s)T*5EtCyQ Q: LL $  % ))+  S9::~/(1+s;<<};Cohqk37 %% e|}} g~   czSELL({{} cz~~ d{||~ cz{{} d4j||~s-I JS;;<< ell  "" eoo!!## ell  "" ekk{{} emm{{}s 3 : S ! )"YY..GGSQN!002D"3'D1#s;T#YGGs.s3  )% %    0 0 599$$==c3G G { 88 - -c3 <<}EsZ cbt|||}||Std|d|j)Nrr)rrr)rrarNthe_types r;rrs;sC-H 1#eCMMO;LM NNr=)rr)rrrr+r'r%rr"r&r(rrr rrrrr rr5rhrr}r_r]rrZrrr7)VrrUrrrjrrKrtextwraprrItorch._Crrrrrr r r r r rrrrrrrrrrrtorch._jit_internalrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,torch._sourcesr-_stater/rOrPrQr0r1r2 torch._opsr3r5rHrhrorur}rrr_r]rrZrrrrrrr__all__rFr=r;r/s    .,5% %%'!1'  --6:N /, *%0<@:FY(".4 ?$8k=\O" r=