+
    Pj                       ^ RI Ht ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIt^ RIt^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHtHtHtHtHtHt ^ RIHt ^ RIt^ R	IHt  ^ R
I!H"t" ^ RI#H$t$ ^ RI%H&t&H't' ^ RI(H)t) ]PT                  ! ]+4      t,]'       dC   ^ RI-t-^ RI.H/t/H0t0H1t1 ^ RI2H3t3 ^ RI4t4^ RI5H6t6 ^ RI7H8t8 ^ RI9H:t: ^ RI;H<t< ^ RI=H>t> ^ RI?H@t@ ^ RIAHBtB  ]P                  ! R4      tD]P                  ! R4      tE]! RRRR7       ! R R4      4       tF ! R R]4      tG ! R R ]P                  4      tI  ! R! R"4      tJ]P&                  ! RR#7       ! R$ R%4      4       tK ! R& R']4      tL]P&                  ! RR(7       ! R) R*4      4       tM]! R+4      tN ]P&                  ! RR#7       ! R, R-4      4       tO ]P&                  ! RR#7       ! R. R/]O4      4       tP ]P&                  ! RR#7       ! R0 R1]O4      4       tQ  ! R2 R3]]N,          4      tR ! R4 R54      tS ! R6 R74      tT ! R8 R9]R]T,          4      tU ! R: R;4      tV ! R< R=]R]V,          4      tW ! R> R?4      tX  ! R@ RA]R]S,          4      tY ! RB RC4      tZ] ! RD RE4      4       t[] ! RF RG4      4       t\ ! RH RI]Z4      t] ! RJ RK4      t^]	P                  ! 4       t`  ! RL RM4      ta] ! RN RO4      4       tb ! RP RQ4      tc]RR RS l4       td]RT RU l4       te]RV RW l4       tf]RdRX RY ll4       tf]! 4       RdRZ R[ ll4       tf]f! RR#7       ! R\ R]4      4       tg]f! RR#7       ! R^ R_]g4      4       thRdR` Ra lltiRb Rc ltjR# )e    )annotationsN)abstractmethod)defaultdict)contextmanager)	dataclass)AnyGeneric
NamedTupleoverloadTYPE_CHECKINGTypeVar)dataclass_transform)_pytree)
OrderedSet)is_traceable_wrapper_subclass)CapturedTracebackformat_frame)WeakTensorKeyDictionary)Callable	GeneratorIterator)CodeType)DDPOptimizerContext)	PyCodegen)GuardCheckSpec)CodeOptions)ViewAndMutationMeta)NestedCompileRegionOptionsFakeTensorModez-^(?P<frame_id>\d+)/(?P<frame_compile_id>\d+)$zQ^!(?P<compiled_autograd_id>\d+)(?:/(?P<frame_id>\d+)/(?P<frame_compile_id>\d+))?$T)frozenkw_onlyslotsc                  \    ] tR t^It$ R]R&   R]R&   RtR]R&   R R lt]R R	 l4       tR
t	R# )	CompileId
int | Noneframe_idframe_compile_idNcompiled_autograd_idc                   V ^8  d   QhRR/#    returnstr )formats   "f/Users/ahmed/devFolder/Ultron/claude-voice/gateway/.venv/lib/python3.14/site-packages/torch/_guards.py__annotate__CompileId.__annotate__X   s     > > >    c                	   V P                   e   V P                  R J V P                  R J 8w  d&   \        RV P                   RV P                   24      hRpV P                  e   RV P                   RV P                   2pRV P                    V 2# V P                  e   V P                  f&   \        RV P                   RV P                   24      hV P                   RV P                   2# )NzMframe_id and frame_compile_id must both be None or both be set, got frame_id=z, frame_compile_id= /!z=frame_id and frame_compile_id must not be None, got frame_id=)r)   r'   r(   AssertionError)self	frame_strs   & r1   __str__CompileId.__str__X   s   $$0%4+@+@D+HI$$$(MM?2EdF[F[E\^  I}}(a0E0E/FG	t001)==}}$(=(=(E$$$(MM?2EdF[F[E\^  mm_Ad&;&;%<==r4   c                    V ^8  d   QhRRRR/# )r,   
compile_id
str | Noner-   CompileId | Noner/   )r0   s   "r1   r2   r3   n   s     J JZ J4D Jr4   c                F   Vf   R#  \         \        3 Fb  pVP                  V4      ;p'       g   K  VP                  4       pVP	                  4        F  w  rVVf   K  \        V4      WE&   K  	  V ! R/ VB u # 	  \        h  \         d   p\        RT R24      ThRp?ii ; i)zt
Factory method that creates a CompileId from its string representation.
Keep this in sync with the __str__ method.
NzInvalid compile_id ''r/   )COMPILE_ID_PATTERNCA_COMPILE_ID_PATTERNmatch	groupdictitemsint
ValueError	Exception)clsr?   patternrF   groupskves   &&      r1   from_stringCompileId.from_stringm   s     	J.0EF#MM*55555"__.F &=(+AFI !/ ==( G !  	J3J<qABI	Js(   %B  &B  B  8B   B BB r/   )
__name__
__module____qualname____firstlineno____annotations__r)   r<   classmethodrR   __static_attributes__r/   r4   r1   r%   r%   I   s8    
 !  (,*+
>* J Jr4   r%   c                  8    ] tR t^t$ R]R&   R]R&   R R ltRtR# )	TraceIdr%   r?   rI   attemptc                   V ^8  d   QhRR/# r+   r/   )r0   s   "r1   r2   TraceId.__annotate__   s     7 7 7r4   c                	    V P                   ^ 8X  d   \        V P                  4      # V P                   RV P                    2# )r   _)r]   r.   r?   r:   s   &r1   r<   TraceId.__str__   s7    <<1t''oo&a~66r4   r/   NrT   rU   rV   rW   rX   r<   rZ   r/   r4   r1   r\   r\      s     L7 7r4   r\   c                      ] tR t^t^ t^t^t^t^t^t	^t
^t^t^	t^
t^t^t^t^t^t^tR R ltR R ltR R ltR R ltR	 R
 ltRtR# )GuardSourcec                   V ^8  d   QhRR/# r,   r-   boolr/   )r0   s   "r1   r2   GuardSource.__annotate__   s     W W Wr4   c                	H    V \         P                  \         P                  39   # N)rf   GLOBAL_FSDP_MODULELOCAL_FSDP_MODULErb   s   &r1   is_fsdp_moduleGuardSource.is_fsdp_module   s    668U8UVVVr4   c                   V ^8  d   QhRR/# rh   r/   )r0   s   "r1   r2   rj      s     
 
