a
    h4                     @   st  d Z ddlZddlZddlZddlZddlZddlmZ ddlm	Z	 ddl
mZmZmZ ddlZddlmZmZmZ ddlmZmZmZmZ dd	lmZ dd
lmZmZ ddlmZm Z m!Z!m"Z" ddlm#Z#m$Z$m%Z% ddl&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z- ddl.m/Z/ erddl0m1Z1 dd Z2dd Z3G dd dZ4ej5ddddZ6ej5ddddZ7ej5ddddZ8dS )a  
Side effect tracking and management for TorchDynamo's compilation system.

This module provides infrastructure for tracking and managing side effects that occur
during symbolic execution, including:

- Tracking mutations to objects, attributes, and variables
- Managing context changes (cell variables, global namespace modifications)
- Handling aliasing and object identity preservation
- Managing stack frame state and local variable changes
- Tracking function calls with side effects

Key classes:
- SideEffects: Main container for tracking all side effects during execution
- MutableSideEffects: Specialization for mutable object tracking
- AttributeMutation/ValueMutation: Track specific types of mutations
- Various specialized side effect classes for different scenarios

The side effect system ensures that mutations performed during symbolic execution
are properly replayed during runtime, maintaining the correctness of compiled code
while enabling optimizations where safe.
    N)MutableMapping)CellType)AnyOptionalTYPE_CHECKING   )graph_break_hintsutils	variables)bytecode_from_templatecreate_call_functioncreate_call_methodcreate_instruction)	PyCodegen)SideEffectsErrorunimplemented_v2)GlobalSourceLocalCellSourceLocalSourceSource)is_frozen_dataclassnn_module_new
object_new)AttributeMutationAttributeMutationExistingAttributeMutationNewis_side_effect_safeValueMutationExistingValueMutationNewVariableTracker)FrozenDataClassVariable)InstructionTranslatorc                 C   s<   t |j| }|| |  D ]\}}|||| q d S N)type__mro__clearitems__setitem__)	dict_fromdict_to	mro_index
dict_classkv r.   H/var/www/auris/lib/python3.9/site-packages/torch/_dynamo/side_effects.py_manual_dict_setitem@   s    
r0   c                 C   s   t | t ||  d S r"   )listr%   extend)	list_fromlist_tor.   r.   r/   _manual_list_updateK   s    
r5   c                       s*  e Zd ZU dZeeef ed< eeeeef f ed< e	e
 ed< dh fdd	Zeedd	d
