
    HЦiE                     ^   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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/J0r0J1r1J2r2J3r3J4r4J5r5J6r6  S SK7J8r8  SSK9J:r:  \Rv                  Rx                  R{                  5       (       a  S S	KJ>r>  S S
K"J?r?J@r@  S SKAJBrB   " S S5      rC " S S5      rDS rES rFS rGS rHS rIS rJS rKS rLS rMS rNS\
\R                     4S jrPS rQS rRS!S jrSS!S jrT/ S QrUg)"    N)dedent)Type)_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)ModuleG   c                     Xl         X l        g N)namemembers)selfr:   r;   s      T/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/torch/jit/annotations.py__init__Module.__init__H   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RuntimeErrorr:   r<   r:   s     r=   __getattr__Module.__getattr__L   sJ    	<<%% 	$))$:4&A	s    '8)r;   r:   N)__name__
__module____qualname____firstlineno__r>   rE   __static_attributes__ r@   r=   r6   r6   G   s    r@   r6   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
)EvalEnvU   torchTensortypingr,   )
rP   rQ   rR   r,   r*   r    r+   r-   r!   Awaitc                     Xl         [        R                  R                  R	                  5       (       a  [
        U R                  S'   g g )Nr3   )rcbrP   distributedrpcis_availabler3   env)r<   rU   s     r=   r>   EvalEnv.__init__c   s5      --//#DHHV 0r@   c                     XR                   ;   a  U R                   U   $ U R                  b  U R                  U5      $ [        [        US 5      $ r9   )rY   rU   getattrbuiltinsrD   s     r=   __getitem__EvalEnv.__getitem__h   sA    8888D>!8888D>!xt,,r@   )rU   N)rG   rH   rI   rJ   r6   rP   rQ   r,   r*   r    r+   r-   r!   r   rY   r>   r^   rK   rL   r@   r=   rN   rN   U   sQ    (ELL!9:,,GU#34C$
-r@   rN   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   )

isinstancer4   try_real_annotationsopr   joinr.   get_type_line	TypeErrorparse_type_line)	fnrU   loc	is_method	signatureparam_typesreturn_type	type_linesources	            r=   get_signaturerq   p   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      $ r9   )inspect
isfunctionismethodthe_callables    r=   is_function_or_methodrx      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)rx   callable__call__rs   getfullargspecvarargsrv   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 r9   )rb   r4   rd   rx   rz   r{   r%   rs   unwrapr|   argsrangestr)ri   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)Nra   r   r/   zCannot instantiate class 'z' in a script functionz$Expected a single top-level function)r   re   r.   OSErrorrg   astparselenbodyrb   ClassDefrP   jitfrontendFrontendErrorr:   FunctionDef)ri   rj   rp   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.ra   eval)modeCALLz/Type annotation should not contain calls, but 'z' does)compiledisget_instructionsopnamerC   r   )stmtglobrj   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   rN   	NameErrorSyntaxErrorrC   rb   tupleann_to_type)
ro   rU   rj   arg_ann_strret_ann_strarg_anneret_annann	arg_typess
             r=   rh   rh      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/   rL   )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       $ r9   )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   rC   r   r   appendre   mapreplace)rp   lines
type_lineswrong_type_linesreturn_lineparameter_type_linesline_numr   r   typesparameter_typesr   r   r   s              @@@r=   rf   rf      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
ValueErrorrC   r   )ro   start_offset	arrow_poss      r=   r   r   6  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r9   )empty).0r   sigs     r=   	<genexpr>'try_real_annotations.<locals>.<genexpr>W  s     
2z#))zs   )	rs   rl   r   return_annotation
parametersvalues
annotationallr   )ri   rj   p
all_annotsr   rn   r   s         @r=   rc   rc   J  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_typerP   _Cunify_type_listr   get)r   rj   enum_valuesvr   tir_typesress           r=   get_enum_value_typer   a  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)
issubclassrP   rQ   
LongTensorDoubleTensorFloatTensor	IntTensorShortTensor
HalfTensor
CharTensor
ByteTensor
BoolTensorwarningswarn)r   s    r=   	is_tensorr  s  s    #u||$$OO
	
  	H	

 r@   c                     g r9   rL   )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   rL   Unknown type annotation: '' at zWUnsupported annotation {} could not be resolved because {} could not be resolved. At
{}__torch_script_interface__)QrR   get_argsrs   	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   rP   rV   rW   rX   r2   r1   r$   r   r"   r   r   r   r	   SymIntr   r   r   boolr   r   hasattrr   r
  devicer
   	Generatorr   Streamr   dtypeenumEnumr0   r   _script_recursive_compile_classqualified_namer   r   r   r   _jit_internalcan_compile_classr  r   _resolve_type_from_object)r   rj   rU   ann_argsa	elem_typekeyr   	contained
valid_typemsginner
maybe_typeelementTypescripted_classr:   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   rj   rU   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   r6   rq   r   r   rh   rf   r   rc   r   r   r9   )Vr   r]   r   r  rs   r   rR   r  textwrapr   r   rP   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.   _stater0   rV   rW   rX   r1   r2   r3   
torch._opsr4   r6   rN   rq   rx   r~   r   r   r   rh   rf   r   rc   r  r   r  r  r   r   __all__rL   r@   r=   <module>r:     s   
  
   	          .     , 5 % 	%%''!1 ' - -6:N	/,
*%0<@:FY(".4		? $8h=VO"r@   