$ 
r4   c                	    ^ RI Hu Hp VP                  '       d<   V \        P
                  \        P                  39   ;'       g    V P                  4       # V \        P
                  \        P                  39   # r   N)torch._dynamo.config_dynamoconfig_unsafe_skip_fsdp_module_guardsrf   GLOBAL_SPECIALIZED_NN_MODULELOCAL_SPECIALIZED_NN_MODULEro   )r:   rv   s   & r1   is_specialized_nn_module$GuardSource.is_specialized_nn_module   sv    --111<<;; ) )
 &&( 4433
 
 	
r4   c                   V ^8  d   QhRR/# rh   r/   )r0   s   "r1   r2   rj      s     
 
D 
r4   c                	    V \         P                  \         P                  \         P                  \         P                  39   # rl   )rf   GLOBAL_UNSPECIALIZED_NN_MODULELOCAL_UNSPECIALIZED_NN_MODULE&GLOBAL_UNSPECIALIZED_BUILTIN_NN_MODULE%LOCAL_UNSPECIALIZED_BUILTIN_NN_MODULErb   s   &r1   is_unspecialized_nn_module&GuardSource.is_unspecialized_nn_module   s8    6655>>==	
 
 	
r4   c                   V ^8  d   QhRR/# rh   r/   )r0   s   "r1   r2   rj      s     
 
D 
r4   c                	H    V \         P                  \         P                  39   # rl   )rf   r   r   rb   s   &r1   "is_unspecialized_builtin_nn_module.GuardSource.is_unspecialized_builtin_nn_module   s&    >>==
 
 	
r4   c                   V ^8  d   QhRR/# rh   r/   )r0   s   "r1   r2   rj      s     
 
$ 
r4   c                	    V \         P                  \         P                  \         P                  \         P                  \         P
                  39   # rl   )rf   LOCALry   rn   r   r   rb   s   &r1   is_localGuardSource.is_local   sA    33))55==
 
 	
r4   r/   N)rT   rU   rV   rW   r   GLOBALry   rx   CONSTANTRANDOM_VALUE	SHAPE_ENVrn   rm   BACKWARD_STATE	EPHEMERALSYNTHETIC_LOCALr   r~   r   r   
TEMP_LOCALro   rz   r   r   r   rZ   r/   r4   r1   rf   rf      s~    EF"##$ HLINIO$&!%'",.)-/*JW
"


 
r4   rf   c                      ] tR t^tRtR# )GuardBuilderBaser/   NrT   rU   rV   rW   rZ   r/   r4   r1   r   r      s    r4   r   )r!   c                  8    ] tR t^t$ R]R&   R]R&   R R ltRtR# )	SLocz#traceback.FrameSummary | str | Noneframework_locr@   maybe_user_locc                   V ^8  d   QhRR/# r+   r/   )r0   s   "r1   r2   SLoc.__annotate__   s       r4   c                	    \        V P                  \        4      '       d   V P                  M$V P                  f   RM\        V P                  4      pV P                  e   V P                   RV R2# RV R2# )Nr6   z ()()
isinstancer   r.   r   r   )r:   flocs   & r1   r<   SLoc.__str__   s~     $,,c22  !!) d001 	 *))*"TF!44tfA;r4   r/   Nrd   r/   r4   r1   r   r      s    66 r4   r   c                  6    ] tR t^t$ R]R&   R]R&   R]R&   RtR# )	
ShapeGuardzsympy.logic.boolalg.Booleanexprr   slocri   size_obliviousr/   NrT   rU   rV   rW   rX   rZ   r/   r4   r1   r   r      s    
%%
Jr4   r   )r#   c                  n   ] tR t^t$ R]R&   R]R&   RtR]R&   RtR]R&   RtR	]R
&   RtR]R&   Rt	R]R&   Rt
R]R&   RtR]R&   RtR]R&   R R ltR R ltR R ltR R lt]R R l4       t]R  R! l4       t]R" R# l4       tR$ R% ltR& R' ltR( R) ltR* R+ ltR, R- ltR. R/ ltR0 R1 ltR2 R3 ltR4tR# )5GuardSourceoriginating_sourcez)Callable[[GuardBuilderBase, Guard], None]	create_fnNzlist[str] | Noneguard_types	code_listzobject | Noneobj_weakref!weakref.ReferenceType[Any] | Noneguarded_class_weakrefzCapturedTraceback | Nonestackztraceback.StackSummary | None
user_stackr&   _hashFri   _unserializablec                   V ^8  d   QhRR/# r,   r-   rI   r/   )r0   s   "r1   r2   Guard.__annotate__  s      # r4   c                	    V P                   f;   \        V P                  V P                  \	        V P
                  4      34      V n         V P                   # rl   )r   hashnamesourceidr   rb   s   &r1   __hash__Guard.__hash__  s:    ::tyy$++r$..7IJKDJzzr4   c                   V ^8  d   QhRR/# )r,   r-   ztuple[bool, int, int, str, int]r/   )r0   s   "r1   r2   r   "  s     
 
9 
r4   c                	   \        V P                  \        P                  4      ;'       dE    V P                  P                  \
        P                  P                  P                  P                  J pTV P                  '       d   V P                  P                  MR\        V P                  4      V P                  V P                  4       P                  P                   3# )   )r   r   	functoolspartialfunctorchru   guardsGuardBuilderDUPLICATE_INPUTr   valuelenr   inner_create_fn__code__co_firstlineno)r:   is_duplicate_inputs   & r1   sort_keyGuard.sort_key"  s    
 t~~y'8'89 Y Y##u}}';';'H'H'X'XX 	
 !%DKK"		NII  "++::
 	
r4   c                    V ^8  d   QhRRRR/# )r,   otherr   r-   ri   r/   )r0   s   "r1   r2   r   2  s     2 2E 2d 2r4   c                	D    V P                  4       VP                  4       8  # rl   )r   r:   r   s   &&r1   __lt__Guard.__lt__2  s    }}!111r4   c                   V ^8  d   QhRR/# )r,   r-   z(Callable[[GuardBuilderBase, Guard], Any]r/   )r0   s   "r1   r2   r   5  s     " "!I "r4   c                	    \        V P                  \        P                  4      '       d   V P                  P                  # V P                  # rl   )r   r   r   r   r   rb   s   &r1   r   Guard.inner_create_fn5  s3    dnni&7&788>>&&&>>!r4   c                   V ^8  d   QhRR/# r+   r/   )r0   s   "r1   r2   r   <  s     , ,c ,r4   c                	.    V P                   P                  # rl   )r   r   rb   s   &r1   r   
Guard.name;  s    &&+++r4   c                   V ^8  d   QhRR/# r,   r-   rf   r/   )r0   s   "r1   r2   r   @  s     4 4 4r4   c                	.    V P                   P                  # rl   )r   guard_sourcerb   s   &r1   r   Guard.source?  s    &&333r4   c                    V ^8  d   QhRRRR/# )r,   r   objectr-   r.   r/   )r0   s   "r1   r2   r   D  s     $ $F $s $r4   c           
     &   \        V \        P                  4      '       dh   V ! 4       pVeE   R\        \	        V 4      4       RVP
                  P                   R\        \	        V4      4       R2# R\        \	        V 4      4       R2# \        V 4      # )a  
This is a workaround of a Python weakref bug.

`obj_weakref` is instance returned by `weakref.ref`,
`str(obj_weakref)` is buggy if the original obj overrides __getattr__, e.g:

    class MyConfig(dict):
        def __getattr__(self, x):
            return self[x]

    obj = MyConfig(offset=5)
    obj_weakref = weakref.ref(obj)
    str(obj_weakref)  # raise error: KeyError: '__name__'
z<weakref at z; to 'z' at >z; dead>)r   weakrefReferenceTypehexr   	__class__rT   r.   )r   objs   & r1   weakref_to_strGuard.weakref_to_strC  s      k7#8#899-C%c"[/&:%;6#--BXBXAYY^_bceficj_k^llmnn%c"[/&:%;7CC{##r4   c                   V ^8  d   QhRR/# r+   r/   )r0   s   "r1   r2   r   \  s     
 
# 
r4   c                	f   R V P                   '       d%   V P                   P                  P                  4       MR R\        V P                  4       RV P	                  4       P
                   RV P                   RV P                   RV P                  V P                  4       RV P                   R2pV# )z	
        r6    z&
        {
            'guard_types': z,
            'code': z,
            'obj_weakref': z
            'guarded_class': z
        }
        )r   r   lowerreprr   rT   r   r   r   r   r   )r:   ss   & r1   __repr__Guard.__repr__\  s    	%)[[[					!b94		?:K1TMaMaMcMlMlLm n ,,- .^^$ % //0@0@AB C"889 :	 r4   c                   V ^8  d   QhRR/# r+   r/   )r0   s   "r1   r2   r   h  s     	 	 	r4   c                	   R \        V P                  4       R2pV P                  '       d%   V P                  P                  P                  4       MRpVRV R2,          pVRV P	                  4       P
                   R2,          pVRV P                   R2,          pVRV P                   R2,          pVRV P                  V P                  4       R2,          pVRV P                   R2,          pV# )	zName: 
r6   z    Source: z    Create Function: z    Guard Types: z    Code List: z    Object Weakref: z    Guarded Class Weakref: )r   r   r   r   r   rT   r   r   r   r   r   )r:   outputr   s   &  r1   r<   Guard.__str__h  s    $tyy/*"--1[[[!!'')bL++)$*>*>*@*I*I)J"MM%d&6&6%7r::ODNN#3266()<)<T=M=M)N(OrRR/0J0J/K2NNr4   c                    V ^8  d   QhRRRR/# )r,   builderr   r-   r   r/   )r0   s   "r1   r2   r   s  s      . 3 r4   c           	     	`    V P                  W4      #   \         d    \        P                  R \	        T 4      P                  4       4       T P                  '       dO   \        P                  RRP                  T P                  P                  4       RR 4      P                  4       4       h i ; i)zError while creating guard:
%szCreated at:
%sr6   N)
r   rK   log	exceptionr.   rstripr   errorjoinr0   )r:   r   s   &&r1   createGuard.creates  s    	>>'00 	MM;SY=M=M=OPzzz		+RWWTZZ5F5F5H5M-N-U-U-WX		s
    BB-c                   V ^8  d   QhRR/# rh   r/   )r0   s   "r1   r2   r   |  s     6 6$ 6r4   c                	6    V P                   P                  4       # rl   )r   rz   rb   s   &r1   rz   Guard.is_specialized_nn_module|  s    {{3355r4   c                   V ^8  d   QhRR/# rh   r/   )r0   s   "r1   r2   r     s     , , ,r4   c                	6    V P                   P                  4       # rl   )r   ro   rb   s   &r1   ro   Guard.is_fsdp_module  s    {{))++r4   c                   V ^8  d   QhRR/# rh   r/   )r0   s   "r1   r2   r     s     & &$ &r4   c                	6    V P                   P                  4       # rl   )r   r   rb   s   &r1   r   Guard.is_local  s    {{##%%r4   c                   V ^8  d   QhRR/# r+   r/   )r0   s   "r1   r2   r     s     " " "r4   c                	    \        V P                  \        P                  4      '       d#   V P                  P                  pVP
                  # V P                  pVP
                  # rl   )r   r   r   r   r   rT   )r:   r   s   & r1   create_fn_nameGuard.create_fn_name  sM    dnni&7&788++I !!! I!!!r4   c          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )r,   
guard_typer.   guarded_classr   r   	list[str]r   r   r-   Noner/   )r0   s   "r1   r2   r     s<     &' &'&' 9&' 	&'
 &' 
&'r4   c                	    V P                   '       g   . V n         V P                   P                  V4       V P                  VR 39  d   \        RV P                   RV 24      hW n        V P                  '       g   W0n        MV P                  P                  V4       V P                  VR 39   ;'       g0    \        V P                  4      ;'       d    V P                  4       R J pV'       g   \        RV P                   RV 24      hW@n        R # )Nz1Guarded class id must be identical, or None, got z vs zHGuarded object must be identical, None or ephemeral (dead weakref), got )r   appendr   r9   r   extendr   callable)r:   r  r  r   r   is_valids   &&&&& r1   set_export_infoGuard.set_export_info  s    !D
+%%mT-BB 112$}oG  &3"~~~&NNN!!), d 33 + +(() + +  "d* 	
  ''([M;  'r4   )r   r   r   r   r   )rT   rU   rV   rW   rX   r   r   r   r   r   r   r   r   r   r   r   r   propertyr   r   staticmethodr   r   r<   r  rz   ro   r   r  r   rZ   r/   r4   r1   r   r      s    & 88 %)K!("&I&!%K%?C<C&*E#*04J-4E:!OT!

 2" , , 4 4 $ $0
	6,&"&' &'r4   r   Tc                      ] tR tRtRtR# )GuardEnvExpri  r/   Nr   r/   r4   r1   r&  r&    s    r4   r&  c                  8    ] tR tRt$ R]R&   R]R&   R R ltRtR# )	DuplicateInputsi  r   input_source_ainput_source_bc                   V ^8  d   QhRR/# r,   r-   r  r/   )r0   s   "r1   r2   DuplicateInputs.__annotate__  s      t r4   c                	l    V P                   V P                  8X  d   \        R V P                    24      hR# )z9input_source_a and input_source_b must be different, got N)r)  r*  r9   rb   s   &r1   __post_init__DuplicateInputs.__post_init__  s>    $"5"55 **+-  6r4   r/   N)rT   rU   rV   rW   rX   r/  rZ   r/   r4   r1   r(  r(    s     r4   r(  c                  ,    ] tR tRt$ R]R&   R]R&   RtR# )StorageOverlapi  zlist[Source]overlapping_sourcesnon_overlapping_sourcesr/   Nr   r/   r4   r1   r2  r2    s    %%))r4   r2  c                  B    ] tR tRt]R R l4       t]R R l4       tRtR# )Checkpointablei  c                   V ^8  d   QhRR/# )r,   r-   r$  r/   )r0   s   "r1   r2   Checkpointable.__annotate__  s    '''r4   c                	    R # rl   r/   rb   s   &r1   copy_graphstateCheckpointable.copy_graphstate  s    $'r4   c                    V ^8  d   QhRRRR/# )r,   stater$  r-   r  r/   )r0   s   "r1   r2   r8    s    777d7r4   c                	    R # rl   r/   r:   r=  s   &&r1   restore_graphstate!Checkpointable.restore_graphstate  s    47r4   r/   N)rT   rU   rV   rW   r   r:  r@  rZ   r/   r4   r1   r6  r6    s    ' '7 7r4   r6  c                  J    ] tR tRt$ RtR]R&   R R ltR R ltR	 R
 ltRt	R# )GuardsCheckpointStatei   zO
The GuardCheckpointState - it is the T of Checkpointable[T] for GuardsContext
OrderedSet[Guard]dynamo_guardsc                    V ^8  d   QhRRRR/# )r,   rE  rD  r-   r  r/   )r0   s   "r1   r2   "GuardsCheckpointState.__annotate__  s     + +&7 +D +r4   c                	    Wn         R # rl   rE  )r:   rE  s   &&r1   __init__GuardsCheckpointState.__init__  s    *r4   c                    V ^8  d   QhRRRR/# )r,   r   rC  r-   OrderedSet[Guard] | Noner/   )r0   s   "r1   r2   rG  
  s     
 
/ 
4L 
r4   c                t    V P                   P                  VP                   4      p\        V4      ^ 8X  d   R# V# )z
Produces a delta against another GuardsCheckpointState.

Returns None if no delta is found, otherwise, return an OrderedSet() of mismatched
Guard type objects.
N)rE  
differencer   r:   r   rs   && r1   diffGuardsCheckpointState.diff
  s3     ))%*=*=>q6Q;r4   c                    V ^8  d   QhRRRR/# r,   r   r   r-   ri   r/   )r0   s   "r1   r2   rG         ( (F (t (r4   c                	X    \        V\        4      '       g   R # V P                  V4      RJ # FN)r   rC  rR  r   s   &&r1   __eq__GuardsCheckpointState.__eq__  s'    %!677yy4''r4   rI  N)
rT   rU   rV   rW   __doc__rX   rJ  rR  rY  rZ   r/   r4   r1   rC  rC     s#     %$+
( (r4   rC  c                  J    ] tR tRt$ / tR]R&   R R ltR R ltR R	 ltR
t	R# )ModuleContextCheckpointStatei  dict[str, torch.nn.Module]
nn_modulesc                    V ^8  d   QhRRRR/# )r,   r_  r^  r-   r  r/   )r0   s   "r1   r2   )ModuleContextCheckpointState.__annotate__  s     % %#= %$ %r4   c                	    Wn         R # rl   r_  )r:   r_  s   &&r1   rJ  %ModuleContextCheckpointState.__init__  s    $r4   c                    V ^8  d   QhRRRR/# )r,   r   r]  r-   set[str] | Noner/   )r0   s   "r1   r2   ra  "       
 
6 
? 
r4   c                    \        V P                  P                  4       4      P                  \        VP                  P                  4       4      4      p\	        V4      ^ 8X  d   R# V# )z
Produces a delta against another ModuleContextCheckpointState.

Returns None if no delta is found, otherwise, return a set() of mismatched
module key names.
N)setr_  keysrO  r   rP  s   && r1   rR  !ModuleContextCheckpointState.diff"  sM     $$&'223u7G7G7L7L7N3OPq6Q;r4   c                    V ^8  d   QhRRRR/# rU  r/   )r0   s   "r1   r2   ra  .  rV  r4   c                	X    \        V\        4      '       g   R # V P                  V4      RJ # rX  )r   r]  rR  r   s   &&r1   rY  #ModuleContextCheckpointState.__eq__.  '    %!=>>yy4''r4   rc  N)
rT   rU   rV   rW   r_  rX   rJ  rR  rY  rZ   r/   r4   r1   r]  r]    s!    -/J*/%
( (r4   r]  c                  :    ] tR tRtR R ltR R ltR R ltRtR	# )
ModuleContexti4  c                   V ^8  d   QhRR/# r,  r/   )r0   s   "r1   r2   ModuleContext.__annotate__5  s     - -$ -r4   c                	    / V n         R # rl   rc  rb   s   &r1   rJ  ModuleContext.__init__5  s	    *,r4   c                   V ^8  d   QhRR/# )r,   r-   r]  r/   )r0   s   "r1   r2   rs  8  s     C C!= Cr4   c                	>    \        \        V P                  4      4      # rl   )r]  dictr_  rb   s   &r1   r:  ModuleContext.copy_graphstate8  s    +D,ABBr4   c                    V ^8  d   QhRRRR/# )r,   r=  r]  r-   r  r/   )r0   s   "r1   r2   rs  ;  s     + +(D + +r4   c                	    \        V\        4      '       g   \        R \        V4       24      hVP                  V n        R# )z+expected ModuleContextCheckpointState, got N)r   r]  r9   typer_  r?  s   &&r1   r@   ModuleContext.restore_graphstate;  s:    %!=>> =d5k]K   **r4   rc  N)rT   rU   rV   rW   rJ  r:  r@  rZ   r/   r4   r1   rq  rq  4  s    -C+ +r4   rq  c                  J    ] tR tRt$ / tR]R&   R R ltR R ltR R	 ltR
t	R# )GlobalContextCheckpointStateiC  dict[str, tuple[Callable, Any]]global_statec                    V ^8  d   QhRRRR/# )r,   global_statesr  r-   r  r/   )r0   s   "r1   r2   )GlobalContextCheckpointState.__annotate__F  s     * *&E *$ *r4   c                	    Wn         R # rl   r  )r:   r  s   &&r1   rJ  %GlobalContextCheckpointState.__init__F  s    )r4   c                    V ^8  d   QhRRRR/# )r,   r   r  r-   rf  r/   )r0   s   "r1   r2   r  I  rg  r4   c                    \        V P                  P                  4       4      P                  \        VP                  P                  4       4      4      p\	        V4      ^ 8X  d   R# V# )z
Produces a delta against another GlobalContextCheckpointState.