Zd ee dddZdd Zdd Zdd Zdd Zdd Zdd Zdd ZeeedddZdidd Zd!d" Zd#d$ Zeed%d&d'Zeeed(d)d*Zed+d, Zd-d. Z d/d0 Z!d1d2 Z"d3d4 Z#e$fe
ed5d6d7Z%e%Z&e
ed5d8d9Z'e(e
e
d:d;d<Z)d=d> Z*d?d@ Z+dAdB Z,dCdD Z-ee( e.edEdFdGZ/e(e
dHdIdJZ0dKdL Z1dMdN Z2dOdP Z3dQdR Z4dSdT Z5dUdV Z6e7dWdXdYZ8dZd[ Z9d\d] Z:d^d_ Z;d`da Z<e7dWdbdcZ=ddde Z>dfdg Z?  Z@S )jSideEffectsah  
    Maintain records of mutations and provide methods to apply them during code generation.

    Handles tracking and applying side effects during PyTorch Dynamo compilation,
    maintaining Python semantics by managing mutations, attribute modifications,
    and other side effects that occur during program execution.

    Key responsibilities:
    - Tracks mutations to Python objects, lists, and dictionaries that need to be
    applied after an FX graph is run.
    - Manages attribute modifications and deletions
    - Handles tensor hooks and backward pass state
    - Tracks cell variable mutations and global variable changes
    - Ensures correct ordering and application of side effects after graph execution

    This ensures that optimized code behaves identically to the original Python code with
    respect to object mutations and other side effects.
    id_to_variablestore_attr_mutations	keepaliveNc                    sX   t    t|| _|pi | _|p&i | _|p0g | _|p:g | _|pDi | _	d| _
d | _d S )NF)super__init__weakrefrefoutput_graph_weakrefr7   r8   r9   save_for_backwardtensor_hooks_has_existing_dict_mutationca_final_callbacks_var)selfoutput_graphr7   r8   r9   r?   r@   	__class__r.   r/   r;   h   s    	





zSideEffects.__init__)otherreturnc                 C   s>   t |tsJ | j|jko<| j|jko<| j|jko<| j|jkS r"   )
isinstancer6   r7   r8   r?   r@   )rC   rG   r.   r.   r/   __eq__   s    


zSideEffects.__eq__c                 C   s   | j |j kr<| j  }|j  }||kr8d| d| S dS | j|jkrx| j }|j }||krtd| d| S dS | j|jkrdS | j|jkrdS d S d S )Nzid_to_variable keys: z != zid_to_variable: unknown diffzstore_attr_mutations keys: z"store_attr_mutations: unknown diffr?   r@   )r7   keysr8   r?   r@   )rC   rG   Zsk_itvZok_itvZsk_samZok_samr.   r.   r/   diff   s"    



zSideEffects.diffc                 C   s:   | j |  t| jdd | j D t| j| j| j	dS )zCreate a shallow copyc                 S   s   i | ]\}}|t |qS r.   )dict.0r,   r-   r.   r.   r/   
<dictcomp>   s   z%SideEffects.clone.<locals>.<dictcomp>)rD   r7   r8   r9   r?   r@   )
rF   r>   rM   r7   r8   r&   r1   r9   r?   r@   rC   r.   r.   r/   clone   s    zSideEffects.clonec                 C   s   t || jv S r"   )idr7   rC   itemr.   r.   r/   __contains__   s    zSideEffects.__contains__c                 C   s   | j t| S r"   )r7   rS   rT   r.   r.   r/   __getitem__   s    zSideEffects.__getitem__c                 C   s$   |   }|o"|jjjjo"|jjjjS r"   )r>   
current_txoutputcurrent_tracerunder_activation_checkpoint#allow_side_effects_under_checkpointrC   rD   r.   r.   r/   *should_allow_side_effects_under_checkpoint   s    

z6SideEffects.should_allow_side_effects_under_checkpointc                 C   s   |   }|o|jjjjS r"   )r>   rX   rY   rZ   ,unsafe_allow_externally_visible_side_effectsr]   r.   r.   r/   9should_allow_externally_visible_side_effects_in_subtracer   s    
zESideEffects.should_allow_externally_visible_side_effects_in_subtracerc                 C   s   |   }|o|jjjjS r"   )r>   rX   rY   rZ   is_reconstructing_generatorr]   r.   r.   r/   ra      s    
z'SideEffects.is_reconstructing_generatorc                 C   s`   ddl m} t||rdS |  r&dS |  r2dS |  rBtdt|js\t	dddg d d S )	Nr   )AutogradFunctionContextVariableTzCannot reconstruct a generator with variable mutations. Dynamo needs to fully exhaust the generator, which may cause unintended variable modifications.zOHigherOrderOperator: Mutating a variable not in the current scope (SideEffects) This is not supported.Zgb_typecontextZexplanationhints)
Ztorch._dynamo.variables.miscrb   rI   r`   r^   ra   r   r   mutation_typer   )rC   rU   rb   r.   r.   r/   check_allowed_side_effect   s$    

z%SideEffects.check_allowed_side_effect)rU   namevaluec                 C   s>   |  |sJ | | || jvr,i | j|< || j| |< d S r"   )is_attribute_mutationri   r8   )rC   rU   rj   rk   r.   r.   r/   
store_attr   s
    


zSideEffects.store_attrFc                 C   sV   |r|  |sJ | j| | }|sRt|tjrRtdd| d| dg tjd |S )Nz$Attempted to read a deleted variablezitem: z, name: rc   re   )rl   r8   rI   r
   DeletedVariabler   r   
USER_ERROR)rC   rU   rj   Z
deleted_okcheckresultr.   r.   r/   	load_attr   s    zSideEffects.load_attrc                 C   s\   |  r*tdd| d| dg tjd t|tjs:J t|tjsJJ | |d| d S )NzWrite to immutable cellz	cellvar: z	, value: zFDynamo doesn't support writing to immutable/sourceless cell variables.re   cell_contents)	is_immutabler   r   Z	DIFFICULTrI   r
   CellVariabler   rm   )rC   cellvarrk   r.   r.   r/   
store_cell   s    zSideEffects.store_cellc                 C   sV   t |tjsJ | |dr,| j|dddS |jr8|jS tdt|dg tj	d d S )Nrs   F)rp   zRead uninitialized cellzBAttempted to read a cell variable that has not been populated yet.re   )
rI   r
   ru   has_pending_mutation_of_attrrr   pre_existing_contentsr   strr   ro   )rC   rv   r.   r.   r/   	load_cell  s    zSideEffects.load_cell)gvarrj   c                 C   s   t |tjsJ | ||S r"   )rI   r
   r   rr   )rC   r|   rj   r.   r.   r/   load_global  s    zSideEffects.load_global)r|   rj   rk   c                 C   s2   t |tjsJ t |tjs J | ||| d S r"   )rI   r
   r   rm   )rC   r|   rj   rk   r.   r.   r/   store_global  s    zSideEffects.store_globalc                 C   s.   t | dd tjtjtjtjtjtjt	jfv S )N__getattribute__)
inspectgetattr_staticobjectr   rM   intrz   r1   tupleBaseException)clsr.   r.   r/   "cls_supports_mutation_side_effects  s    z.SideEffects.cls_supports_mutation_side_effectsc                 C   s   t |jtS r"   )rI   rh   r   rT   r.   r.   r/   rl   '  s    z!SideEffects.is_attribute_mutationc                 C   s   |  |ot| j|S r"   )rl   boolr8   getrT   r.   r.   r/   has_pending_mutation*  s    
z SideEffects.has_pending_mutationc                 C   s   |  |o|| j|dv S )Nr.   )rl   r8   r   )rC   rU   rj   r.   r.   r/   rx   /  s
    z(SideEffects.has_pending_mutation_of_attrc                 C   s\   |  rdS t|jttfr dS t|tjr@|| jv p>|| S | 	|rT|| jv S |jj
S )NFT)rt   rI   rh   r   r   r
   UserDefinedObjectVariabler8   Zis_underlying_vt_modifiedrl   is_modifiedrT   r.   r.   r/   r   4  s    

zSideEffects.is_modified)rU   variablec                 C   s\   t || jv r6t| d|j d| jt | j d| |_|| jt |< | j| |S )z7Start tracking an existing or new variable for mutationz is already tracked for mutation. This could be because you are not using VariableBuilder to construct the variable tracker. Source of new object: z'. Source of previously tracked object: .)rS   r7   AssertionErrorsourcerh   r9   append)rC   rU   r   mutation_type_clsr.   r.   r/   
_track_objE  s    zSideEffects._track_objc                 C   s   | j ||tdS )N)r   )r   r   )rC   rU   r   r.   r.   r/   track_object_existing\  s
    z!SideEffects.track_object_existing)
cls_sourceuser_clsvariable_clsc                 C   s   |t jjju rFtjdd t j }W d    qN1 s:0    Y  nt|}||fdt|i|}|| j	t
|< | j| |S )NT)recordrh   )torchZautogradfunctionZFunctionCtxwarningscatch_warningsZFunctionr   r   r7   rS   r9   r   )rC   r   r   r   optionsobjr   r.   r.   r/   track_object_newg  s    *zSideEffects.track_object_newc                 C   s
  ddl m} ddlm} ddlm} ddlm} tj	}t
||rP||rP|}nt|drrt|drr||sr|}nt
|tjjrtj}nlt
|ttjfrtj}nTt
|trtj}nBt
|trtj}n0t
|trtj}nt|rt}nt
|trtj}t
|tj	sJ |S )	Nr   )TorchFunctionModer   )GenericContextWrappingVariable)TorchFunctionModeVariable)is_forbidden_context_manager	__enter____exit__)Ztorch.overridesr   Zvariables.ctx_managerr   Zvariables.torch_functionr   variables.user_definedr   r
   r   
issubclassZ is_supported_torch_function_modehasattrr   nnModuleZUnspecializedNNModuleVariablerM   collectionsOrderedDictUserDefinedDictVariabler   ZUserDefinedTupleVariabler1   UserDefinedListVariabler   ZMutableMappingVariabler   r    r   Z"UserDefinedExceptionObjectVariable)rC   r   r   r   r   r   r   r.   r.   r/   get_variable_cls|  sF    



zSideEffects.get_variable_clsc                 C   st   |j }t|tjjrt|}nRt|tjr2|j	}n"t|tj
rF|j }ntd| tj
|jsfJ ||}|S )NzUnexpected base_cls_vt )rk   r   r   r   r   r   rI   r
   ZBuiltinVariablefnZUserDefinedClassVariableRuntimeErrorZis_supported_new_method__new__)rC   base_cls_vtcls_vt	init_argsr   r   Zbase_clsr.   r.   r/   get_example_value  s    


zSideEffects.get_example_valuec           	      C   sZ   |j }|j}| |}| |||}|||j ||t|d}|| jt|< | j| |S )aM  
        Creates a UserDefinedObjectVariable (or its subclass) variable tracker
        and mark it for attribute mutation tracking.

        Also records the variable trackers to call __new__ method on
        reconstruction. Roughly, the reconstruction looks like this
            base_cls_vt.__new__(user_cls, *init_args)
        )r   r   r   rh   )	r   rk   r   r   r   r7   rS   r9   r   )	rC   r   r   r   r   r   r   r   r   r.   r.   r/   track_new_user_defined_object  s    
z)SideEffects.track_new_user_defined_objectc                 C   s2   t  }tjt d}|| jt|< | j| |S )Nrh   )r   r
   ru   r   r7   rS   r9   r   )rC   r   r   r.   r.   r/   track_cell_new  s    zSideEffects.track_cell_new)r   cellcontentsc                 C   s<   t j|d u rd nt ||d}|| jt|< | j| |S )N)rh   ry   r   )r
   ru   r   r7   rS   r9   r   )rC   r   r   r   r   r.   r.   r/   track_cell_existing  s    zSideEffects.track_cell_existing)r   rU   c                 C   s.   t jt |d}|| jt|< | j| |S )N)rh   r   )r
   NewGlobalVariabler   r7   rS   r9   r   )rC   r   rU   r   r.   r.   r/   track_global_existing  s    z!SideEffects.track_global_existingc                 C   s$   t |tjsJ | j||f d S r"   )rI   r
   rb   r?   r   )rC   ctxargsr.   r.   r/   track_save_for_backward   s    z#SideEffects.track_save_for_backwardc                 C   sD   |j D ]8}t|}|j| }|| jvrt|tjr| || qd S r"   )r9   rS   r7   rI   r
   TensorVariabler   )rC   rG   Z
other_itemZother_idZother_variabler.   r.   r/   1track_tensor_variables_from_runahead_side_effects  s    

z=SideEffects.track_tensor_variables_from_runahead_side_effectsc                    s   t  t  tdfddtdfdd dd j D }t|j|j||jjj	f  fdd	j
 D _ fd
d	j
 D _d S )Nvarc                    sL   | v rd S  |  t| jtr,  |  | jv rHtj|   d S r"   )addrI   rh   r   r8   r   visitr   )live_new_objectsrC   r   visitedr.   r/   r     s    


z0SideEffects.prune_dead_object_new.<locals>.visitc                    s   t | jtr|  v S dS NTrI   rh   r   r   )r   r.   r/   is_live%  s    z2SideEffects.prune_dead_object_new.<locals>.is_livec                 S   s   g | ]}t |jts|qS r.   r   rO   r   r.   r.   r/   
<listcomp>*  s   z5SideEffects.prune_dead_object_new.<locals>.<listcomp>c                    s   i | ]\}} |r||qS r.   r.   rN   r   r.   r/   rP   I  s   z5SideEffects.prune_dead_object_new.<locals>.<dictcomp>c                    s   i | ]\}} |r||qS r.   r.   rN   r   r.   r/   rP   L  s   )setr   r7   valuesr   stackZsymbolic_localsrY   Zbackward_stater@   r&   r8   )rC   txZpre_existing_varsr.   )r   r   rC   r   r   r/   prune_dead_object_new  s.    	

z!SideEffects.prune_dead_object_newc                 C   sF   |  | t|jtrd|j_|jrBt|tjrBt|tjsBd| _	d S r   )
ri   rI   rh   r   r   r   r
   ConstDictVariableZSetVariablerA   )rC   r   r.   r.   r/   mutationP  s    


zSideEffects.mutationc                 C   s   | j S r"   )rA   rQ   r.   r.   r/   has_existing_dict_mutation[  s    z&SideEffects.has_existing_dict_mutationc                    s    fdd j  D S )Nc                    s   g | ]}  |r|qS r.   )r   r   rQ   r.   r/   r   _      z2SideEffects._get_modified_vars.<locals>.<listcomp>)r7   r   rQ   r.   rQ   r/   _get_modified_vars^  s    zSideEffects._get_modified_varscgc                    s  |   D ]tjts*jd usJ qttjrjd u r~  fdd  	t
dd   t j _njd u rtj_qttjrttjjrވ dd      t j _qttjrtdddg d	 qttjr& fd
d} | n  fdd  jj jD ]} | qJ 	t
dtj d   t j _q| jD ]P\}} |j  d |D ]} | q 	g tt|td qd S )Nc                      s     tjdS )NZ	make_cellload_import_fromr	   __name__r.   r   r.   r/   <lambda>t  r   z3SideEffects.codegen_save_tempvars.<locals>.<lambda>r   FZallow_cachez<AutogradFunctionContextVariable escaped Dynamo-traced regionrc   zAWe cannot reconstruct a torch.autograd.Function's context object.re   c                      s.   j d usJ  j    dg d S )Nr   )r   extend_outputcreate_load_attrr.   r   r   r.   r/   load_new_method  s    
z:SideEffects.codegen_save_tempvars.<locals>.load_new_methodc                      s     tjdS )Nr   r   r.   r   r.   r/   r     r   r   r?   POP_TOP)r   rI   rh   r   r   r
   ru   
local_nameadd_push_nullr   r   	add_cacher   Ztempvarsr   r   torch_functionZTensorWithTFOverrideVariableZ	clear_tosrb   r   r   r   r   lenr?   load_methodr   r   )rC   r   r   argr   r   r.   r   r/   codegen_save_tempvarsa  sj    




	





z!SideEffects.codegen_save_tempvarsc                 C   s   t |tjsJ t |tjs J t |tjr4| s8J ttj|sHJ t	| j
 }|| j
v rj|d7 }qV||||f| j
|< |jrJ ||_d S )Nr   )rI   r
   r   r   ZRemovableHandleVariableZ
is_mutabler   r   ZTensorr   r@   rK   idx)rC   tensorhookhandlerj   r   r.   r.   r/   register_hook  s    



zSideEffects.register_hookc                 C   s   | j |= d S r"   )r@   )rC   r   r.   r.   r/   remove_hook  s    zSideEffects.remove_hookc                    sf   | j  D ]V\}}js$J d fdd} |  |  tdd  | q
d S )Nz4Hooks on non input tensors NYI - should not get herec                      s        g d S r"   )r   r   r.   r   rj   r   r.   r/   gen_fn  s    z)SideEffects.codegen_hooks.<locals>.gen_fnr   F)r@   r   r   r   r   r   r   )rC   r   r   r   r   r.   r   r/   codegen_hooks  s    #
zSideEffects.codegen_hooksc                 C   s.   ddl m} | jd u r(tjg | d| _| jS )Nr   )r   r   )variables.baser   rB   r
   ListVariable)rC   r   r.   r.   r/   get_ca_final_callbacks_var  s    
z&SideEffects.get_ca_final_callbacks_varc              	      s  g }|   D ]ttjrj dd  j   d  d tdddg |tdg qttj	j
rtjtjrjjd u stddd	d
gd  j  d  dd |g tdtd  j  d |g tdtd qttjr r j  d  dd jrd j  d |g tdtd jr|g tdtd qttjjrR  fdd  dd tj } jd  |f7  <  td|d   fdd  j  tdtjd  dd  td qttjrjd ur| j v r| !} | | "jg q| #r>ttj$r| %j&ri }t'j(j)D ]} j*j+, ||< qzt-jj./t0j1}W n& t2y*   t-jj./t3}Y n0  td|dtd|d dg  j  td|d dg  j&dd  td|d dg t4t'|d}|g |td nttj5rd| %j6rdi }t7j(j)D ]} j*j+, ||< q j  td|d dg  j6dd  td|d dg t4t7|d}|g |td t8| j 9i : D ]\}}	ttj;r҈ j*j+<|  |	 tjt=sJ |td |dg qzt|	tj>r2tj?t@r8tAtBd!d |r8 j*j+<|  j |td"|dg qzttjCrD|r  fd#d  j  t|  |	 |g tEd$dtd nttjCrF r Gd%d&  d'  j  t|  |	 |g td$td n2 j*j+<|  |	   |td(|dg qzqttjHrtIj/D ]6}
  fd)d  j  dd  J  qVqttjKr fd*d+} |  LjMN  |g tEddtd qtOt-qt8|D ]} | qd S ),NFr   BUILD_SLICE   )r   STORE_SUBSCRz1Side effect on existing deque with limited maxlenrc   rd   z*Don't use a deque with `maxlen` specified.re   r2   r   r   r%   r   updatec                      s     tjdS )NZget_torch_function_mode_stackr   r.   r   r.   r/   r   m  s   z4SideEffects.codegen_update_mutated.<locals>.<lambda>co_varnames
STORE_FAST)argvalc                      s     tjdS )NZset_torch_function_mode_stackr   r.   r   r.   r/   r   v  s   
BUILD_LIST
LOAD_CONSTr*   r)   r(   )varname_mapr4   r3   STORE_GLOBALrk   DELETE_ATTRc                      s     tjdS )NZ object_setattr_ignore_descriptorr   r.   r   r.   r/   r     s      builtinsr   __setattr__
STORE_ATTRc                      s     tjdS )NZ	iter_nextr   r.   r   r.   r/   r   /  r   c                      s    j   d d S )Nsetstate)r   rr   r.   r   r.   r/   r   6  s    
z2SideEffects.codegen_update_mutated.<locals>.gen_fn)Pr   rI   r
   r   r   r   Zcreate_load_constr   r   listsZDequeVariablemaxlenZConstantVariablerk   r   r   r   r   Zhas_new_itemsZshould_reconstruct_allr   ZTorchFunctionModeStackVariabler   call_functionZget_prev_stack_var_nameZcode_optionsZappend_outputZforeachZsymbolic_stackr   ru   r   r8   r{   Zcreate_store_derefrl   r   r   Z_dict_vtr0   __code__r   r   rY   Znew_varr#   r$   indexr   r   
ValueErrorrM   r   r   Z_list_vtr5   reversedr   r&   r   Zupdate_co_namesr   rn   rh   r   r   getattrr   Zshould_skip_descriptor_setterr   Zneeds_slow_setattrr   ZListIteratorVariablerangeZpop_topZRandomVariableZ
wrap_staterandomgetstater   )rC   r   suffixesrj   Zcontents_varr  r*   Zdict_update_instsZlist_update_instsrk   _r   suffixr.   r   r/   codegen_update_mutated  s   







	










	











z"SideEffects.codegen_update_mutatedc                 C   s*   t t| j| j p&| jp&| jp&| j S r"   )anymapr   r7   r   r@   r?   rQ   r.   r.   r/   is_emptyJ  s    zSideEffects.is_emptyc                 C   s   | j   | j  d S r"   )r9   r%   r7   rQ   r.   r.   r/   r%   R  s    
zSideEffects.clear)NNNNN)FF)Ar   
__module____qualname____doc__rM   r   r   __annotations__rz   r1   r   r;   r   r   rJ   r   rL   rR   rV   rW   r^   r`   ra   ri   rm   rr   rw   r{   r}   r~   staticmethodr   rl   r   rx   r   r   r   Ztrack_mutabler   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r%   __classcell__r.   r.   rE   r/   r6   P   s   
     


%
	@^6	  ;r6   r!   )r   c                 c   sH   | j jjsJ | j jj}zd| j j_d V  W || j j_n|| j j_0 d S r   )rY   rZ   r[   r\   r   Zorig_valr.   r.   r/   r\   W  s    

r\   c                 c   s:   | j jj}zd| j j_d V  W || j j_n|| j j_0 d S r   )rY   rZ   r_   r#  r.   r.   r/   2allow_externally_visible_side_effects_in_subtracerb  s
    

r$  c                 c   s:   | j jj}zd| j j_d V  W || j j_n|| j j_0 d S r   )rY   rZ   ra   r#  r.   r.   r/   "disallow_side_effects_in_generatorl  s
    

r%  )9r  r   
contextlibr   r   r<   collections.abcr   typesr   typingr   r   r   Ztorch.nnr   rc   r   r	   r
   Zbytecode_transformationr   r   r   r   Zcodegenr   excr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    Ztorch._dynamo.symbolic_convertr!   r0   r5   r6   contextmanagerr\   r$  r%  r.   r.   r.   r/   <module>   sH   $	        
	