
    YThtE                     R   S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKJ	r	  S SK
r
S SKJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJ r   S SK!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-J.r.J/r/J0r0J1r1J2r2J3r3J4r4J5r5  S SK6J7r7  SSK8J9r9  \
Rt                  Rv                  Ry                  5       (       a  S SKJ=r=  S S	K!J>r>J?r?  S S
K@JArA   " S S5      rB " S S5      rCS rDS rES rFS rGS rHS rIS rJS rKS rLS rMS\N\R                     4S jrPS rQS rRS S jrSS S jrT/ SQrUg)!    N)dedent)_GeneratorTypeAnyType	AwaitTypeBoolTypeComplexTypeDeviceObjTypeDictTypeEnumType	FloatType
FutureTypeInterfaceTypeIntTypeListTypeNoneType
NumberTypeOptionalTypeStreamObjType
StringType
TensorType	TupleType	UnionType)_Await_qualified_nameAnyBroadcastingList1BroadcastingList2BroadcastingList3DictFutureis_awaitis_dict	is_futureis_ignored_fnis_listis_optionalis_tupleis_unionListOptionalTupleUnion)get_source_lines_and_file   )_get_script_class)RRefType)is_rrefRRef)OpOverloadPacketc                        \ rS rSrS rS rSrg)ModuleF   c                     Xl         X l        g N)namemembers)selfr9   r:   s      M/var/www/auris/envauris/lib/python3.13/site-packages/torch/jit/annotations.py__init__Module.__init__G   s    	    c                 v     U R                   U   $ ! [         a    [        SU R                   SU 35      S ef = f)NzModule z has no member called )r:   KeyErrorRuntimeErrorr9   r;   r9   s     r<   __getattr__Module.__getattr__K   sJ    	<<%% 	$))$:4&A	s    '8)r:   r9   N)__name__
__module____qualname____firstlineno__r=   rD   __static_attributes__ r?   r<   r5   r5   F   s    r?   r5   c                       \ rS rSr\" SS\R                  05      \R                  \" SS\05      \\\	\
\\\S.
rS rS rS	rg
)EvalEnvT   torchTensortypingr+   )
rO   rP   rQ   r+   r)   r   r*   r,   r    Awaitc                     Xl         [        R                  R                  R	                  5       (       a  [
        U R                  S'   g g )Nr2   )rcbrO   distributedrpcis_availabler2   env)r;   rT   s     r<   r=   EvalEnv.__init__b   s5      --//#DHHV 0r?   c                     XR                   ;   a  U R                   U   $ U R                  b  U R                  U5      $ [        [        US 5      $ r8   )rX   rT   getattrbuiltinsrC   s     r<   __getitem__EvalEnv.__getitem__g   sA    8888D>!8888D>!xt,,r?   )rT   N)rF   rG   rH   rI   r5   rO   rP   r+   r)   r   r*   r,   r    r   rX   r=   r]   rJ   rK   r?   r<   rM   rM   T   sQ    (ELL!9:,,GU#34C$
-r?   rM   c                 P   [        U [        5      (       a  [        U R                  U5      nO[        X5      nUb  U(       a  Uu  pVUSS  nXV4nUcE  Su  px [	        SR                  [        U 5      S   5      5      n[        U5      nUb  [        XqU5      nU$ ! [         a     Nf = f)Nr.   )NN r   )

isinstancer3   try_real_annotationsopr   joinr-   get_type_line	TypeErrorparse_type_line)	fnrT   loc	is_method	signatureparam_typesreturn_type	type_linesources	            r<   get_signaturerp   o   s    "&''(4	(1	
 $- !!"o .	&		BGG$=b$A!$DEFF%f-I
  '	<I  		s   1B 
B%$B%c                 h    [         R                  " U 5      =(       d    [         R                  " U 5      $ r8   )inspect
isfunctionismethodthe_callables    r<   is_function_or_methodrw      s%     l+Mw/?/?/MMr?   c                     [        U 5      (       d  [        U 5      (       a  U R                  n [        U 5      (       a"  [        R                  " U 5      R
                  S L$ g)NF)rw   callable__call__rr   getfullargspecvarargsru   s    r<   	is_varargr}      sN     ..8L3I3I $,,\**%%l3;;4GGr?   c                    [        U [        5      (       a  U R                  n [        U 5      (       d6  [	        U 5      (       a&  [        U R
                  5      (       a  U R
                  n [        U 5      (       aF  [        U 5      (       a  [        R                  " U 5      n [        R                  " U 5      R                  $ [        U5       Vs/ s H  n[        U5      PM     sn$ s  snf r8   )ra   r3   rc   rw   ry   rz   r$   rr   unwrapr{   argsrangestr)rh   n_argsis      r<   get_param_namesr      s    "&''UU ""%%RLL!"++.. [[R  #B%%b)... !&f.1A...s   C#c                     [        SR                  [        U 5      S   5      5      nUc  g [
        R                  " U5      n[        UR                  5      S:X  aq  [        UR                  S   [
        R                  5      (       aE  [        R                  R                  R                  USUR                  S   R                   S35      e[        UR                  5      S:w  d,  [        UR                  S   [
        R                   5      (       d*  [        R                  R                  R                  US5      eg ! [        [        4 a     g f = f)Nr`   r   r.   zCannot instantiate class 'z' in a script functionz$Expected a single top-level function)r   rd   r-   OSErrorrf   astparselenbodyra   ClassDefrO   jitfrontendFrontendErrorr9   FunctionDef)rh   ri   ro   py_asts       r<   check_fnr      s    9" =a @AB ~YYvF
6;;1FKKNCLL!I!Iii  ..(Q)<)<(==ST
 	
 6;;1Jv{{1~s$O$Oii  ..7
 	
 %P Y s   &D< <EEc                     [        U SSS9n[        R                  " U5       H"  nSUR                  ;   d  M  [	        SU  S35      e   [        X1U5      $ )zLEvaluate statement as long as it does not contain any method/function calls.r`   eval)modeCALLz/Type annotation should not contain calls, but 'z' does)compiledisget_instructionsopnamerB   r   )stmtglobri   bytecodeinsns        r<   _eval_no_callr      sY    tRf-H$$X.T[[ A$vN  /
 $$r?   c                    [        U 5      u  p4 [        U0 [        U5      5      n[        U[        5      (       d  U4n [        U0 [        U5      5      nU Vs/ s H  n[        X5      PM     n	nU	[        Xr5      4$ ! [        [        4 a  n[        S5      UeSnAff = f! [        [        4 a  n[        S5      UeSnAff = fs  snf )zParse a type annotation specified as a comment.

Example inputs:
    # type: (Tensor, torch.Tensor) -> 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_liner   rM   	NameErrorSyntaxErrorrB   ra   tupleann_to_type)
rn   rT   ri   arg_ann_strret_ann_strarg_anneret_annann	arg_typess
             r<   rg   rg      s      /y9KR> gu%%*R> 3::'3S&'I:k'///! {# D
	 {# B
	
 ;s4   A< B  C<BBB C0B<<Cc           
      b  ^^^ SmU R                  S5      n[        [        U5      5      n[        [        U4S jU5      5      n[        R
                  " S5      m[        [        U4S jU5      5      n[        U5      S:X  ae  [        R
                  " S5      m[        [        U4S jU5      5      n[        U5      S:  a&  [        S	[        US   S   5      -   S
-   S-   S-   5      eg[        U5      S:X  a  US   S   R                  5       $ Sn/ nU H)  u  pgSU;   a  Xg4n  OTU;   d  M  UR                  U5        M+     Uc3  [        SSR                  U Vs/ s H  owS   PM	     sn5      -   S-   5      eU4S jn[        X5      n	SR                  U	5      n
US   R                  SU
5      $ s  snf )zCTry to find the line containing a comment with the type annotation.# type:
c                    > TU S   ;   $ Nr.   rK   )linetype_comments    r<   <lambda>get_type_line.<locals>.<lambda>   s    ,$q'*Ar?   z!# type:\ ignore(\[[a-zA-Z-]+\])?$c                 6   > TR                  U S   5      (       + $ r   search)r   type_patterns    r<   r   r     s    l.A.A$q'.J*Jr?   r   z&#[	 ]*type[	 ]*(?!: ignore(\[.*\])?$):c                 ,   > TR                  U S   5      $ r   r   )r   wrong_type_patterns    r<   r   r   
  s     2 9 9$q' Br?   zThe 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)c                 b   > X R                  T5      [        T5      -   S  nUR                  5       $ r8   )findr   strip)r   	item_typer   s     r<   get_parameter_type)get_type_line.<locals>.get_parameter_type+  s.    <03|3DDFG	  r?   z, z...)splitlist	enumeratefilterrer   r   rB   r   r   appendrd   mapreplace)ro   lines
type_lineswrong_type_linesreturn_lineparameter_type_linesline_numr   r   typesparameter_typesr   r   r   s              @@@r<   re   re      s   LLLE5!"EfA5IJJ ::DELfJJWXJ
:!ZZ(TUBEJ
  1$0&q)!,-.?@ BB #	#  	ZA	!}Q%%'' K$$&#*KT! ''- % 1iiZ8ZTaZ89: ~~
 	
! "9Eii&Oq>!!%99 9s   F,c                     [        S5      n U R                  S5      nXU R	                  5       XS-   S R	                  5       4$ ! [         a    [        S5      Sef = f)a  Split 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]")

r   z->z4Syntax error in type annotation (couldn't find `->`)N   )r   index
ValueErrorrB   r   )rn   start_offset	arrow_poss      r<   r   r   5  sq     y>LOOD)	
 ),224iA6P6V6V6XXX	  B
	s   A Ac                   ^  [         R                  " U 5      mTR                  /TR                  R                  5        Vs/ s H  o"R                  PM     sn-   n[        U4S jU 5       5      (       a  gTR                  R                  5        Vs/ s H  n[        UR                  U5      PM     nn[        TR                  U5      nXE4$ ! [         a     gf = fs  snf s  snf )z8Try to use the Py3.5+ annotation syntax to get the type.Nc              3   >   >#    U  H  oTR                   L v   M     g 7fr8   )empty).0r   sigs     r<   	<genexpr>'try_real_annotations.<locals>.<genexpr>V  s     
2z#))zs   )	rr   rk   r   return_annotation
parametersvalues
annotationallr   )rh   ri   p
all_annotsr   rm   r   s         @r<   rb   rb   I  s     # ''(!nn335,55, J 
2z
2229<9N9N9PQ9PAQ\\3/9PIQc33S9K!!  , Rs   C C C"
CCr   c                 f   [        U 5      nU(       d  [        SU R                   S35      eU Vs1 s H  n[        UR                  5      iM     nnU Vs/ s H  n[        XQ5      PM     nn[        R                  R                  U5      nU(       d  [        R                  " 5       $ U$ s  snf s  snf )NzNo enum values defined for: '')r   r   	__class__typevaluetry_ann_to_typerO   _Cunify_type_listr   get)r   ri   enum_valuesvr   tir_typesress           r<   get_enum_value_typer   `  s    #'7K8QGHH$/0KqT!'']KE0167A'H7 ((
"
"8
,C{{}J 17s   B)B.c                    [        U [        R                  5      (       a  g[        U [        R                  [        R                  [        R
                  [        R                  [        R                  [        R                  [        R                  [        R                  [        R                  4	5      (       a  [        R                  " S5        gg)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)
issubclassrO   rP   
LongTensorDoubleTensorFloatTensor	IntTensorShortTensor
HalfTensor
CharTensor
ByteTensor
BoolTensorwarningswarn)r   s    r<   	is_tensorr  r  s    #u||$$OO
	
  	H	

 r?   c                     g r8   rK   )inps    r<   	_fake_rcbr    s    r?   c           	         [         R                  " U 5      nU [        R                  R                  L a  [
        R                  " 5       $ U c  [        R                  " 5       $ [        R                  " U 5      (       a%  [        U 5      (       a  [
        R                  " 5       $ [        U 5      (       aH  [        U5      S:X  a  US   S:X  a  [        / 5      $ [        U Vs/ s H  n[        XA5      PM     sn5      $ [        U 5      (       a!  [        US   U5      nU(       a  [!        U5      $ [#        U 5      (       as  [        US   U5      n[        US   U5      nUc"  [%        SUS    SUR'                  5        35      eUc"  [%        SUS    SUR'                  5        35      e[)        Xg5      $ [+        U 5      (       az  [-        US   [/        S 5      5      (       a  US   nOUS   n[        X5      n	Sn
U	(       d3   U
R1                  [3        U 5      [3        U5      [3        U5      5      5       e[5        U	5      $ [7        U 5      (       a  [9        U5      [:        [<        [>        1:X  a  [@        R                  " 5       $ / n[         R                  " U 5       H  nUc$  URC                  [        R                  " 5       5        [        XA5      nSn
U(       d3   U
R1                  [3        U 5      [3        U5      [3        U5      5      5       eURC                  U5        M     [E        U5      $ [F        RH                  RJ                  RM                  5       (       a(  [O        U 5      (       a  [Q        [        US   U5      5      $ [S        U 5      (       a  [U        [        US   U5      5      $ [W        U 5      (       a6  U(       a  [        US   U5      O[X        R                  " 5       n[[        U5      $ U [<        L a  [\        R                  " 5       $ U [>        L a  [^        R                  " 5       $ U [:        L d  U [F        R`                  L a  [b        R                  " 5       $ U [d        L a  [f        R                  " 5       $ U [h        L a  [j        R                  " 5       $ U [l        L a  [X        R                  " 5       $ U [/        S 5      L a  [        R                  " 5       $ [        R                  " U 5      (       a&  [o        U S5      (       a  [q        U Rr                  5      $ U [F        Rt                  L a  [v        R                  " 5       $ U [F        Rx                  L a  [z        R                  " 5       $ U [F        R|                  L a  [~        R                  " 5       $ U [F        R                  L a  [b        R                  " 5       $ [        R                  " U 5      (       a  [-        U [        R                  5      (       ap  [        U 5      c:  [F        R                  R                  R                  X5      nUR                  5       nO[        U 5      n[        U[        X5      [        U 5      5      $ [        R                  " U 5      (       a]  [        U 5      nUb  U$ [F        R                  R                  U 5      (       a)  [F        R                  R                  R                  X5      $ Uc  [        n[F        R                  R                  XU5      $ s  snf )Nr.   r   rK   Unknown type annotation: '' at zWUnsupported annotation {} could not be resolved because {} could not be resolved. At
{}__torch_script_interface__)QrQ   get_argsrr   	Signaturer   r   getInferredr   r   isclassr  r'   r   r   r   r%   r   r"   r   	highlightr
   r&   r   r   formatreprr   r(   setintfloatcomplexr   r   r   rO   rU   rV   rW   r1   r0   r#   r   r!   r   r   r   r   SymIntr   r   r   boolr   r   hasattrr   r	  devicer	   	Generatorr   Streamr   dtypeenumEnumr/   r   _script_recursive_compile_classqualified_namer   r   r   r   _jit_internalcan_compile_classr  r   _resolve_type_from_object)r   ri   rT   ann_argsa	elem_typekeyr   	contained
valid_typemsginner
maybe_typeelementTypescripted_classr9   maybe_script_classs                    r<   r   r     s/   s#H
g%%%%%''
{||~s	#~~}}x=A(1+"3R= 8D8a/!18DEEs||#HQK5	I&&s||hqk3/S1;,Xa[Ms}}>OP  =,Xa[Ms}}>OP  ##3hqk4:.. I I$Y4
hL3::d3ii$s)LLzJ''}}x=S%11>>## %AyX\\^,(0JlCQszz$s)T*5EtCyQQ:LL$ & ))++S9::~~/(1+s;<<}};Cohqk37%%
e|}}
g~  
czSELL({{}
cz~~
d{||~
cz{{}
d4j||~s-I J JS;;<<
ell  ""
eoo!!##
ell  ""
ekk{{}s
3		 : :S!)"YY..GGQN!002D"3'D1#;T#YGGs.s3)%%005599$$==cGG {88--c<<w Es   [<c                 b    [        XU5      nUb  U$ [        SU  SUR                  5        35      e)Nr  r  )r   r   r  )r   ri   rT   the_types       r<   r   r     s9    s-H
1#eCMMO;LM
NNr?   )r   r)   r   r   r   r+   r'   r%   r   r"   r&   r(   r   r   r   r   r   r   r   r
   r   r5   rp   r   r   rg   re   r   rb   r   r   r8   )Vr   r\   r   r  rr   r   rQ   r   textwrapr   rO   torch._Cr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   torch._jit_internalr   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   torch._sourcesr-   _stater/   rU   rV   rW   r0   r1   r2   
torch._opsr3   r5   rM   rp   rw   r}   r   r   r   rg   re   r   rb   r   r  r   r  r  r   r   __all__rK   r?   r<   <module>r9     s	   
  
   	         .     , 5 % 	%%''!1 ' - -6:N	/,
*%0<@:FY(".4		? $8h=VO"r?   