Returns None if no delta is found, otherwise, return a set() of mismatched
global key names.
N)ri  r  rj  rO  r   rP  s   && r1   rR  !GlobalContextCheckpointState.diffI  sO     !!&&()44S9K9K9P9P9R5STq6Q;r4   c                    V ^8  d   QhRRRR/# rU  r/   )r0   s   "r1   r2   r  U  rV  r4   c                	X    \        V\        4      '       g   R # V P                  V4      RJ # rX  )r   r  rR  r   s   &&r1   rY  #GlobalContextCheckpointState.__eq__U  ro  r4   r  N)
rT   rU   rV   rW   r  rX   rJ  rR  rY  rZ   r/   r4   r1   r  r  C  s!    46L16*
( (r4   r  c                  F    ] tR tRtRt0 RmtR R ltR R ltR R ltR	t	R
# )GlobalContexti[  zn
This keeps track of the global torch state during tracing of a function.
For example, torch.is_grad_enabled.
c                   V ^8  d   QhRR/# r,  r/   )r0   s   "r1   r2   GlobalContext.__annotate__j  s     @ @$ @r4   c                	    / V n         R # rl   r  rb   s   &r1   rJ  GlobalContext.__init__j  s
    =?r4   c                   V ^8  d   QhRR/# )r,   r-   r  r/   )r0   s   "r1   r2   r  m  s     ? ?!= ?r4   c                	,    \        V P                  4      # rl   )r  r  rb   s   &r1   r:  GlobalContext.copy_graphstatem  s    +D,=,=>>r4   c                    V ^8  d   QhRRRR/# )r,   r=  r  r-   r  r/   )r0   s   "r1   r2   r  p  s      (D  r4   c                	   \        V\        4      '       g   \        R \        V4       24      hVP                  V n        \        V P                  4      \        V P                  4      8X  d3   \        V P                  P                  4       4      V P                  8X  g=   \        R\        V P                  P                  4       4       RV P                   24      hV P                  P                  4        F  w  r#V! V4       K  	  R# )z+expected GlobalContextCheckpointState, got z Global state mismatch: got keys z, expected N)
r   r  r9   r|  r  r   _supported_global_statesri  rj  values)r:   r=  r   argss   &&  r1   r@   GlobalContext.restore_graphstatep  s    %!=>> =d5k]K  "..!!"c$*G*G&HHD%%**,-1N1NN 23t7H7H7M7M7O3P2Q R 99:<  ++224JDJ 5r4   r  N>   grad_enabledautocast_enabledautocast_cpu_dtypeautocast_gpu_dtypeautocast_cpu_enabledautocast_cache_enabled)
rT   rU   rV   rW   r[  r  rJ  r:  r@  rZ   r/   r4   r1   r  r  [  s$    
 @? r4   r  c                      ] tR tRtRR R lltR R ltR R ltR	 R
 ltR R ltR R lt	R R lt
RRR^ /R R lltR R ltR R ltR R ltRtR# )	GuardsSeti  Nc                    V ^8  d   QhRRRR/# )r,   innerrM  r-   r  r/   )r0   s   "r1   r2   GuardsSet.__annotate__  s     	. 	.6 	.$ 	.r4   c                	    Vf   \        4       V n        MWn        \        \        4      V n        V P                   F  pV P                  V4       K  	  R # rl   )r   r  r   listsource_to_guardstrack_guard_by_source)r:   r  guards   && r1   rJ  GuardsSet.__init__  sB    =,6LDJJ CNdBSZZE&&u-  r4   c                    V ^8  d   QhRRRR/# )r,   r  r   r-   r  r/   )r0   s   "r1   r2   r    s     4 45 4T 4r4   c                	b    VP                   pV P                  V,          P                  V4       R # rl   )r   r  r  )r:   r  r   s   && r1   r  GuardsSet.track_guard_by_source  s&    ))f%,,U3r4   c                   V ^8  d   QhRR/# )r,   r-   zIterator[Guard]r/   )r0   s   "r1   r2   r    s        /  r4   c                	,    \        V P                  4      # rl   )iterr  rb   s   &r1   __iter__GuardsSet.__iter__      DJJr4   c                   V ^8  d   QhRR/# r   r/   )r0   s   "r1   r2   r    s       r4   c                	,    \        V P                  4      # rl   )r   r  rb   s   &r1   __len__GuardsSet.__len__  s    4::r4   c                    V ^8  d   QhRRRR/# )r,   r   r  r-   r/   )r0   s   "r1   r2   r    s     3 3Y 39 3r4   c                	N    \        V P                  VP                  ,
          4      # rl   )r  r  r   s   &&r1   __sub__GuardsSet.__sub__  s    ekk122r4   c                   V ^8  d   QhRR/# rh   r/   )r0   s   "r1   r2   r    s        $  r4   c                	,    \        V P                  4      # rl   )ri   r  rb   s   &r1   __bool__GuardsSet.__bool__  r  r4   c                   V ^8  d   QhRR/# r,  r/   )r0   s   "r1   r2   r    s     2 2t 2r4   c                	L    \        4       V n        \        \        4      V n        R # rl   )r   r  r   r  r  rb   s   &r1   clearGuardsSet.clear  s    \
 +D 1r4   collect_debug_stackTskipc               (    V ^8  d   QhRRRRRRRR/# )	r,   r  r   r  ri   r  rI   r-   r  r/   )r0   s   "r1   r2   r    s,     * **48*GJ*	*r4   c               	B   WP                   9   d   R # V'       d2   VP                  f$   \        P                  ! ^V,           R7      Vn        VP                  f   \
        P                  4       Vn        V P                   P                  V4       V P                  V4       R # )Nr  )	r  r   r   extractr   TracingContextextract_stackaddr  )r:   r  r  r  s   &&$$r1   r  GuardsSet.add  so     JJ{{"/77QXF#-;;=E

u""5)r4   c                    V ^8  d   QhRRRR/# )r,   othersz
set[Guard]r-   r  r/   )r0   s   "r1   r2   r    s     $ $j $T $r4   c                	P    V F  pV F  pV P                  V^R7       K  	  K!  	  R# )r   r  N)r  )r:   r  ogs   &*  r1   updateGuardsSet.update  s&    A#  r4   c                    V ^8  d   QhRRRR/# )r,   r   r   r-   zlist[Guard]r/   )r0   s   "r1   r2   r    s     3 3F 3{ 3r4   c                :    \        V P                  V,          4      # )z4Return all guards with the given originating_source.)r  r  )r:   r   s   &&r1   get_guards_for_sourceGuardsSet.get_guards_for_source  s    D))&122r4   c                    V ^8  d   QhRRRR/# )r,   r   r   r-   r  r/   )r0   s   "r1   r2   r    s     . . .4 .r4   c                   aa ^RI Ho \        VV3R lV P                   4       4      V n        \	        \
        4      V n        V P                   F  pV P                  V4       K  	  R# )z.Delete all guards that contains a given source)is_from_sourcec              3  ^   <"   T F"  pS! VP                   S4      '       d   K  Vx  K$  	  R # 5irl   )r   ).0r  r  r   s   & r1   	<genexpr>6GuardsSet.remove_guards_with_source.<locals>.<genexpr>  s%       
!!8L8Lf)UAAzs   -
-N)_dynamo.sourcer  r   r  r   r  r  r  )r:   r   r  r  s   &f @r1   remove_guards_with_source#GuardsSet.remove_guards_with_source  sN    2  
zz 
 


 !,D 1ZZE&&u-  r4   )r  r  rl   )rT   rU   rV   rW   rJ  r  r  r  r  r  r  r  r  r  r  rZ   r/   r4   r1   r  r    sN    	.4 
