
    9i                        S r SSKrSSKrSSKrSSKJrJrJrJrJ	r	  SSK
JrJrJrJr  SSKJr  SSKJrJr  \(       a  SSKJr  \R,                  \R.                  \R0                  \R2                  \R.                  \R.                  \R2                  \R2                  \R4                  \R4                  \R6                  \R6                  \R8                  \R8                  \R:                  \R:                  \R<                  \R<                  \R>                  \R>                  0
r \R,                  \R4                  \R0                  \R6                  \R4                  \R4                  \R6                  \R6                  \R.                  \R4                  \R2                  \R6                  \R8                  \R8                  \R:                  \R:                  \R<                  \R<                  \R>                  \R>                  0
r!\R,                  \R8                  \R0                  \R:                  \R4                  \R8                  \R6                  \R:                  \R.                  \R8                  \R2                  \R:                  \R8                  \R8                  \R:                  \R:                  \R<                  \R<                  \R>                  \R>                  0
r"\R,                  \R<                  \R0                  \R>                  \R.                  \R<                  \R2                  \R>                  \R<                  \R<                  \R>                  \R>                  \R4                  \R<                  \R6                  \R>                  \R8                  \R<                  \R:                  \R>                  0
r#S	\S
\$4S jr%S	\S
\&4S jr'\RP                  " SS9 " S S\5      5       r)\RP                  " SS9 " S S\5      5       r*\RP                  " SS9 " S S\5      5       r+\RP                  " SS9 " S S\5      5       r,\RP                  " SS9 " S S\5      5       r-\RP                  " SS9 " S S\5      5       r.\RP                  " SS9 " S S\.5      5       r/\RP                  " SS9 " S S\5      5       r0\RP                  " SS9 " S S \5      5       r1\RP                  " SS9 " S! S"\5      5       r2\RP                  " SS9 " S# S$\5      5       r3\RP                  " SS9 " S% S&\5      5       r4\RP                  " SS9 " S' S(\5      5       r5\RP                  " SS9 " S) S*\5      5       r6\RP                  " SS9 " S+ S,\5      5       r7\RP                  " SS9 " S- S.\05      5       r8\RP                  " SS9 " S/ S0\05      5       r9\RP                  " SS9 " S1 S2\5      5       r:\RP                  " SS9 " S3 S4\5      5       r; " S5 S6\Rx                  5      r=\RP                  " SS9 " S7 S8\5      5       r>\RP                  " SS9 " S9 S:\5      5       r?\RP                  " SS9 " S; S<\5      5       r@\RP                  " SS9 " S= S>\5      5       rA\RP                  " SS9 " S? S@\5      5       rB\RP                  " SS9 " SA SB\5      5       rC " SC SD\5      rD\RP                  " SS9 " SE SF\5      5       rE\RP                  " SS9 " SG SH\5      5       rF\RP                  " SS9 " SI SJ\5      5       rG\RP                  " SS9 " SK SL\5      5       rH\RP                  " SS9 " SM SN\5      5       rI\RP                  " SS9 " SO SP\5      5       rJ\RP                  " SS9 " SQ SR\F5      5       rK\RP                  " SS9 " SS ST\F5      5       rL\RP                  " SS9 " SU SV\5      5       rM\RP                  " SS9 " SW SX\5      5       rN\RP                  " SS9 " SY SZ\5      5       rO\RP                  " SS9 " S[ S\\5      5       rP\RP                  " SS9 " S] S^\5      5       rQ\RP                  " SS9 " S_ S`\Q5      5       rR\RP                  " SS9 " Sa Sb\R5      5       rS\RP                  " SS9 " Sc Sd\Q5      5       rT\RP                  " SS9 " Se Sf\5      5       rU\RP                  " SS9 " Sg Sh\5      5       rV\RP                  " SS9 " Si Sj\5      5       rW\RP                  " SS9 " Sk Sl\5      5       rX\RP                  " SS9 " Sm Sn\5      5       rY\RP                  " SS9 " So Sp\5      5       rZ\RP                  " SS9 " Sq Sr\5      5       r[\RP                  " SS9 " Ss St\5      5       r\\RP                  " SS9 " Su Sv\5      5       r]\RP                  " SS9 " Sw Sx\5      5       r^SySz.S	\S{\$S
\\&   4S| jjr_SySz.S	\S{\$S
\$4S} jjr`S	\S
\$4S~ jraS	\S
\\&   4S jrbS	\S
\$4S jrcS	\S
\$4S jrdS	\S\S
\$4S jre\R                  S	\S
\$4S j5       rg\R                  S	\S
\$4S j5       rh\R                  S	\S
\$4S j5       ri\R                  S	\S
\$4S j5       rj\R                  S	\S
\$4S j5       rk\R                  S	\S
\$4S j5       rl\R                  S	\S
\$4S j5       rmg)a  
This module provides Source classes that track the origins of values in PyTorch Dynamo.
Sources represent where values come from (e.g. local variables, globals, attributes) and
are used for guard generation and code reconstruction during compilation.

The module includes specialized sources for:
- Local variables and synthetic locals
- Global variables and constants
- Object attributes and method calls
- NN module specialization (specialized vs unspecialized)
- Random values and tensor properties
- Default argument handling
- FSDP (Fully Sharded Data Parallel) modules

Sources play a key role in Dynamo's guard system by tracking value origins for
guard generation, and in code reconstruction by providing methods to rebuild
the code needed to recreate values.
    N)AnyCallableOptionalTYPE_CHECKINGUnion)ChainedSourceGuardGuardSourceSource   )utils)create_call_functioncreate_instruction)	PyCodegensourcereturnc                     [        U [        5      (       a  g U R                  5       [        R                  :X  a  g g! [
         a     gf = fNTF)
isinstanceConstantSourceguard_sourcer
   CONSTANTNotImplementedErrorr   s    T/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/torch/_dynamo/source.pyis_constant_sourcer   a   sR    &.)) K$8$88 9
   s   "= 
A
	A
c                 D     U R                  5       $ ! [         a     gf = f)Nz<unknown source>)namer   r   s    r   _get_source_debug_namer   m   s%    "{{} "!"s    
T)frozenc                   |    \ rS rSr% \\S'   Sr\\S'   Sr\	\
\      \S'   Sr\\S'   SS	 jrS\4S
 jrS\4S jrSrg)LocalSourcet   
local_nameFis_inputNdynamismis_derefed_cell_contentsr   c                     U R                   (       a  UR                  U R                  5        g UR                  UR	                  U R                  5      5        g N)r'   
load_derefr$   append_outputcreate_loadselfcodegens     r   reconstructLocalSource.reconstruct   s:    ((t/!!'"5"5doo"FG    c                 "    [         R                  $ r)   )r
   LOCALr.   s    r   r   LocalSource.guard_source   s       r2   c                 4    S[        U R                  5       S3$ )NzL[])reprr$   r5   s    r   r   LocalSource.name   s    D)*!,,r2    r/   r   r   N)__name__