3 2*;?*MN*$
3. .r4   r  c                  d    ] tR tRtR R lt]P                  R R l4       tR R ltR R	 lt	R
t
R# )GuardsContexti  c                   V ^8  d   QhRR/# r,  r/   )r0   s   "r1   r2   GuardsContext.__annotate__  s     ( ($ (r4   c                	@    \        4       V n        . V n        R V n        R# rX  )r  rE  aotautograd_guardsskip_installrb   s   &r1   rJ  GuardsContext.__init__  s    (168"'r4   c                   V ^8  d   QhRR/# r,   r-   Generator[None, None, None]r/   )r0   s   "r1   r2   r    s     $ $$? $r4   c              #  	`   "   V P                   pR V n          Rx  Wn         R#   Yn         i ; i5i)TN)r  )r:   olds   & r1   skip_guard_install GuardsContext.skip_guard_install  s,      	$ #s   .# .+.c                   V ^8  d   QhRR/# )r,   r-   rC  r/   )r0   s   "r1   r2   r    s     K K!6 Kr4   c                	R    \        \        V P                  P                  4      4      # rl   )rC  r   rE  r  rb   s   &r1   r:  GuardsContext.copy_graphstate  s    $Z0B0B0H0H%IJJr4   c                    V ^8  d   QhRRRR/# )r,   r=  rC  r-   r  r/   )r0   s   "r1   r2   r    s     < <(= <$ <r4   c                	    \        V\        4      '       g   \        R \        V4       24      h\	        VP
                  4      V n        R# )z$expected GuardsCheckpointState, got N)r   rC  r9   r|  r  rE  r?  s   &&r1   r@   GuardsContext.restore_graphstate  s:    %!677 #GU}!UVV&u':':;r4   )r  rE  r  N)rT   rU   rV   rW   rJ  
contextlibr   r  r:  r@  rZ   r/   r4   r1   r  r    s1    (
 $ $K< <r4   r  c                      ] tR tRt]R R l4       t]R R l4       t]R R l4       t]R R	 l4       t]R
 R l4       t	]R R l4       t
]R R l4       t]R R l4       t]R R l4       t]R R l4       tRtR# )HopSubgraphCachei  c               $    V ^8  d   QhRRRRRR/# r,   fn_coder   
identifierr.   r-   r  r/   )r0   s   "r1   r2   HopSubgraphCache.__annotate__  s$      -0	r4   c                	    R # rl   r/   r:   r   r  s   &&&r1   add_dynamo_installed_submodule/HopSubgraphCache.add_dynamo_installed_submodule       r4   c                    V ^8  d   QhRRRR/# r,   r   r   r-   r  r/   )r0   s   "r1   r2   r    s    RRxRIRr4   c                	    R # rl   r/   r:   r   s   &&r1   get_dynamo_installed_submodules0HopSubgraphCache.get_dynamo_installed_submodules  s    ORr4   c               $    V ^8  d   QhRRRRRR/# r,   r  r.   keyr   r-   r  r/   )r0   s   "r1   r2   r    s    QQQ8QQr4   c                	    R # rl   r/   r:   r  r  s   &&&r1   add_autograd_key_entry'HopSubgraphCache.add_autograd_key_entry  s    NQr4   c                    V ^8  d   QhRRRR/# r,   r  r.   r-   zCallable | Noner/   )r0   s   "r1   r2   r    s    MMMMr4   c                	    R # rl   r/   r:   r  s   &&r1   get_autograd_key_entry'HopSubgraphCache.get_autograd_key_entry  s    JMr4   c               $    V ^8  d   QhRRRRRR/# r  r/   )r0   s   "r1   r2   r    s    SS3SXS$Sr4   c                	    R # rl   r/   r  s   &&&r1   add_proxy_dispatch_entry)HopSubgraphCache.add_proxy_dispatch_entry  s    PSr4   c                    V ^8  d   QhRRRR/# r  r/   )r0   s   "r1   r2   r    s    OO3O?Or4   c                	    R # rl   r/   r  s   &&r1   get_proxy_dispatch_entry)HopSubgraphCache.get_proxy_dispatch_entry  s    LOr4   c               $    V ^8  d   QhRRRRRR/# r,   r  r   schemaztorch._C.FunctionSchemar-   r  r/   )r0   s   "r1   r2   r    s$      #:	r4   c                	    R # rl   r/   r:   r  r%  s   &&&r1   add_functionalize_schema_entry/HopSubgraphCache.add_functionalize_schema_entry   r  r4   c                    V ^8  d   QhRRRR/# r,   r  r   r-   ztorch._C.FunctionSchema | Noner/   )r0   s   "r1   r2   r    s     - --	'-r4   c                	    R # rl   r/   r:   r  s   &&r1   get_functionalize_schema_entry/HopSubgraphCache.get_functionalize_schema_entry  s     *-r4   c               (    V ^8  d   QhRRRRRRRR/# 	r,   r  r.   tangent_metadatatuple[object]gmodtorch.fx.GraphModuler-   rI   r/   )r0   s   "r1   r2   r    s2       ( #	
 
r4   c                	    R # rl   r/   )r:   r  r2  r4  s   &&&&r1   add_lazy_bwd_entry#HopSubgraphCache.add_lazy_bwd_entry
  s     r4   c               $    V ^8  d   QhRRRRRR/# r,   r  r.   r2  r3  r-   z.tuple[torch.fx.GraphModule | None, int | None]r/   )r0   s   "r1   r2   r    s$     = ==1>=	7=r4   c                	    R # rl   r/   r:   r  r2  s   &&&r1   get_lazy_bwd_entry#HopSubgraphCache.get_lazy_bwd_entry  s     :=r4   r/   N)rT   rU   rV   rW   r   r  r  r  r  r  r!  r(  r.  r7  r=  rZ   r/   r4   r1   r  r    s      R RQ QM MS SO O  - -   = =r4   r  c                  l    ] tR tRt$ R]R&   R]R&   R]R&   R]R	&   R
]R&   R]R&   R]R&   ^ tR]R&   RtR# )InvokeSubgraphReuseEntryi  r.   	body_namer5  	body_gmodz!NestedCompileRegionOptions | Nonerv   	list[Any]subgraph_input_mappingri   single_tensor_outputzIlist[tuple[torch.Size, tuple[int, ...], torch.dtype, torch.device, bool]]output_metadatazlist[Source | None]arg_sourcesrI   num_user_outputsr/   N)rT   rU   rV   rW   rX   rH  rZ   r/   r4   r1   r@  r@    sD    N##--    %$ cr4   r@  c                  j    ] tR tRt$ R]R&   R]R&   RtR]R&   ]P                  ! ]R	7      t	R
]R&   Rt
R# )InvokeSubgraphReuseConditioni2  zlist[tuple[Any, object]]input_checksz2list[tuple[Source, GuardCheckSpec, object, Guard]]r   Nzpytree.TreeSpec | Nonetreespec)default_factoryzOrderedSet[Source]traced_sourcesr/   )rT   rU   rV   rW   rX   rL  dataclassesfieldr   rN  rZ   r/   r4   r1   rJ  rJ  2  s7     +*
 ?> (,H$+
 *5):)::)VN&Vr4   rJ  c                      ] tR tRtR R ltR R ltR R ltR R	 ltR
 R ltR R lt	R R lt
R R ltR R ltR R ltR R ltR R ltR R ltR&R R lltR R ltR  R! ltR&R" R# lltR$tR%# )'InvokeSubgraphCacheiM  c                   V ^8  d   QhRR/# r,  r/   )r0   s   "r1   r2    InvokeSubgraphCache.__annotate__N  s      $ r4   c                	    / V n         / V n        / V n        \        \        4      V n        \        \        4      V n        / V n        \        \        4      V n	        \        \        4      V n
        R # rl   )autograd_cacheproxy_dispatch_cachefunctionalize_schema_cacher   r  dynamo_installed_submodulesrx  lazy_bwd_cacheeffects_cachesubgraph_reuse_cachesubgraph_reuse_key_cacherb   s   &r1   rJ  InvokeSubgraphCache.__init__N  sk    359;!QS'FQRVFW(  	
  	  	!  	%r4   c               $    V ^8  d   QhRRRRRR/# r  r/   )r0   s   "r1   r2   rT  e  s)     E EE-0E	Er4   c                	J    V P                   V,          P                  V4       R # rl   )rY  r  r  s   &&&r1   r  2InvokeSubgraphCache.add_dynamo_installed_submodulee  s     	((188Dr4   c                    V ^8  d   QhRRRR/# r	  r/   )r0   s   "r1   r2   rT  j  s     A Ax AI Ar4   c                	:    V P                   P                  V. 4      # rl   )rY  getr  s   &&r1   r  3InvokeSubgraphCache.get_dynamo_installed_submodulesj  s    //33GR@@r4   c               $    V ^8  d   QhRRRRRR/# r  r/   )r0   s   "r1   r2   rT  m  s!     . . .8 . .r4   c                	"    W P                   V&   R # rl   )rV  r  s   &&&r1   r  *InvokeSubgraphCache.add_autograd_key_entrym  s    *-J'r4   c                    V ^8  d   QhRRRR/# r  r/   )r0   s   "r1   r2   rT  p  s     9 9 9 9r4   c                	:    V P                   P                  VR 4      # rl   )rV  rd  r  s   &&r1   r  *InvokeSubgraphCache.get_autograd_key_entryp  s    ""&&z488r4   c               $    V ^8  d   QhRRRRRR/# r  r/   )r0   s   "r1   r2   rT  s  s!     4 43 4X 4$ 4r4   c                	"    W P                   V&   R # rl   )rW  r  s   &&&r1   r  ,InvokeSubgraphCache.add_proxy_dispatch_entrys  s    03!!*-r4   c                    V ^8  d   QhRRRR/# r  r/   )r0   s   "r1   r2   rT  v  s     ? ?3 ?? ?r4   c                	:    V P                   P                  VR 4      # rl   )rW  rd  r  s   &&r1   r!  ,InvokeSubgraphCache.get_proxy_dispatch_entryv  s    ((,,Z>>r4   c               $    V ^8  d   QhRRRRRR/# r$  r/   )r0   s   "r1   r2   rT  y  s$     6 66#:6	6r4   c                	"    W P                   V&   R # rl   )rX  r'  s   &&&r1   r(  2InvokeSubgraphCache.add_functionalize_schema_entryy  s     06'',r4   c                    V ^8  d   QhRRRR/# r+  r/   )r0   s   "r1   r2   rT  ~  s     > >>	'>r4   c                	:    V P                   P                  VR 4      # rl   )rX  rd  r-  s   &&r1   r.  2InvokeSubgraphCache.get_functionalize_schema_entry~  s     ..223==r4   c               (    V ^8  d   QhRRRRRRRR/# r1  r/   )r0   s   "r1   r2   rT    s2     	 		 (	 #		
 
	r4   c                	l    \        V P                  V,          4      pW43V P                  V,          V&   V# rl   )r   rZ  )r:   r  r2  r4  	num_gmodss   &&&& r1   r7  &InvokeSubgraphCache.add_lazy_bwd_entry  s8     ++J78	=A<MJ'(89r4   c               $    V ^8  d   QhRRRRRR/# r:  r/   )r0   s   "r1   r2   rT    s)     S SS1>S	7Sr4   c                	l    WP                   9  d   R# V P                   V,          P                  VR4      # )N)NN)rZ  rd  r<  s   &&&r1   r=  &InvokeSubgraphCache.get_lazy_bwd_entry  s5     000"":.223C\RRr4   c               $    V ^8  d   QhRRRRRR/# )r,   r  r.   effectsri  r-   r  r/   )r0   s   "r1   r2   rT    s!     
1 
1c 
1C 
1D 
1r4   c           	         V P                   P                  VR4      ;p'       d   W#8w  d   \        RV RV RV R24      hW P                   V&   R# )z>Store the effect types for a given invoke_subgraph identifier.NzPDifferent number of effects were found for invoke_subgraph call with identifier z,. 
Previously we had the following effects: z.
But now we have: .)r[  rd  r9   )r:   r  r  prev_effectss   &&& r1   add_effectsInvokeSubgraphCache.add_effects  sj    --11*dCC<C&$,,6< 8@@L~ N((/y3  *1:&r4   c                    V ^8  d   QhRRRR/# )r,   r  r.   r-   z
set | Noner/   )r0   s   "r1   r2   rT    s     8 8c 8j 8r4   c                :    V P                   P                  VR4      # )zARetrieve the effect types for a given invoke_subgraph identifier.N)r[  rd  r  s   &&r1   get_effectsInvokeSubgraphCache.get_effects  s    !!%%j$77r4   c          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )r,   r   r   	conditionrJ  entryr@  max_reuse_entriesrI   r-   r  r/   )r0   s   "r1   r2   rT    s<     + ++ 0+ (	+
 + 
+r4   c                	    V P                   V,          p\        V4      V8  d   \        R V RV R24      hVP                  W#34       R# )1invoke_subgraph: exceeded maximum reuse entries () for function code a?  . This most likely means a guard keeps failing on every invocation, preventing subgraph reuse. Set TORCH_LOGS='+hierarchical_compile' to identify which guard is failing. If reuse is genuinely not possible and you need more cache entries, increase the limit via the max_reuse_entries argument to nested_compile_region().N)r\  r   RuntimeErrorr  )r:   r   r  r  r  entriess   &&&&& r1   add_reuse_entry#InvokeSubgraphCache.add_reuse_entry  s^     ++G4w<,,%&&:7) DIJ	 	 		)*r4   c               $    V ^8  d   QhRRRRRR/# )r,   r   r   	evaluatorzHCallable[[InvokeSubgraphReuseCondition, InvokeSubgraphReuseEntry], bool]r-   InvokeSubgraphReuseEntry | Noner/   )r0   s   "r1   r2   rT    s(      
 
)r4   c                	    V P                   P                  V. 4      p\        V4       FB  w  pw  rVV! WV4      '       g   K  V^ 8  d"   VP                  ^ VP	                  V4      4       Vu # 	  R# rs   )r\  rd  	enumerateinsertpop)r:   r   r  r  ir  r  s   &&&    r1   find_reuse_entry$InvokeSubgraphCache.find_reuse_entry  se     ++//<%.w%7!A!	**q5NN1gkk!n5 &8 r4   c               $    V ^8  d   QhRRRRRR/# )r,   r   r   hash_keyrI   r-   r  r/   )r0   s   "r1   r2   rT    s)     L LL+.L	(Lr4   c                	X    V P                   P                  V/ 4      P                  V4      # rl   )r]  rd  )r:   r   r  s   &&&r1   find_reuse_entry_by_key+InvokeSubgraphCache.find_reuse_entry_by_key  s(     ,,00"=AA(KKr4   c          
     ,    V ^8  d   QhRRRRRRRRRR	/# )
r,   r   r   r  rI   r  r@  r  r-   r  r/   )r0   s   "r1   r2   rT    s<     $ $$ $ (	$
 $ 