__module____qualname____firstlineno__str__annotations__r%   boolr&   r   	frozensetr'   r0   r
   r   r   __static_attributes__r;   r2   r   r"   r"   t   sS    O Hd *.Hhy~&-
 &+d*H!k !-c -r2   r"   c                   F    \ rS rSr% \\S'   S	S jrS\4S jrS\4S jr	Sr
g)
SyntheticLocalSource   r$   r   Nc                 X    UR                  UR                  U R                  5      5        g r)   )r+   r,   r$   r-   s     r   r0    SyntheticLocalSource.reconstruct   s    g11$//BCr2   c                 "    [         R                  $ r)   )r
   SYNTHETIC_LOCALr5   s    r   r   !SyntheticLocalSource.guard_source   s    ***r2   c                 $    SU R                   < S3$ )NzSYNTHETIC_LOCAL[r8   )r$   r5   s    r   r   SyntheticLocalSource.name   s    !$//!4A66r2   r;   r<   r=   r>   r?   r@   rA   rB   r0   r
   r   r   rE   r;   r2   r   rG   rG      s%    OD+k +7c 7r2   rG   c                   F    \ rS rSr% \\S'   S\4S jrS	S jrS\	4S jr
Srg)
RandomValueSource   random_call_indexr   c                 "    [         R                  $ r)   )r
   RANDOM_VALUEr5   s    r   r   RandomValueSource.guard_source   s    '''r2   Nc                    UR                  UR                  UR                  R                  R                  5      5        UR                  UR                  U R                  5      5        UR                  [        S5      5        g NBINARY_SUBSCR)r+   r,   txoutputrandom_values_varcreate_load_constrT   r   r-   s     r   r0   RandomValueSource.reconstruct   s^    g11'**2C2C2U2UVWg778N8NOP0ABr2   c                      SU R                    3$ )Nrandom_value_)rT   r5   s    r   r   RandomValueSource.name   s    t55677r2   r;   r<   )r=   r>   r?   r@   intrB   r
   r   r0   rA   r   rE   r;   r2   r   rR   rR      s&    (k (C
8c 8r2   rR   c                   F    \ rS rSr% \\S'   S	S jrS\4S jrS\4S jr	Sr
g)
GlobalSource   global_namer   Nc                 V    UR                  UR                  U R                  SS95        g NTaddr+   create_load_globalrg   r-   s     r   r0   GlobalSource.reconstruct   s&    g889I9It8TUr2   c                 "    [         R                  $ r)   r
   GLOBALr5   s    r   r   GlobalSource.guard_source       !!!r2   c                 4    S[        U R                  5       S3$ )NG[r8   r9   rg   r5   s    r   r   GlobalSource.name   s    D))*+1--r2   r;   r<   rP   r;   r2   r   re   re      s&    V"k ".c .r2   re   c                   F    \ rS rSr% \\S'   S	S jrS\4S jrS\4S jr	Sr
g)
GlobalWeakRefSource   rg   r   Nc                 j   ^ ^ TR                  UU 4S j5        TR                  [        SS5      5        g )Nc                  V   > T R                  T R                  TR                  SS95      $ ri   rl   r/   r.   s   r   <lambda>1GlobalWeakRefSource.reconstruct.<locals>.<lambda>   s)    G))**4+;+;*Fr2   r   Fadd_push_nullextend_outputr   r-   s   ``r   r0   GlobalWeakRefSource.reconstruct   s.    	

 	21e<=r2   c                 "    [         R                  $ r)   rp   r5   s    r   r    GlobalWeakRefSource.guard_source   rs   r2   c                 4    S[        U R                  5       S3$ )Nru   z]()rv   r5   s    r   r   GlobalWeakRefSource.name   s    D))*+3//r2   r;   r<   rP   r;   r2   r   ry   ry      s%    >"k "0c 0r2   ry   c                   :    \ rS rSrSS jrS\4S jrS\4S jrSr	g)	WeakRefCallSource   r   Nc                 j   ^ ^ TR                  UU 4S j5        TR                  [        SS5      5        g )Nc                  (   > T " TR                   5      $ r)   baser}   s   r   r~   /WeakRefCallSource.reconstruct.<locals>.<lambda>   s    gdii&8r2   r   Fr   r-   s   ``r   r0   WeakRefCallSource.reconstruct   s(    8921e<=r2   c                 6    U R                   R                  5       $ r)   r   r   r5   s    r   r   WeakRefCallSource.guard_source       yy%%''r2   c                 <    U R                   R                  5        S3$ )Nz()r   r   r5   s    r   r   WeakRefCallSource.name   s    )).."#2&&r2   r;   r<   
r=   r>   r?   r@   r0   r
   r   rA   r   rE   r;   r2   r   r   r      s    >(k ('c 'r2   r   c                       \ rS rSrSrg)CallFunctionNoArgsSource   r;   Nr=   r>   r?   r@   rE   r;   r2   r   r   r          r2   r   c                   P    \ rS rSr% \\S'   S
S jrSS jrS\4S jr	S\4S jr
S	rg)
AttrSource   memberr   Nc                 :   U R                   (       d   S5       eSU R                  ;   as  U R                  R                  S5      n[        R	                  U S[        U R                   SR                  US S 5      5      5        [        R	                  U SUS   5        g g Nz9Can't construct an AttrSource without a valid base source.r   r   r   r   splitobject__setattr__r   joinr.   member_partss     r   __post_init__AttrSource.__post_init__       yyUUUy$++;;,,S1LfjCHH\#2=N4OP tX|B/?@ r2   c                 |    U" U R                   5        UR                  UR                  U R                  5      5        g r)   r   r   create_load_attrsr   r-   s     r   r0   AttrSource.reconstruct   +    		g77DEr2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   AttrSource.guard_source   r   r2   c                     U R                   R                  5       (       d,  SU R                  R                  5        SU R                   < S3$ U R                  R                  5        SU R                    3$ )Nzgetattr(, )r   )r   isidentifierr   r   r5   s    r   r   AttrSource.name   s[    {{''))diinn./r$++BB)).."#1T[[M22r2   r;   r   Nr<   r=   r>   r?   r@   rA   rB   r   r0   r
   r   r   rE   r;   r2   r   r   r      s+    KAF(k (3c 3r2   r   c                   P    \ rS rSr% \\S'   S
S jrSS jrS\4S jr	S\4S jr
S	rg)GenericAttrSource   r   r   Nc                 :   U R                   (       d   S5       eSU R                  ;   as  U R                  R                  S5      n[        R	                  U S[        U R                   SR                  US S 5      5      5        [        R	                  U SUS   5        g g r   r   r   s     r   r   GenericAttrSource.__post_init__   r   r2   c                 |    U" U R                   5        UR                  UR                  U R                  5      5        g r)   r   r-   s     r   r0   GenericAttrSource.reconstruct	  r   r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   GenericAttrSource.guard_source  r   r2   c                 Z    SU R                   R                  5        SU R                  < S3$ )Nzobject.__getattribute__(r   r   r   r   r   r5   s    r   r   GenericAttrSource.name  s'    )$))..*:);2dkk_ANNr2   r;   r   r<   r   r;   r2   r   r   r      s-    KAF(k (Oc Or2   r   c                   :    \ rS rSrSS jrS\4S jrS\4S jrSr	g)	TypeDictSourcei  r   Nc                 h    U" U R                   5        UR                  UR                  S5      5        g )N__dict__r   r   r   r-   s     r   r0   TypeDictSource.reconstruct  '    		g77
CDr2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   TypeDictSource.guard_source  r   r2   c                 >    SU R                   R                  5        S3$ )Nzdict(z
.__dict__)r   r5   s    r   r   TypeDictSource.name  s    
 tyy~~'(
33r2   r;   r<   r   r;   r2   r   r   r     s     E(k (4c 4r2   r   c                   :    \ rS rSrSS jrS\4S jrS\4S jrSr	g)	TypeMROSourcei'  r   Nc                 h    U" U R                   5        UR                  UR                  S5      5        g )N__mro__r   r-   s     r   r0   TypeMROSource.reconstruct)  '    		g77	BCr2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   TypeMROSource.guard_source-  r   r2   c                 <    U R                   R                  5        S3$ )Nz.__mro__r   r5   s    r   r   TypeMROSource.name0  s    )).."#8,,r2   r;   r<   r   r;   r2   r   r   r   '  s     D(k (-c -r2   r   c                   .    \ rS rSr% Sr\\S'   SS jrSrg)LocalCellSourcei4  zw
Conceptually, this class is `LocalSource` for cell objects implicitly
generated by Python (e.g., captured variables).
r$   Nc                 X    UR                  UR                  U R                  5      5        g r)   )r+   create_load_closurer$   r-   s     r   r0   LocalCellSource.reconstruct=  s!     	g99$//JKr2   r;   r<   )	r=   r>   r?   r@   __doc__rA   rB   r0   rE   r;   r2   r   r   r   4  s    
 OLr2   r   c                   :    \ rS rSrSS jrS\4S jrS\4S jrSr	g)	
CodeSourceiH  r   Nc                 h    U" U R                   5        UR                  UR                  S5      5        g )N__code__r   r-   s     r   r0   CodeSource.reconstructJ  r   r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   CodeSource.guard_sourceN  r   r2   c                 <    U R                   R                  5        S3$ )Nz	.__code__r   r5   s    r   r   CodeSource.nameQ  s    )).."#9--r2   r;   r<   r   r;   r2   r   r   r   H  s     E(k (.c .r2   r   c                   :    \ rS rSrSS jrS\4S jrS\4S jrSr	g)	ClosureSourceiV  r   Nc                 h    U" U R                   5        UR                  UR                  S5      5        g )N__closure__r   r-   s     r   r0   ClosureSource.reconstructX  s'    		g77FGr2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   ClosureSource.guard_source\  r   r2   c                 <    U R                   R                  5        S3$ )Nz.__closure__r   r5   s    r   r   ClosureSource.name_  s    )).."#<00r2   r;   r<   r   r;   r2   r   r   r   V  s     H(k (1c 1r2   r   c                   J    \ rS rSr% Sr\\S'   S
S jrS\4S jr	S\4S jr
S	rg)
GradSourceig  gradr   r   Nc                 |    U" U R                   5        UR                  UR                  U R                  5      5        g r)   r   r-   s     r   r0   GradSource.reconstructk  r   r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   GradSource.guard_sourceo  r   r2   c                 T    U R                   R                  5        SU R                   3$ )Nr   r   r5   s    r   r   GradSource.namer  s#    )).."#1T[[M22r2   r;   r<   )r=   r>   r?   r@   r   rA   rB   r0   r
   r   r   rE   r;   r2   r   r   r   g  s*    FCF(k (3c 3r2   r   c                   "    \ rS rSrS\4S jrSrg)ParamBufferSourceiv  r   c                 D    [         U R                  R                  5          $ r)   #_GUARD_SOURCE_SPECIALIZED_NN_MODULEr   r   r5   s    r   r   ParamBufferSource.guard_sourcex      24993I3I3KLLr2   r;   Nr=   r>   r?   r@   r
   r   rE   r;   r2   r   r  r  v  s    Mk Mr2   r  c                       \ rS rSrSrg)UnspecializedParamBufferSourcei}  r;   Nr   r;   r2   r   r	  r	  }  r   r2   r	  c                   p    \ rS rSr% Sr\\   \S'   S\4S jr	S\4S jr
S\S\4   S\4S	 jrS\4S
 jrSrg)EphemeralSourcei  Ndescr   c                 "    [         R                  $ r)   )r
   	EPHEMERALr5   s    r   r   EphemeralSource.guard_source      $$$r2   c                 L    SU R                   b  SU R                   -    S3$ S S3$ )Nz
<ephemeralz:  >)r  r5   s    r   r   EphemeralSource.name  s1    		0ED499,NaPP2NaPPr2   fn.c                     [         er)   r   r.   r  s     r   
make_guardEphemeralSource.make_guard      !!r2   c                     gNTr;   r5   s    r   is_ephemeralEphemeralSource.is_ephemeral      r2   r;   )r=   r>   r?   r@   r  r   rA   rB   r
   r   r   r   r   r	   r  rC   r  rE   r;   r2   r   r  r    sR    D(3-%k %Qc Q"Xc3h/ "E "d r2   r  c                   :    \ rS rSrSS jrS\4S jrS\4S jrSr	g)	SkipGuardSourcei  r   Nc                 :    U R                   R                  U5        g r)   )r   r0   r-   s     r   r0   SkipGuardSource.reconstruct  s    		g&r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   SkipGuardSource.guard_source  r   r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   SkipGuardSource.name      yy~~r2   r;   r<   r   r;   r2   r   r"  r"    s    '(k ( c  r2   r"  c                   .    \ rS rSrSrSrSrS\4S jrSr	g)	TensorPropertyi  r   r      r   c                     U [         R                  L a  gU [         R                  L a  gU [         R                  L a  g[	        SU  35      e)Nsizestridestorage_offset
unhandled )r+  SIZESTRIDESTORAGE_OFFSETAssertionErrorr5   s    r   method_nameTensorProperty.method_name  sG    >&&&^***^222# :dV!455r2   r;   N)
r=   r>   r?   r@   r2  r3  r4  rA   r6  rE   r;   r2   r   r+  r+    s    DFN6S 6r2   r+  c                   d    \ rS rSr% \\S'   Sr\\   \S'   SS jr	SS jr
S\4S jrS\4S	 jrS
rg)TensorPropertySourcei  propNidxr   c                     U R                   c   eU R                  [        R                  L a  U R                  b   eg U R                  c   eg r)   )r   r:  r+  r4  r;  r5   s    r   r   "TensorPropertySource.__post_init__  sD    yy$$$9955588###88'''r2   c                   ^ ^ TR                  UU 4S j5        T" T R                  5        T R                  b*  TR                  TR	                  T R                  5      5        TR                  [        T R                  b  SOSS5      5        g )Nc                  z   > T R                  [        R                  STR                  R	                  5        35      $ )Ncall_)load_import_fromr   r=   r:  r6  r}   s   r   r~   2TensorPropertySource.reconstruct.<locals>.<lambda>  s.    G,,%		(=(=(?'@ Ar2   r,  r   F)r   r   r;  r+   r^   r   r   r-   s   ``r   r0    TensorPropertySource.reconstruct  sn    	

 			88!!'";";DHH"EF dhh&:5I	