$r4   c                	    V P                   V,          p\        V4      V8  d   W%9  d   \        R V RV R24      hW5V&   R# )r  r  zc (hash-key path). Increase the limit via the max_reuse_entries argument to nested_compile_region().N)r]  r   r  )r:   r   r  r  r  	key_caches   &&&&& r1   add_reuse_entry_by_key*InvokeSubgraphCache.add_reuse_entry_by_key  sZ     11':	y>..83L%&&:7) D+,  $(r4   )rV  rY  r[  rX  rZ  rW  r\  r]  N)   )rT   rU   rV   rW   rJ  r  r  r  r  r  r!  r(  r.  r7  r=  r  r  r  r  r  r  rZ   r/   r4   r1   rR  rR  M  s`    .E
A.94?6
>
	S
18+* L
$ $r4   rR  c                  .    ] tR tRtR R ltR R ltRtR# )HopDispatchSetCachei  c                   V ^8  d   QhRR/# r,  r/   )r0   s   "r1   r2    HopDispatchSetCache.__annotate__  s     F F$ Fr4   c                	4    ^ RI Hp V\        4       /V n        R# )r   )invoke_subgraphN)'torch._higher_order_ops.invoke_subgraphr  rR  hop_cache_map)r:   r  s   & r1   rJ  HopDispatchSetCache.__init__  s    K-/B/DEr4   c                    V ^8  d   QhRRRR/# )r,   opztorch._ops.HigherOrderOperatorr-   zHopSubgraphCache | Noner/   )r0   s   "r1   r2   r    s     & &: &?V &r4   c                	L    WP                   9  d   R # V P                   V,          # rl   r  )r:   r  s   &&r1   	get_cacheHopDispatchSetCache.get_cache  s"    '''!!"%%r4   r  N)rT   rU   rV   rW   rJ  r  rZ   r/   r4   r1   r  r    s    F& &r4   r  c                  z    ] tR tRt]R R l4       t]R R l4       tR R lt]R R	 l4       t]R
 R l4       t	Rt
R# )CompileContexti  c                   V ^8  d   QhRR/# )r,   r-   r  r/   )r0   s   "r1   r2   CompileContext.__annotate__  s     $ $ $r4   c                 	\    \         P                  f   \        R4      h\         P                  # )Nzcompile_context is not set)_TLScompile_contextr9   r/   r4   r1   rd  CompileContext.get  s&    ' !=>>###r4   c                   V ^8  d   QhRR/# )r,   r-   CompileContext | Noner/   )r0   s   "r1   r2   r         6 6* 6r4   c                 	$    \        \        R R4      # r  Ngetattrr  r/   r4   r1   try_getCompileContext.try_get      t.55r4   c                    V ^8  d   QhRRRR/# )r,   r?   rA   r-   r  r/   )r0   s   "r1   r2   r    s     . .#3 . .r4   c                	    Ve.   \        V\        4      '       g   \        R\        V4       24      hWn        ^ V n        . V n        R # )Nz*compile_id must be None or CompileId, got )r   r%   r9   r|  r?   r]   shape_env_guards)r:   r?   s   &&r1   rJ  CompileContext.__init__  sG    !*Z*K*K <T*=M<NO  -7+-r4   c                   V ^8  d   QhRR/# )r,   r-   rA   r/   )r0   s   "r1   r2   r    s       0 r4   c                 	N    \         P                  4       p V f   R # V P                  # rl   )r  r  r?   rb   s    r1   current_compile_id!CompileContext.current_compile_id  s"    %%'<r4   c                   V ^8  d   QhRR/# )r,   r-   zTraceId | Noner/   )r0   s   "r1   r2   r  !  s     6 6n 6r4   c                 	    \         P                  4       p V f   R # V P                  f   R # \        V P                  V P                  4      # rl   )r  r  r?   r\   r]   rb   s    r1   current_trace_idCompileContext.current_trace_id   s:    %%'<??"t55r4   )r]   r?   r  N)rT   rU   rV   rW   r#  rd  r  rJ  r  r  rZ   r/   r4   r1   r  r    sU    $ $
 6 6.   6 6r4   r  c                  :    ] tR tRt$ RtR]R&   R]R&   R]R&   R	tR
# )InlinedCodeCachei*  z8Cache for code-object-derived data used during inlining.rC  instructionszdict[Any, int]indexofr   code_optionsr/   N)rT   rU   rV   rW   r[  rX   rZ   r/   r4   r1   r  r  *  s    Br4   r  c                  l   ] tR tRtRt]R R l4       t]R R l4       tR R ltR	 R
 lt	]]
R R l4       4       t]R R l4       tR R lt]]P                  R R l4       4       t]]P                  R R l4       4       t]]P                  R R l4       4       t]RR R ll4       t]R R l4       tRtR# )r  i3  z
Provides the currently installed TracingContext, or None.

Note that it is a staticmethod, and invocations outside of `with tracing()` (see below), are valid but
will return None.
c                   V ^8  d   QhRR/# )r,   r-   TracingContext | Noner/   )r0   s   "r1   r2   TracingContext.__annotate__<  r  r4   c                 	$    \        \        R R4      # )tracing_contextNr  r/   r4   r1   r  TracingContext.try_get;  r  r4   c                   V ^8  d   QhRR/# )r,   r-   r  r/   )r0   s   "r1   r2   r  @  s     
 
 
r4   c                 	T    \         P                  4       ;p '       d   V # \        R 4      h)z<TracingContext.get() must be called within an ongoing trace.)r  r  r  )ctxs    r1   rd  TracingContext.get?  s+     ((**3*JJ
 	
r4   c                    V ^8  d   QhRRRR/# )r,   	fake_modeFakeTensorMode | Noner-   r  r/   )r0   s   "r1   r2   r  G  s     5. 5."7 5.D 5.r4   c                	   \        4       V n        \        4       V n        \	        4       V n        \        4       V n        \        4       V n        \        4       V n	        Wn
        . V n        R V n        R V n        R V n        R V n        R V n        R V n        R V n        R V n        R V n        RV n        \-        4       V n        RV n        \3        4       V n        . V n        R V n        R # )NF)r  guards_contextrq  module_contextr  global_contextrx  previously_inlined_functionspreviously_cleaned_instructionsinlined_code_cacher  frame_summary_stackloc_in_frameloc_in_frame_positionsfw_metadataddp_optimizer_ctxaot_graph_nameparams_flatparams_flat_unwrap_subclassesparams_unwrapped_to_flat_indexoutput_strides#force_unspec_int_unbacked_size_liker   tensor_to_contextfakify_first_callr  hop_dispatch_set_cachetraced_codecudagraph_annotation)r:   r  s   &&r1   rJ  TracingContext.__init__G  s    +o+o+o<@F)?Cv,?Cv09AC  :><@#7;=A04-1?C*@D+ DH 490!8!:
 "'&9&;#+-)-!r4   c                   V ^8  d   QhRR/# r,  r/   )r0   s   "r1   r2   r  ~  s     ( (t (r4   c                	    / V P                   n        V P                  P                  4        V P                  P                  4        V P
                  P                  4        R # rl   )r  r  r  r  r  r  rb   s   &r1   r  TracingContext.clear~  sH     ,.())//1,,224%%'r4   c                    V ^8  d   QhRRRR/# )r,   kwargsr   r-   r  r/   )r0   s   "r1   r2   r    s     ' ' ' ; 'r4   c               +  	X  "   / p\         P                  4       pV  F  p\        W#4      W&   K  	  V P                  4        F  w  r4\	        W#V4       K  	   R x  VP                  4        F  w  r4\	        W#V4       K  	  R #   TP                  4        F  w  r4\	        Y#T4       K  	  i ; i5irl   )r  rd  r  rH   setattr)r  priorr  r  vals   ,    r1   patchTracingContext.patch  s        "C *EJ  HCCc" '	'!KKM#& *EKKM#& *s   AB*B  'B* 'B''B*c                   V ^8  d   QhRR/# )r,   r-   ztraceback.StackSummaryr/   )r0   s   "r1   r2   r    s     7 71 7r4   c                 	    \         P                  4       p V f   \        P                  ! 4       # V P                  pV P
                  e   WP                  4       .,           p\        P                  P                  V4      # rl   )r  r  	tracebackStackSummaryr  r  _populate_loc_in_frame_summary	from_list)r:   r   s     r1   r  TracingContext.extract_stack  sf    %%'<))++(((@@BCCE%%//66r4   c                   V ^8  d   QhRR/# )r,   r-   ztraceback.FrameSummaryr/   )r0   s   "r1   r2   r    s     
 
0F 
r4   c                	6   V P                   f   \        R4      hV P                   w  rp/ p\        P                  R8  dA   V P                  e3   V P                  P
                  VR&   V P                  P                  VR&   \        P                  ! VVV3RR/VB # )Nzloc_in_frame must not be Nonecolno	end_colnolookup_lineF)      )	r  r9   sysversion_infor  
col_offsetend_col_offsetr  FrameSummary)r:   filenamelineno
frame_namer  s   &    r1   r  -TracingContext._populate_loc_in_frame_summary  s    $ !@AA'+'8'8$*!#w&4+F+F+R"99DDF7O"&"="="L"LF;%%
 	

 
 	
r4   c                   V ^8  d   QhRR/# r  r/   )r0   s   "r1   r2   r    s      4 r4   c               #  	x  "   \         P                  4       p \        P                  P                  P                  V R . 4      ;_uu_ 4        \        P                  P                  P                  V RR4      ;_uu_ 4        \        P                  P                  P                  V RR4      ;_uu_ 4         Rx   RRR4       RRR4       RRR4       R#   \         d    p\        TR4      '       g   RTn        h Rp?ii ; i  + '       g   i     LO; i  + '       g   i     LZ; i  + '       g   i     R# ; i5i)r  r  Nr  
real_stack)	r  rd  unittestmockr  r   rK   hasattrr&  )tcrQ   s     r1   clear_frameTracingContext.clear_frame  s      !MM&&r+@"EEMM&&r>4@@MM&&r+CTJJ K A FE  $ q,//#'AL)	 KJ A@ FEEsl   AD:
4D&>4D	2D 4C9D	D&	
D:C=C88C==D  DD	D#D&&D7	1	D:c                    V ^8  d   QhRRRR/# )r,   frame_summaryztraceback.FrameSummary | Noner-   r  r/   )r0   s   "r1   r2   r    s     6 646	$6r4   c              #  	  "   \         P                  4       pV e   VP                  P                  V 4       VP                  pVP
                  pR Vn        R Vn         R x   T e   TP                  P                  4        Y!n        Y1n        R #   \         d.   p\        TR4      '       g   TP                  4       Tn	        h R p?ii ; i  T e   TP                  P                  4        Y!n        Y1n        i ; i5i)Nr&  )r  rd  r  r  r  r  rK   r)  r  r&  r  )r.  r*  r  old_positionsrQ   s   &    r1   current_frameTracingContext.current_frame  s      !$""))-8oo11$(!
	6 (&&**,!O(5%  	1l++!//1	
 (&&**,!O(5%s6   AC8B ",C8C(CCC	 	,C55C8c                   V ^8  d   QhRR/# )r,   r-   z:Generator[list[tuple[int, ...] | None] | None, None, None]r/   )r0   s   "r1   r2   r    s     3 3 $ 3r4   c               #  	   "   \         P                  4       p V f   R x  R # V P                  p. V n         V P                  x  Wn        R #   Yn        i ; i5irl   )r  r  r  )r*  old_output_stridess     r1   report_output_strides$TracingContext.report_output_strides  sT     
 ##%:J..	3### 2 2s   2AA AAANc          
     ,    V ^8  d   QhRRRRRRRRRR	/# )
r,   r   r.   r!  rI   r"  	positionszdis.Positions | Noner-   r  r/   )r0   s   "r1   r2   r     s:     
. 
.
.
. 
. (	
.
 

.r4   c                	L    \         P                  4       pWV3Vn        W4n        R # rl   )r  rd  r  r  )r   r!  r"  r9  r*  s   &&&& r1   set_current_locTracingContext.set_current_loc  s$     !#Z8$-!r4   c                   V ^8  d   QhRR/# )r,   r-   zlist[CodeType] | Noner/   )r0   s   "r1   r2   r    s      2 r4   c                 	N    \         P                  4       p V f   R # V P                  # rl   )r  r  r  )r*  s    r1   get_traced_codeTracingContext.get_traced_code  s"    ##%:~~r4   )r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rl   )rT   rU   rV   rW   r[  r#  r  rd  rJ  r  r   r  r  r  r  r+  r1  r6  r;  r?  rZ   r/   r4   r1   r  r  3  s     6 6 
 
5.n( '  ' 7 7
&   > 6  60 3  3 
. 
.  r4   r  c                    V ^8  d   QhRRRR/# )r,   contextr  r-   z,Generator[CompileContext | None, None, None]r/   )r0   s   "r1   r2   r2     s     + +"+1+r4   c              #     "   \        \        R R4      pV \        n         V x  V\        n        R#   T\        n        i ; i5ir  )r  r  r  )rB  old_contexts   & r1   r  r    s8      $ 148K"D+*{s   A1 A>Ac                    V ^8  d   QhRRRR/# )r,   rB  r  r-   z,Generator[TracingContext | None, None, None]r/   )r0   s   "r1   r2   r2   !  s     + +"+1+r4   c              #  >  "   \        \        RR4      pV \        n         V x   T eK   T P                  e=   T P                  P                  e%   T P                  P                  P                  4        T\        n        R#   \         d2   p\	        TR4      '       g   T e   T P                  4       Tn        h Rp?ii ; i  T eK   T P                  e=   T P                  P                  e%   T P                  P                  P                  4        T\        n        i ; i5i)z
This function installs the passed in tracing context as a dynamic scoped
global variable.

Calls to TracingContext.get() while not under a `with tracing()` context
will return None.
r  Nr&  )
r  r  r  rK   r)  r  r&  r  	shape_envcleanup)rB  rD  rQ   s   &  r1   tracingrI     s      $ 148K"D+ !!-!!++7''//1*  q,''G,?"002AL !!-!!++7''//1*s5   DB  AD B<,B77B<<B? ?ADDc               $    V ^8  d   QhRRRRRR/# )r,   rL   type[T]r  r   r-   r/   )r0   s   "r1   r2   r2   >  s     K KG Ks Kw Kr4   c                    R # rl   r/   rL   r  s   &,r1   dataclass_with_cached_hashrN  =  s    HKr4   c               $    V ^8  d   QhRRRRRR/# )r,   rL   r  r  r   r-   zCallable[[type[T]], type[T]]r/   )r0   s   "r1   r2   r2   B  s$     ' '	' #'!'r4   c                    R # rl   r/   rM  s   &,r1   rN  rN  A  s     $'r4   c               $    V ^8  d   QhRRRRRR/# )r,   rL   ztype[T] | Noner  r   r-   z&type[T] | Callable[[type[T]], type[T]]r/   )r0   s   "r1   r2   r2   H  s$      	*-+r4   c                2   a R  V3R llpV f   V# V! V 4      # )c                    V ^8  d   QhRRRR/# )r,   	cls_innerrK  r-   r/   )r0   s   "r1   r2   0dataclass_with_cached_hash.<locals>.__annotate__K  s       G r4   c                   <a \         P                  ! V 3/ SB pV P                  oR  V3R llpR pW!n        W1n        V# )c                   V ^8  d   QhRR/# r   r/   )r0   s   "r1   r2   >dataclass_with_cached_hash.<locals>.wrap.<locals>.__annotate__O  s     	 	c 	r4   c                z   < \        V R 4      '       g   \        P                  V R S! V 4      4       V P                  # )r   )r)  r   __setattr__r   )r:   old_hashs   &r1   r   :dataclass_with_cached_hash.<locals>.wrap.<locals>.__hash__O  s0    4))""4(4.A::r4   c                   a  \         P                  ! S 4      p\        ;QJ d    . V 3R  lV 4       F  NK  	  5M! V 3R  lV 4       4      pS P                  V3# )c              3  v   <"   T F.  qP                   '       g   K  \        SVP                  4      x  K0  	  R # 5irl   )initr  r   )r  fr:   s   & r1   r  Odataclass_with_cached_hash.<locals>.wrap.<locals>.__reduce__.<locals>.<genexpr>Y  s&      Q1&&!6qvv!6!6s   99)rO  fieldstupler   )r:   rb  field_valuess   f  r1   
__reduce__<dataclass_with_cached_hash.<locals>.wrap.<locals>.__reduce__T  sB     !''-F 5 Q Q55 Q QQLNNL11r4   )rO  r   r   re  )rT  new_clsr   re  r[  r  s   &   @r1   wrap(dataclass_with_cached_hash.<locals>.wrapK  sE    ''	<V<%%	 	
	2 $'r4   r/   )rL   r  rh  s   &l r1   rN  rN  G  s#     * {9r4   c                      ] tR tRtR R ltR R ltR R ltR R	 lt]P                  R
 R l4       t
]R R l4       t]P                  R R l4       tR R ltR R ltR R ltR R ltRR R lltRtR# )r   ih  c                   V ^8  d   QhRR/# rh   r/   )r0   s   "r1   r2   Source.__annotate__j  s      T r4   c                	    R # Fr/   rb   s   &r1   is_dict_keySource.is_dict_keyj      r4   c                   V ^8  d   QhRR/# rh   r/   )r0   s   "r1   r2   rl  m  s      d r4   c                	    R # rn  r/   rb   s   &r1   is_ephemeralSource.is_ephemeralm  rq  r4   c                    V ^8  d   QhRRRR/# )r,   codegenr   r-   r  r/   )r0   s   "r1   r2   rl  p  s     " "9 " "r4   c                	    \         hrl   NotImplementedErrorr:   rw  s   &&r1   reconstructSource.reconstructp  s    !!r4   c                    V ^8  d   QhRRRR/# )r,   rw  r   r-   r.   r/   )r0   s   "r1   r2   rl  s  s     " ") " "r4   c                    \         h)z
Reconstructs the source into a string of Python code. This method should
be eventually implemented for all subclasses of Source to achieve full
coverage of python wrapper code generation.
ry  r{  s   &&r1   reconstruct_pycodeSource.reconstruct_pycodes  s
     "!r4   c                   V ^8  d   QhRR/# r   r/   )r0   s   "r1   r2   rl  |  s     " "k "r4   c                	    \         hrl   ry  rb   s   &r1   r   Source.guard_source{  s    !!r4   c                   V ^8  d   QhRR/# r+   r/   )r0   s   "r1   r2   rl    s     " " "r4   c                    \         h)a  
A template for the name of the source. Used to prevent code duplication between
`name` and `get_value`.

For non-ChainedSources, `name` and `get_value` use the returned string directly.

For ChainedSources, `name` and `get_value` expect the return to be a format string
with `{0}` present - `name` and `get_value` will apply different values to this function's
returned format string.
ry  rb   s   &r1   _name_templateSource._name_template  s
     "!r4   c                   V ^8  d   QhRR/# r+   r/   )r0   s   "r1   r2   rl    s     # #c #r4   c                	    V P                   # rl   )r  rb   s   &r1   r   Source.name  s    """r4   c               (    V ^8  d   QhRRRRRRRR/# r,   globalszdict[str, Any]localscachezdict[Source, Any]r-   r   r/   )r0   s   "r1   r2   rl    s2     
 

 
 !	

 

r4   c                	V    W9   d	   W0,          # \        V P                  W4      pWCV &   V# rl   )evalr  )r:   r  r  r  r   s   &&&& r1   	get_valueSource.get_value  s/     =;T((':dr4   c                    V ^8  d   QhRRRR/# )r,   fnzCallable[..., Any]r-   r   r/   )r0   s   "r1   r2   rl    s      / E r4   c                	`    V P                   \        P                  J d   \        h\	        W4      # rl   )r   rf   r   rz  r   )r:   r  s   &&r1   
make_guardSource.make_guard  s&     4 44%%Tr4   c                   V ^8  d   QhRR/# rh   r/   )r0   s   "r1   r2   rl    s     < <$ <r4   c                	6    V P                   P                  4       # rl   )r   rz   rb   s   &r1   rz   Source.is_specialized_nn_module  s      99;;r4   c                   V ^8  d   QhRR/# rh   r/   )r0   s   "r1   r2   rl    s     @ @4 @r4   c                <    V P                   \        P                  8g  # )z+True if you can guard on attributes of this)r   rf   r   rb   s   &r1   subguards_allowedSource.subguards_allowed  s      K$?$???r4   Nc                    V ^8  d   QhRRRR/# r,   transform_fnz!Callable[[Source], Source] | Noner-   r   r/   )r0   s   "r1   r2   rl    s      "C v r4   c                	    Ve	   V! V 4      # V # rl   r/   )r:   r  s   &&r1   cloneSource.clone  s     #%%r4   r/   rl   )rT   rU   rV   rW   ro  rt  r|  r  r   cached_propertyr   r"  r  r   r  r  rz   r  r  rZ   r/   r4   r1   r   r   h  s}    "" " " " " # #

<@ r4   r   c                      ] tR tRt$ R]R&   R R ltR R lt]P                  R R	 l4       t	R
 R lt
]P                  R R l4       tR R ltRR R lltRtR# )ChainedSourcei  r   basec                   V ^8  d   QhRR/# rh   r/   )r0   s   "r1   r2   ChainedSource.__annotate__  s     ' 'T 'r4   c                	6    V P                   P                  4       # rl   )r  ro  rb   s   &r1   ro  ChainedSource.is_dict_key  s    yy$$&&r4   c                   V ^8  d   QhRR/# rh   r/   )r0   s   "r1   r2   r    s     ( (d (r4   c                	6    V P                   P                  4       # rl   )r  rt  rb   s   &r1   rt  ChainedSource.is_ephemeral  s    yy%%''r4   c                   V ^8  d   QhRR/# r   r/   )r0   s   "r1   r2   r    s     & &k &r4   c                	.    V P                   P                  # rl   )r  r   rb   s   &r1   r   ChainedSource.guard_source  s    yy%%%r4   c                   V ^8  d   QhRR/# )r,   r-   r   r/   )r0   s   "r1   r2   r    s      & r4   c                	R    T p\        V\        4      '       d   VP                  pK$  V# rl   )r   r  r  )r:   currents   & r1   get_baseChainedSource.get_base  s"    -00llGr4   c                   V ^8  d   QhRR/# r+   r/   )r0   s   "r1   r2   r    s     : :c :r4   c                	`    V P                   P                  V P                  P                  4      # rl   )r  r0   r  r   rb   s   &r1   r   ChainedSource.name  s!    ""))$))..99r4   c               (    V ^8  d   QhRRRRRRRR/# r  r/   )r0   s   "r1   r2   r    s2        !	
 