r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   !TensorPropertySource.guard_source  r   r2   c                    U R                   [        R                  L a*  U R                  R	                  5        SU R
                   S3$ U R                   [        R                  L a*  U R                  R	                  5        SU R
                   S3$ U R                   [        R                  L a,  U R
                  b   eU R                  R	                  5        S3$ [        SU R                    35      e)Nz.size()[r8   z
.stride()[z.storage_offset()r1  )	r:  r+  r2  r   r   r;  r3  r4  r5  r5   s    r   r   TensorPropertySource.name  s    99+++iinn&'xz;;YY.///iinn&'z$((1==YY.77788###iinn&''899 :dii[!9::r2   r;   r   r<   )r=   r>   r?   r@   r+  rB   r;  r   rc   r   r0   r
   r   rA   r   rE   r;   r2   r   r9  r9    s8    
C#(
(k (	;c 	;r2   r9  c                   P    \ rS rSr% \\S'   S
S jrSS jrS\4S jr	S\
4S jrS	rg)IndexedSourcei  r;  r   Nc                 "    U R                   c   eg r)   r   r5   s    r   r   IndexedSource.__post_init__      yy$$$r2   c                     [         er)   r  r-   s     r   r0   IndexedSource.reconstruct  r  r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   IndexedSource.guard_source  r   r2   c                 X    SU R                    SU R                  R                  5        S3$ )N(r   r   )r;  r   r   r5   s    r   r   IndexedSource.name  s'    488*Btyy~~/022r2   r;   r   r<   )r=   r>   r?   r@   rc   rB   r   r0   r
   r   rA   r   rE   r;   r2   r   rI  rI    s)    	H%"(k (3c 3r2   rI  c                   D    \ rS rSrS	S jrS
S jrS\4S jrS\4S jr	Sr
g)NegateSourcei  r   Nc                 "    U R                   c   eg r)   r   r5   s    r   r   NegateSource.__post_init__  rL  r2   c                     [         er)   r  r-   s     r   r0   NegateSource.reconstruct  r  r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   NegateSource.guard_source  r   r2   c                 <    U R                   R                  5        S3$ )Nz
.__neg__()r   r5   s    r   r   NegateSource.name  s    )).."#:..r2   r;   r   r<   r=   r>   r?   r@   r   r0   r
   r   rA   r   rE   r;   r2   r   rU  rU    s$    %"(k (/c /r2   rU  c                   D    \ rS rSrS	S jrS
S jrS\4S jrS\4S jr	Sr
g)ConvertIntSourcei  r   Nc                 "    U R                   c   eg r)   r   r5   s    r   r   ConvertIntSource.__post_init__  rL  r2   c                 (    U" U R                   5        g r)   r   r-   s     r   r0   ConvertIntSource.reconstruct      		r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   ConvertIntSource.guard_source
  r   r2   c                 >    SU R                   R                  5        S3$ )Nz!cast_symbool_to_symint_guardless(r   r   r5   s    r   r   ConvertIntSource.name  s    2499>>3C2DAFFr2   r;   r   r<   r^  r;   r2   r   r`  r`    s&    %(k (Gc Gr2   r`  c                   D    \ rS rSrS	S jrS
S jrS\4S jrS\4S jr	Sr
g)FlattenScriptObjectSourcei  r   Nc                 "    U R                   c   eg r)   r   r5   s    r   r   'FlattenScriptObjectSource.__post_init__  rL  r2   c                 (    U" U R                   5        g r)   r   r-   s     r   r0   %FlattenScriptObjectSource.reconstruct  re  r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   &FlattenScriptObjectSource.guard_source  r   r2   c                 <    U R                   R                  5        S3$ )Nz.__obj_flatten__()r   r5   s    r   r   FlattenScriptObjectSource.name  s    )).."##566r2   r;   r   r<   r^  r;   r2   r   rk  rk    s$    %(k (7c 7r2   rk  c                   D    \ rS rSrS	S jrS
S jrS\4S jrS\4S jr	Sr
g)ScriptObjectQualifiedNameSourcei   r   Nc                 "    U R                   c   eg r)   r   r5   s    r   r   -ScriptObjectQualifiedNameSource.__post_init__"  rL  r2   c                 (    U" U R                   5        g r)   r   r-   s     r   r0   +ScriptObjectQualifiedNameSource.reconstruct%  re  r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   ,ScriptObjectQualifiedNameSource.guard_source(  r   r2   c                 <    U R                   R                  5        S3$ )Nz._type().qualified_name()r   r5   s    r   r   $ScriptObjectQualifiedNameSource.name+  s    )).."##<==r2   r;   r   r<   r^  r;   r2   r   ru  ru     s$    %(k (>c >r2   ru  c                   :    \ rS rSrSS jrS\4S jrS\4S jrSr	g)	AttrProxySourcei/  r   Nc                 (    U" U R                   5        g r)   r   r-   s     r   r0   AttrProxySource.reconstruct0  re  r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   AttrProxySource.guard_source3  r   r2   c                 <    U R                   R                  5        S3$ )Nz.get_base()r   r5   s    r   r   AttrProxySource.name6  s    )).."#;//r2   r;   r<   r   r;   r2   r   r  r  /  s    (k (0c 0r2   r  c                       \ rS rSr% \\\4   \S'   Sr\	\S'   \
R                  " SSSS9r\\S'   \
R                  " SSSS9r\\S'   SS
 jrSS jrS\4S jrS\4S jrSrg	)DefaultsSourcei:  idx_keyFis_kw)initr9   comparefield_namer   Nc           
      h   U R                   (       d   S5       eU R                  (       a  [        U R                  [        5      (       d   e[
        R                  U SS5        [
        R                  U SU R                   R                  5        SU R                   SU R                   S35        g [        U R                  [        5      (       d   e[
        R                  U SS5        [
        R                  U SU R                   R                  5        SU R                   S	U R                   S
35        g )Nz]Base must be a valid source in order to properly track and guard this Defaults to its origin.r  __kwdefaults__r  r   z['z']__defaults__[r8   )
r   r  r   r  rA   r   r   r   r  rc   r5   s    r   r   DefaultsSource.__post_init__A  s    yy 	
k	
y ::dllC0000tW.>?g$)).."2!31TZZL4<<.PRS dllC0000tWn=g$)).."2!31TZZL$,,qQr2   c                    U" U R                   5        UR                  UR                  U R                  5      5        UR	                  UR                  U R                  5      5        UR	                  [        S5      5        g rY   )r   r   r   r  r+   r^   r  r   r-   s     r   r0   DefaultsSource.reconstructR  s\    		g77

CDg77EF0ABr2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   DefaultsSource.guard_sourceX  r   r2   c                     U R                   $ r)   )r  r5   s    r   r   DefaultsSource.name[  s    zzr2   r;   r   r<   )r=   r>   r?   r@   r   rc   rA   rB   r  rC   dataclassesr  r  r   r0   r
   r   r   rE   r;   r2   r   r  r  :  so    38_E4""E5IE3I""E5IE3I"C(k (c r2   r  c                   z   ^  \ rS rSr% \\S'   Sr\\S'   SU 4S jjrSS jr	S\
4S jrS\4S	 jrS\4S
 jrSrU =r$ )GetItemSourcei_  indexFindex_is_slicer   c                    > U R                   c   e[        U R                  [        5      (       a9  [        TU ]  SU R                  R                  5       5        [        TU ]  SS5        g g )Nr  r  T)r   r   r  slicesuperr   
__reduce__)r.   	__class__s    r   r   GetItemSource.__post_init__d  sU    yy$$$djj%((G)>)>)@AG 0$7 )r2   c                 0   U" U R                   5        U R                  (       a/  UR                  UR                  U R	                  5       5      5        O*UR                  UR                  U R
                  5      5        UR                  [        S5      5        g rY   )r   r  r+   r^   unpack_slicer  r   r-   s     r   r0   GetItemSource.reconstructk  sj    		!!'";";D<M<M<O"PQ!!'";";DJJ"GH0ABr2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   GetItemSource.guard_sources  r   r2   c                 N    U R                   (       d   eU R                  u  pU" U6 $ r)   )r  r  )r.   slice_class
slice_argss      r   r  GetItemSource.unpack_slicev  s(    """""&**J''r2   c                    [        U R                  [        5      (       a   eU R                  (       a/  U R                  R                  5        SU R                  5       < S3$ U R                  R                  5        SU R                  < S3$ Nr  r8   )r   r  r   r  r   r   r  r5   s    r   r   GetItemSource.name{  sp     djj&1111iinn&'q):):)<(?qAAiinn&'qa88r2   r;   r   r<   )r=   r>   r?   r@   r   rB   r  rC   r   r0   r
   r   r  r  rA   r   rE   __classcell__r  s   @r   r  r  _  sF    J ND 8C(k ((e (
9c 9 9r2   r  c                   T    \ rS rSr% \\S'   S\4S jrS
S jrS\	4S jr
S\4S jrS	rg)ConstDictKeySourcei  r  r   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   ConstDictKeySource.guard_source  r   r2   Nc                    ^ TR                  U4S j5        T" U R                  5        TR                  TR                  U R                  5      5        TR                  [        SS5      5        g )Nc                  D   > T R                  [        R                  S5      $ )Ndict_keys_getitemrA  r   r=   r/   s   r   r~   0ConstDictKeySource.reconstruct.<locals>.<lambda>  s    G,,U^^=PQr2   r,  Fr   r   r+   r^   r  r   r   r-   s    `r   r0   ConstDictKeySource.reconstruct  sU    Q	
 			g77

CD21e<=r2   c                 Z    SU R                   R                  5        SU R                  < S3$ )Nzlist(dict.keys(z))[r8   r   r   r  r5   s    r   r   ConstDictKeySource.name  s'     !1 2#djj^1EEr2   c                     gr  r;   r5   s    r   is_dict_keyConstDictKeySource.is_dict_key  r   r2   r;   r<   )r=   r>   r?   r@   r   rB   r
   r   r0   rA   r   rC   r  rE   r;   r2   r   r  r    s2    J(k (>Fc FT r2   r  c                   ^    \ rS rSr% \\S'   SS jrS\4S jrSS jr	S\
4S jrS\4S	 jrS
rg)NonSerializableSetGetItemSourcei  r  r   Nc                 T    SSK Jn  UR                  U R                  5      (       d   eg Nr   )ConstantVariable)	variablesr  
is_literalr  r.   r  s     r   r   -NonSerializableSetGetItemSource.__post_init__  s     /**4::6666r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   ,NonSerializableSetGetItemSource.guard_source  r   r2   c                    ^ TR                  U4S j5        T" U R                  5        TR                  TR                  U R                  5      5        TR                  [        SS5      5        g )Nc                  D   > T R                  [        R                  S5      $ )Nset_getitemr  r  s   r   r~   =NonSerializableSetGetItemSource.reconstruct.<locals>.<lambda>  s    G,,U^^]Kr2   r,  Fr  r-   s    `r   r0   +NonSerializableSetGetItemSource.reconstruct  sU    K	
 			g77

CD21e<=r2   c                 Z    SU R                   R                  5        SU R                  < S3$ )Nzlist(z)[r8   r  r5   s    r   r   $NonSerializableSetGetItemSource.name  s'    tyy~~'(4::.::r2   c                     g)NFr;   r5   s    r   r  +NonSerializableSetGetItemSource.is_dict_key  s    r2   r;   r   r<   )r=   r>   r?   r@   rc   rB   r   r
   r   r0   rA   r   rC   r  rE   r;   r2   r   r  r    s5    J7
(k (>;c ;T r2   r  c                   P    \ rS rSr% \\S'   S
S jrS\4S jrSS jr	S\
4S jrS	rg)DictGetItemSourcei  r  r   Nc                     SSK Jn  [        U R                  [        5      (       d#  UR                  U R                  5      (       d   eg g r  r  r  r   r  r  r  r  s     r   r   DictGetItemSource.__post_init__  C    /JJ*
 
((44	5 54
r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   DictGetItemSource.guard_source  r   r2   c                    U" U R                   5        [        U R                  [        5      (       a  U" U R                  5        O*UR	                  UR                  U R                  5      5        UR	                  [        S5      5        g rY   )r   r   r  r   r+   r^   r   r-   s     r   r0   DictGetItemSource.reconstruct  s^    		 djj&))DJJ!!'";";DJJ"GH0ABr2   c                    [        U R                  [        5      (       a8  U R                  R	                  5        SU R                  R	                  5        S3$ U R                  R	                  5        SU R                  < S3$ r  r   r  r  r   r   r5   s    r   r   DictGetItemSource.name  sb    djj"455iinn&'q):(;1==iinn&'qa88r2   r;   r   r<   r=   r>   r?   r@   r   rB   r   r
   r   r0   rA   r   rE   r;   r2   r   r  r    s,    
 J5(k (	C9c 9r2   r  c                   P    \ rS rSr% \\S'   S
S jrS\4S jrSS jr	S\
4S jrS	rg)DictSubclassGetItemSourcei  r  r   Nc                     SSK Jn  [        U R                  [        5      (       d#  UR                  U R                  5      (       d   eg g r  r  r  s     r   r   'DictSubclassGetItemSource.__post_init__  r  r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   &DictSubclassGetItemSource.guard_source  r   r2   c                 B  ^ TR                  U4S j5        T" U R                  5        [        U R                  [        5      (       a  T" U R                  5        O*TR                  TR                  U R                  5      5        TR                  [        SS5      5        g )Nc                  D   > T R                  [        R                  S5      $ )Ndict_getitemr  r  s   r   r~   7DictSubclassGetItemSource.reconstruct.<locals>.<lambda>      G,,U^^^Lr2   r,  F)	r   r   r   r  r   r+   r^   r   r   r-   s    `r   r0   %DictSubclassGetItemSource.reconstruct  sv     	L	

 			 djj&))DJJ!!'";";DJJ"GH21e<=r2   c                    [        U R                  [        5      (       a9  SU R                  R	                  5        SU R                  R	                  5        S3$ U R                  R	                  5        SU R                  < S3$ )Nzdict.__getitem__(r   r   r  r8   r  r5   s    r   r   DictSubclassGetItemSource.name  sd    djj"455&tyy~~'7&84::??;L:MQOOiinn&'qa88r2   r;   r   r<   r  r;   r2   r   r  r    s+    
 J5(k (>&9c 9r2   r  c                   0    \ rS rSrSrSS jrS\4S jrSrg)	ListGetItemSourcei
  zQ
Same as GetItemSource with reconstruct and name overridden to be list specific.
r   Nc                   ^ TR                  U4S j5        T" U R                  5        U R                  (       a  [        S5      eTR	                  TR                  U R                  5      5        TR                  [        SS5      5        g )Nc                  D   > T R                  [        R                  S5      $ )Nlist_getitemr  r  s   r   r~   /ListGetItemSource.reconstruct.<locals>.<lambda>  r  r2   >List[slice] is a temporary object and should not have a sourcer,  F)	r   r   r  RuntimeErrorr+   r^   r  r   r   r-   s    `r   r0   ListGetItemSource.reconstruct  st    
 	L	

 			 P  !!'";";DJJ"GH21e<=r2   c                     [        U R                  [        5      (       a   eU R                  (       a  [	        S5      eSU R
                  R                  5        SU R                  < S3$ )Nr  zlist.__getitem__(r   r   )r   r  r   r  r  r   r   r5   s    r   r   ListGetItemSource.name&  s[     djj&1111P  'tyy~~'7&84::.JJr2   r;   r<   )	r=   r>   r?   r@   r   r0   rA   r   rE   r;   r2   r   r  r  
  s    >,
Kc 
Kr2   r  c                   ,    \ rS rSrSS jrS\4S jrSrg)TupleIteratorGetItemSourcei3  r   Nc                    ^ TR                  U4S j5        T" U R                  5        TR                  TR                  U R                  5      5        TR                  [        SS5      5        g )Nc                  D   > T R                  [        R                  S5      $ )Ntuple_iterator_getitemr  r  s   r   r~   8TupleIteratorGetItemSource.reconstruct.<locals>.<lambda>7  s    G,,U^^=UVr2   r,  Fr  r-   s    `r   r0   &TupleIteratorGetItemSource.reconstruct5  sU    V	
 			g77

CD21e<=r2   c                 Z    SU R                   R                  5        SU R                  < S3$ )Nz___tuple_iterator_getitem(r   r   r  r5   s    r   r   TupleIteratorGetItemSource.name=  s'    +DIINN,<+=R

~QOOr2   r;   r<   )r=   r>   r?   r@   r0   rA   r   rE   r;   r2   r   r   r   3  s    >Pc Pr2   r   c                   :    \ rS rSrSS jrS\4S jrS\4S jrSr	g)	NamedTupleFieldsSourceiA  r   Nc                 h    U" U R                   5        UR                  UR                  S5      5        g )N_fieldsr   r-   s     r   r0   "NamedTupleFieldsSource.reconstructC  r   r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   #NamedTupleFieldsSource.guard_sourceG  r   r2   c                 >    SU R                   R                  5        S3$ )Nz___namedtuple_fields(r   r   r5   s    r   r   NamedTupleFieldsSource.nameJ  s    &tyy~~'7&8::r2   r;   r<   r   r;   r2   r   r	  r	  A  s     D(k (;c ;r2   r	  c                   :    \ rS rSrSS jrS\4S jrS\4S jrSr	g)	DataclassFieldsSourceiN  r   Nc                    ^ TR                  U4S j5        T" U R                  5        TR                  [        SS5      5        g )Nc                  D   > T R                  [        R                  S5      $ )Ndataclass_fieldsr  r  s   r   r~   3DataclassFieldsSource.reconstruct.<locals>.<lambda>R  s    G,,U^^=OPr2   r   Fr   r   r   r   r-   s    `r   r0   !DataclassFieldsSource.reconstructP  s8    P	
 			21e<=r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   "DataclassFieldsSource.guard_sourceW  r   r2   c                 >    SU R                   R                  5        S3$ )Nz___dataclass_fields(r   r   r5   s    r   r   DataclassFieldsSource.nameZ  s    %diinn&6%7q99r2   r;   r<   r   r;   r2   r   r  r  N  s    >(k (:c :r2   r  c                   D    \ rS rSrS	S jrS
S jrS\4S jrS\4S jr	Sr
g)
TypeSourcei^  r   Nc                 "    U R                   c   eg r)   r   r5   s    r   r   TypeSource.__post_init__`  rL  r2   c                    ^ TR                  U4S j5        T" U R                  5        TR                  [        SS5      5        g )Nc                  (   > T R                  SS5      $ )NbuiltinstyperA  r  s   r   r~   (TypeSource.reconstruct.<locals>.<lambda>d  s    g&>&>z6&Rr2   r   Fr  r-   s    `r   r0   TypeSource.reconstructc  s4    RS		21e<=r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   TypeSource.guard_sourceh  r   r2   c                 >    SU R                   R                  5        S3$ )Nztype(r   r   r5   s    r   r   TypeSource.namek  s    tyy~~'(**r2   r;   r   r<   r^  r;   r2   r   r  r  ^  s$    %>
(k (+c +r2   r  c                   :    \ rS rSrSS jrS\4S jrS\4S jrSr	g)	OptimizerSourceio  r   Nc                 (    U" U R                   5        g r)   r   r-   s     r   r0   OptimizerSource.reconstructq  re  r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   OptimizerSource.guard_sourcet  r   r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   OptimizerSource.namew  r)  r2   r;   r<   r   r;   r2   r   r-  r-  o  s    (k ( c  r2   r-  c                   :    \ rS rSrSS jrS\4S jrS\4S jrSr	g)	NNModuleSourcei{  r   Nc                 (    U" U R                   5        g r)   r   r-   s     r   r0   NNModuleSource.reconstruct}  re  r2   c                 D    [         U R                  R                  5          $ r)   r  r5   s    r   r   NNModuleSource.guard_source  r  r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   NNModuleSource.name  r)  r2   r;   r<   r   r;   r2   r   r5  r5  {  s!    Mk M c  r2   r5  c                   "    \ rS rSrS\4S jrSrg)UnspecializedNNModuleSourcei  r   c                 D    [         U R                  R                  5          $ r)   )%_GUARD_SOURCE_UNSPECIALIZED_NN_MODULEr   r   r5   s    r   r   (UnspecializedNNModuleSource.guard_source  s    4TYY5K5K5MNNr2   r;   Nr  r;   r2   r   r=  r=    s    Ok Or2   r=  c                   "    \ rS rSrS\4S jrSrg)"UnspecializedBuiltinNNModuleSourcei  r   c                 D    [         U R                  R                  5          $ r)   )-_GUARD_SOURCE_UNSPECIALIZED_BUILTIN_NN_MODULEr   r   r5   s    r   r   /UnspecializedBuiltinNNModuleSource.guard_source  s    <TYY=S=S=UVVr2   r;   Nr  r;   r2   r   rB  rB    s    Wk Wr2   rB  c                   "    \ rS rSrS\4S jrSrg)FSDPNNModuleSourcei  r   c                 D    [         U R                  R                  5          $ r)   )_GUARD_SOURCE_FSDP_MODULEr   r   r5   s    r   r   FSDPNNModuleSource.guard_source  s    ()?)?)ABBr2   r;   Nr  r;   r2   r   rG  rG    s    Ck Cr2   rG  c                   0    \ rS rSrS\4S jrS\4S jrSrg)GlobalStateSourcei  r   c                     gNr  r;   r5   s    r   r   GlobalStateSource.name      r2   c                 "    [         R                  $ r)   rp   r5   s    r   r   GlobalStateSource.guard_source  rs   r2   r;   N	r=   r>   r?   r@   rA   r   r
   r   rE   r;   r2   r   rL  rL    s    c "k "r2   rL  c                   b   ^  \ rS rSrSrS\S\SS4U 4S jjrS\4S jrSS	 jr	S\
4S
 jrSrU =r$ )TorchSourcei  zPoints to the actual `torch` module - used instead of GlobalSource
in case the user has overridden `torch` in their local namespaceargskwargsr   Nc                 x   > [         TU ]  " U0 UD6  SSKJnJn  U" U R                  UR                  5      5        g )Nr   )GuardBuilderinstall_guard)r  __init__guardsrY  rZ  r  ID_MATCH)r.   rV  rW  rY  rZ  r  s        r   r[  TorchSource.__init__  s/    $)&)7dool&;&;<=r2   c                     g)Nz__import__('torch')r;   r5   s    r   r   TorchSource.name  s    $r2   c                 x    UR                  UR                  S5      [        SSS9UR                  S5      /5        g )Nr   BUILD_TUPLE)argtorch)r   r^   r   create_import_namer-   s     r   r0   TorchSource.reconstruct  s;    ))!,"=a8**73	
r2   c                 "    [         R                  $ r)   rp   r5   s    r   r   TorchSource.guard_source  rs   r2   r;   r<   )r=   r>   r?   r@   r   r   r[  rA   r   r0   r
   r   rE   r  r  s   @r   rU  rU    sE    H>c >S >T >%c %
"k " "r2   rU  c                   T    \ rS rSr% \\S'   S\4S jrS\4S jrS
S jr	S\
4S jrS	rg)TorchFunctionModeStackSourcei  indr   c                 *    SU R                  5        S3$ )Nz$___get_torch_function_mode_stack_at(r   )
_get_indexr5   s    r   r   !TorchFunctionModeStackSource.name  s    5doo6G5HJJr2   c                 D    SSK Jn  UR                  U R                  5      $ )Nr   )TorchFunctionModeStackVariable)variables.torch_functionrp  get_mode_indexrk  )r.   rp  s     r   rm  'TorchFunctionModeStackSource._get_index  s    L-<<TXXFFr2   Nc                    ^ TR                  U4S j5        TR                  TR                  U R                  5       5      /5        TR                  [	        SS5      5        g )Nc                  D   > T R                  [        R                  S5      $ )N get_torch_function_mode_stack_atr  r  s   r   r~   :TorchFunctionModeStackSource.reconstruct.<locals>.<lambda>  s    G,, Br2   r   F)r   r   r^   rm  r   r-   s    `r   r0   (TorchFunctionModeStackSource.reconstruct  sQ    	

 	w889JKLM21e<=r2   c                 "    [         R                  $ r)   rp   r5   s    r   r   )TorchFunctionModeStackSource.guard_source  rs   r2   r;   r<   )r=   r>   r?   r@   rc   rB   rA   r   rm  r0   r
   r   rE   r;   r2   r   rj  rj    s4    	HKc KGC G
>"k "r2   rj  c                   X    \ rS rSr% \\S'   SS jrS\4S jrS\4S jr	S\
S\
4S	 jrS
rg)r   i  source_namer   Nc                 V    UR                  UR                  U R                  SS95        g )NFrj   )r+   rm   r|  r-   s     r   r0   ConstantSource.reconstruct  s&    g889I9Iu8UVr2   c                 "    [         R                  $ r)   )r
   r   r5   s    r   r   ConstantSource.guard_source  s    ###r2   c                     U R                   $ r)   )r|  r5   s    r   r   ConstantSource.name  s    r2   r  c                     [         er)   r  r  s     r   r  ConstantSource.make_guard  r  r2   r;   r<   )r=   r>   r?   r@   rA   rB   r0   r
   r   r   r   r  rE   r;   r2   r   r   r     s9    W$k $ c  "S "S "r2   r   c                   :    \ rS rSrS\4S jrS\4S jrSS jrSr	g)	NumpyTensorSourcei  r   c                 >    SU R                   R                  5        S3$ )Nz___from_numpy(r   r   r5   s    r   r   NumpyTensorSource.name  s    		 0133r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   NumpyTensorSource.guard_source  r   r2   Nc                    ^ TR                  U4S j5        T" U R                  5        TR                  [        SS5      5        g )Nc                  (   > T R                  SS5      $ )Nrd  	as_tensorr%  r  s   r   r~   /NumpyTensorSource.reconstruct.<locals>.<lambda>  s    g&>&>w&Tr2   r   Fr  r-   s    `r   r0   NumpyTensorSource.reconstruct  s4    TU		21e<=r2   r;   r<   )
r=   r>   r?   r@   rA   r   r
   r   r0   rE   r;   r2   r   r  r    s    4c 4(k (>r2   r  c                   0    \ rS rSrS\4S jrS\4S jrSrg)SubclassAttrListSourcei  r   c                 <    U R                   R                  5        S3$ )Nz.__tensor_flatten__()[0]r   r5   s    r   r   SubclassAttrListSource.name  s    )).."##;<<r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   #SubclassAttrListSource.guard_source  r   r2   r;   NrS  r;   r2   r   r  r    s    =c =(k (r2   r  c                   0    \ rS rSrS\4S jrS\4S jrSrg)FloatTensorSourcei   r   c                 >    SU R                   R                  5        S3$ )Nz___as_tensor(r   r   r5   s    r   r   FloatTensorSource.name  s    tyy~~/022r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   FloatTensorSource.guard_source  r   r2   r;   NrS  r;   r2   r   r  r     s    3c 3(k (r2   r  c                   0    \ rS rSrS\4S jrS\4S jrSrg)CallMethodItemSourcei	  r   c                 <    U R                   R                  5        S3$ )Nz.item()r   r5   s    r   r   CallMethodItemSource.name  s    )).."#7++r2   c                 6    U R                   R                  5       $ r)   r   r5   s    r   r   !CallMethodItemSource.guard_source  r   r2   r;   NrS  r;   r2   r   r  r  	  s    ,c ,(k (r2   r  c                   0    \ rS rSrS\4S jrS\4S jrSrg)ShapeEnvSourcei  r   c                     grN  r;   r5   s    r   r   ShapeEnvSource.name  rP  r2   c                 "    [         R                  $ r)   )r
   	SHAPE_ENVr5   s    r   r   ShapeEnvSource.guard_source  r  r2   r;   NrS  r;   r2   r   r  r    s    c %k %r2   r  c                   0    \ rS rSrS\4S jrS\4S jrSrg)BackwardStateSourcei  r   c                     grN  r;   r5   s    r   r   BackwardStateSource.name   rP  r2   c                 "    [         R                  $ r)   )r
   BACKWARD_STATEr5   s    r   r    BackwardStateSource.guard_source#  s    )))r2   r;   NrS  r;   r2   r   r  r    s    c *k *r2   r  Fonly_allow_inputr  c                    [        U [        5      (       a  [        U R                  US9$ [        U [        5      (       d  g U(       a  U R
                  (       d  g U R                  $ Nr  )r   r   get_local_source_namer   r"   r%   r$   r   r  s     r   r  r  '  sK     &-(($V[[CSTTfk**r2   c                    [        XS9S L$ r  )r  r  s     r   is_from_local_sourcer  3  s     KSWWWr2   c                     [        U 5      S L$ r)   )get_global_source_namer   s    r   is_from_global_sourcer  7  s    !&)55r2   c                     [        U [        5      (       a  [        U R                  5      $ [        U [        5      (       d  g U R
                  $ r)   )r   r   r  r   re   rg   r   s    r   r  r  ;  s:    &-((%fkk22fl++r2   c                     [        U [        5      (       a  [        U R                  5      $ [        U [        5      =(       a$    U R
                  =(       a    U R                  (       + $ r)   )r   r   is_from_nonlocal_sourcer   r"   r'   r%   r   s    r   r  r  C  sJ    &-((&v{{336;' 	 ++	 r2   c                     [        U [        5      (       a  g[        U [        5      (       a  [        U R                  5      $ gr   )r   r   r   is_from_closure_sourcer   r   s    r   r  r  M  s1    &-((&-((%fkk22r2   targetc                 `    [        U [        5      (       a  [        U R                  U5      $ X:H  $ r)   )r   r   is_from_sourcer   )r   r  s     r   r  r  U  s)    &-((fkk622r2   c                     [        U [        5      (       a  g[        U [        5      (       a  [        U R                  5      $ gr   )r   r=  r   &is_from_unspecialized_nn_module_sourcer   r   s    r   r  r  [  s2    &566&-((5fkkBBr2   c                     [        U [        5      (       a  g[        U [        5      (       a  [        U R                  5      $ gr   )r   rB  r   .is_from_unspecialized_builtin_nn_module_sourcer   r   s    r   r  r  d  s2    &<==&-((=fkkJJr2   c                     [        U [        5      (       a  g[        U [        5      (       a  [        U R                  5      $ gr   )r   r	  r   )is_from_unspecialized_param_buffer_sourcer   r   s    r   r  r  m  s2    &899&-((8EEr2   c                     [        U [        5      (       a  g[        U [        5      (       a  [        U R                  5      $ gr   )r   rk  r   $is_from_flatten_script_object_sourcer   r   s    r   r  r  v  s2    &344	FM	*	*3FKK@@r2   c                     [        U [        5      (       a  g[        U [        5      (       a  [        U R                  5      $ gr   )r   r-  r   is_from_optimizer_sourcer   r   s    r   r  r    s1    &/**&-(('44r2   c                    [        U [        5      (       a  g[        U [        5      (       a:  [        U R                  [        5      (       a  U R                  R
                  S:X  a  g[        U [        5      (       a:  [        U R                  [        5      (       a  U R                  R
                  S:X  a  g[        U [        5      (       a  [        U R                  5      $ g)NTr  r  F)	r   r  r  r   r   r   r  r   is_from_defaultsr   s    r   r  r    s    &.)) 	6,--v{{J//KK"22 	6=))v{{J//KK.0&-((,,r2   c                     [        U [        5      (       a  g[        U [        5      (       a  [        U R                  5      $ gr   )r   r"  r   is_from_skip_guard_sourcer   r   s    r   r  r    s1    &/**&-(((55r2   )nr   r  enum	functoolstypingr   r   r   r   r   torch._guardsr   r	   r
   r   r  r   bytecode_transformationr   r   r/   r   r4   LOCAL_SPECIALIZED_NN_MODULErq   GLOBAL_SPECIALIZED_NN_MODULELOCAL_UNSPECIALIZED_NN_MODULEGLOBAL_UNSPECIALIZED_NN_MODULE%LOCAL_UNSPECIALIZED_BUILTIN_NN_MODULE&GLOBAL_UNSPECIALIZED_BUILTIN_NN_MODULELOCAL_FSDP_MODULEGLOBAL_FSDP_MODULEr  r?  rD  rI  rC   r   rA   r   	dataclassr"   rG   rR   re   ry   r   r   r   r   r   r   r   r   r   r   r  r	  r  r"  Enumr+  r9  rI  rU  r`  rk  ru  r  r  r  r  r  r  r  r  r   r	  r  r  r-  r5  r=  rB  rG  rL  rU  rj  r   r  r  r  r  r  r  r  r  r  r  r  r  r  	lru_cacher  r  r  r  r  r  r  r;   r2   r   <module>r     s  &    @ @ C C  M " {>>@@++[-T-T,,k.V.V--{/X/X..0Z0Z55{7h7h668j8j!!;#@#@""K$B$B' #  {@@BB--{/X/X..0Z0Z++[-V-V,,k.X.X55{7h7h668j8j!!;#@#@""K$B$B) %" {HHJJ--{/`/`..0b0b++[-^-^,,k.`.`55{7h7h668j8j!!;#@#@""K$B$B1 - {4466++[-J-J,,k.L.L!!;#@#@""K$B$B--{/L/L..0N0N55{7T7T668V8V 	v 	$ 	"6 "c " d#-& - $-8 d#
76 
7 $
7 d#8 8 $8 d#
.6 
. $
. d#0& 0 $0$ d#	' 	' $	' d#	0 	 $	 d#3 3 $32 d#O O $O0 d#4] 4 $4" d#	-M 	- $	- d#Lf L $L& d#	. 	. $	. d#	1M 	1 $	1  d#3 3 $3 d#M
 M $M d#	Z 	 $	 d#f  $  d# m   $ 6TYY 6  d#%;= %; $%;P d#3M 3 $3  d#/= / $/ d#G} G $G d#7 7 $7 d#>m > $>0m 0 d#!] ! $!H d##9M #9 $#9L d#  $, d#m  $8 d#9 9 $9H d#'9 '9 $'9T d#%K %K $%KP d#
P 
P $
P d#	;] 	; $	; d#:M : $: d#+ + $+  d# m   $  d# ]   $  d#O. O $O
 d#W)D W $W
 d#C C $C
 d#" " $" d#"& " $"4 d#"6 " $"0 d#"V " $"  d#
> 
> $
> d#(] ( $( d#( ( $( d#(= ( $( d#%V % $% d#*& * $* 16		)-	c]	 FK X Xd Xt X6& 6T 66 hsm F t 6 d 6 6 d  6 d   6 d   f     D   V    V   2 f   r2   