r4   c                	    W9   d	   W0,          # R p^ pWB9   d   R V 2pV^,          pK  V P                   P                  WV4      W$&   \        V P                  P	                  V4      W4      pW$ WcV &   V# )tmp)r  r  r  r  r0   )r:   r  r  r  tmpvarcounterr   s   &&&&   r1   r  ChainedSource.get_value  s{     =;7)_FqLG,,WeDT((//7INdr4   Nc                    V ^8  d   QhRRRR/# r  r/   )r0   s   "r1   r2   r    s      "C v r4   c                	z   R V P                   P                  V4      /p\        P                  ! V 4       F`  pVP                  R 8X  d   K  \        WP                  4      p\        V\        4      '       g   KC  VP                  V4      W#P                  &   Kb  	  \        P                  ! V 3/ VB pVe	   V! V4      pV# )r  )	r  r  rO  rb  r   r  r   r   replace)r:   r  cloned_fieldsr`  r
  results   &&    r1   r  ChainedSource.clone  s    )/1N(O##D)Avv$'C#v&&(+		,(?ff% * $$T;];#!&)Fr4   r/   rl   )rT   rU   rV   rW   rX   ro  rt  r   r  r   r  r   r  r  rZ   r/   r4   r1   r  r    sY    
L'( & & : :& r4   r  c                    V ^8  d   QhRRRR/# )r,   inputsr   r-   r  r/   )r0   s   "r1   r2   r2     s     > >S >,A >r4   c                   ^ RI HpHpHp \        P                  4       ;p'       d   VP                  pVe   V# . p^ RIHp \        \        V! 4       4      4       F,  w  r\        W4      '       g   K  VP                  V	RV34       K.  	  \        P                  ! V 4      p
\        V
4       F  w  r\        W4      '       d   VP                  VP                  RV34       \        V4      '       g   KG  . pV! WR7       V Uu. uF  p\        W4      '       g   K  VNK  	  ppTP!                  \        V4       UUu. uF  w  ppVP                  RV 2V3NK  	  upp4       K  	  V'       dl   V^ ,          w  pppVR,           FO  w  p	ppWYJg   K  \#        R	V R
V RV RV	 R
V RV RV RV RVP$                   RV RV RV	P$                   24      h	  V# R# u upi u uppi )ax  
Attempts to "detect" what the current fake mode is.  If there is one ambiently
available from TracingContext, we preferentially use that.  Otherwise, we
heuristically detect the fake mode via the following sources, in order of
priority:

    - Currently active fake mode on stack
    - Fake mode associated with passed in tensors (inputs does not
      have to be flattened)
)
FakeTensorr    get_plain_tensorsN _get_current_dispatch_mode_stackzactive fake modezfake tensor input)outzsubclass input :r   NNzfake mode (z) from r   z doesn't match mode (z

fake mode from z allocated at:
z
fake mode from )torch._subclasses.fake_tensorr  r    r  r  r  r  torch.utils._python_dispatchr  r  reversedr   r  pytreetree_leavesr   r  r9   r   )r  r  r    r  rB  r  
fake_modesr  r  mflat_inputs
flat_inputr  xfake_tensorsixtensordesc1i1desc2i2s   &                    r1   detect_fake_moder    s     !((**w*%%	 JM(#C#EFGa((q"4a89 H $$V,K";/j--z335H!LM(44;=Cj2.a*Q";3  .  '0&=&=
F %%'<bA&= 0  )!}	5"&rNNLAub!$!)GE7!B4?TUVTWW^_d^eefgifj k&&+WAbT1A)//AR S&&+WAbT1A!''L  + -.s   GG:Gc                   V ^8  d   QhRR/# )r,   r-   r  r/   )r0   s   "r1   r2   r2   -  s      / r4   c                     ^ RI Hp  ^ RIHp \	        \        V! 4       4      4       F  w  r#\        W04      '       g   K  Vu # 	  R# )zr
Inspects the dispatch mode stack for an active fake mode and returns it.
Returns None if no fake mode is active.
r   r  N)r  r    r  r  r  r  r   )r    r  ra   r  s       r1   active_fake_moder  -  s:    
 =M(#C#EFGa((H H r4   rl   )k
__future__r   r  rO  enumr   loggingrer  	threadingr  unittest.mockr'  r   abcr   collectionsr   r   r   typingr   r	   r
   r   r   r   typing_extensionsr   r   torch.utilsr   r  torch.utils._ordered_setr   r  r   torch.utils._tracebackr   r   torch.utils.weakr   	getLoggerrT   r  discollections.abcr   r   r   typesr   sympy"torch._dynamo.backends.distributedr   torch._dynamo.codegenr   torch._dynamo.guardsr   torch._dynamo.output_graphr   &torch._functorch._aot_autograd.schemasr   r  r   r  r    compilerD   rE   r%   r\   Enumrf   r   r   r   r   r$  r&  r(  r2  r6  rC  r]  rq  r  r  r  r  r  r@  rJ  rR  r  localr  r  r  r  r  rI  rN  r   r  r  r  r/   r4   r1   <module>r     s   "      	 
      # % ! M M 1  ) / F B 4 ! ==F/36JR< ZZ PQ 

X " $D17J 7J 27Jt7j 7<
$)) <
~	 	 d#  $$  T"u' u' #u'p CL d#	 	 $	 d#	l 	 $	 d#*\ * $*

8WQZ 8( (8( (0+N#?@ +( (0$N#?@ $RC. C.L<N#89 <2*= *=Z   2 W W W4R$* R$j
& 
& &#6 #6L   ^ ^B + + + +8 
 K 
 K 
' 
'
  @ 4(E E )ER 4(6F 6 )6r>Br4   