o
    "i5S                    @   s  d dl Z d dlZd dlZd dlZd dlZd dl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mZmZmZmZmZmZmZmZ d dlZd dlZd dlZd dlZd dlm  mZ d dlm Z  d dlm!Z!m"Z"m#Z# d dl$m%Z% d dl&m'Z' d dl(m)Z) d d	l*m+Z+m,Z,m-Z- d d
l.m/Z/ d dl0m1Z1 ddl2m3Z3mZ4m5Z5 ddl6m7Z7m8Z8 ddl9m:Z:m;Z;m<Z<m=Z= ddl>m>Z> ddl?m@Z@ ddlAmBZB ddlCmDZDmEZEmFZFmGZGmHZH ddlImJZJmKZK ddlLmMZM ddlNmOZOmPZP ddlQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\m]Z]m^Z^ ddlm_Z_m`Z`maZambZbmcZcmdZdmeZemfZfmgZgmhZhmiZimjZjmkZkmlZlmmZmmnZn ddlompZp ddlqmrZrmsZsmtZtmuZumvZv ddlwmxZx ddlymzZz ddl{m|Z| ddl}m~Z~mZmZmZ ddlmZ erpd d lmZ eeZejed!Zejed"Zejed#Zejed$Zed%d&G d'd( d(ZG d)d* d*Zedd+d, ZeG d-d. d.Zd/d0 ZG d1d2 d2ejjZG d3d4 d4Zeeef ZG d5d6 d6Zd7Zd8d9 Ze ZG d:d; d;e jZdS )<    N)	dataclass)	AnyCallableDictListOptionalSetTupleTYPE_CHECKINGUnion)fx)GlobalContextCheckpointStateSourceTracingContext)signpost_event)_make_graph_module)BackwardState)free_symbolsis_symbolicShapeEnv)insert_deferred_runtime_asserts)is_traceable_wrapper_subclass   )configlogging	variables)
CompiledFn
CompilerFn)create_call_functioncreate_instructionInstruction	unique_id)code_context)	PyCodegen)enter_new_scope)BackendCompilerFailed!exceptions_allowed_to_be_fallback	SkipFrameunimplementedunimplemented_with_warning)GuardBuilderinstall_guard)is_dynamic_nn_module)AttributeMutationExistingSideEffects)
AttrSourceBackwardStateSourceConstantSourceGetItemSourceGlobalStateSourceis_constant_sourceis_from_local_sourceLocalSourceParamBufferSourceShapeEnvSourceSyntheticLocalSourceTensorPropertyTensorPropertySource)checkpoint_paramsCleanupHookclone_inputscount_callscountersdynamo_timedget_instruction_source_311get_locals_to_stealget_static_address_typegraph_break_reasonsincrement_op_countlazy_format_graph_code
LazyStringnn_module_proxysameset_example_value)VariableTracker)BackwardStateGraphArgGraphArgTrackedFakeVariableBuilderwrap_fx_proxy)BaseListVariable)NullVariable)NNModuleVariable)NumpyNdarrayVariableSymNodeVariableTensorVariableUnspecializedPythonVariable)TensorWithTFOverrideVariable)InstructionTranslatorBasegraph
graph_codegraph_sizes
trace_callT)frozenc                   @   s   e Zd ZU eed< eed< dS )VariableTrackerCacheKeyvt_idsourceN)__name__
__module____qualname__int__annotations__r    rh   rh   X/home/ubuntu/SoloSpeech/.venv/lib/python3.10/site-packages/torch/_dynamo/output_graph.pyr`   u   s   
 r`   c                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )VariableTrackerCachec                 C   s
   i | _ d S N)cacheselfrh   rh   ri   __init__      
zVariableTrackerCache.__init__c                 C   s&   t t||}|| jvrd S | j| S rk   r`   idrl   )rn   valuerb   keyrh   rh   ri   lookup   s   

zVariableTrackerCache.lookupc                 C   s   t t||}|| j|< d S rk   rq   )rn   rs   rb   vtrt   rh   rh   ri   add   s   zVariableTrackerCache.addc                 C   s   t  }|j| j |S rk   )rj   rl   update)rn   	new_cacherh   rh   ri   clone   s   zVariableTrackerCache.clonec                 C   s   | j   d S rk   )rl   clearrm   rh   rh   ri   r{         zVariableTrackerCache.clearN)rc   rd   re   ro   ru   rw   rz   r{   rh   rh   rh   ri   rj   ~   s    rj   c                   C   s
   t tS rk   )torchdynamo_loggingget_step_loggerlogrh   rh   rh   ri   _step_logger      
r   c                   @   s<   e Zd ZU dZeed< eej ed< dZ	e
ed< dd ZdS )	GraphCompileReasonzOStores why a given output graph was compiled; i.e. what caused the graph break.reason
user_stackTgraph_breakc                 C   s   | j r
t|  d S d S rk   )r   rE   appendrm   rh   rh   ri   __post_init__   s   z GraphCompileReason.__post_init__N)rc   rd   re   __doc__strrg   r   	tracebackFrameSummaryr   boolr   rh   rh   rh   ri   r      s   
 r   c                    s    fdd}|S )Nc                      s   dd  D S )Nc                 S   s    g | ]\}}}||i |qS rh   rh   ).0fnargskwargsrh   rh   ri   
<listcomp>   s     zE_get_gen_rand_values_fn.<locals>._gen_rand_values.<locals>.<listcomp>rh   rh   random_callsrh   ri   _gen_rand_values   r|   z1_get_gen_rand_values_fn.<locals>._gen_rand_valuesrh   )r   r   rh   r   ri   _get_gen_rand_values_fn   s   r   c                       s:   e Zd ZdZdeeejjf f fddZ	dd Z
  ZS )FakeRootModulez'Trick the constructor of fx.GraphModule
nn_modulesc                    s,   t    | D ]
\}}t| || q	d S rk   )superro   itemssetattr)rn   r   kv	__class__rh   ri   ro      s   
zFakeRootModule.__init__c                 C   s   dS )NzFakeRootModule(...)rh   rm   rh   rh   ri   __repr__   s   zFakeRootModule.__repr__)rc   rd   re   r   r   r   torchnnModulero   r   __classcell__rh   rh   r   ri   r      s    r   c                   @   s6   e Zd ZdefddZdejjdeej	 fddZ
dS )	WrapperBackendbackendc                 C   
   || _ d S rk   )r   )rn   r   rh   rh   ri   ro      rp   zWrapperBackend.__init__gmexample_inputsc                 C   s   t || _|| _t| j}| ||| _| jd u s!| j| jju r%| jjS tj	s+| jS z2z$| jjt
| }| jt
| }t||rJ| jW W |   S td|   ty]   td  w |   w )Nzincorrect results of backend zerror in verify_correctness)r<   restorer   copydeepcopyr   	candidateforwardr   verify_correctnessr>   rJ   RuntimeError	Exceptionr   	exception)rn   r   r   copy_gmcorrectresultrh   rh   ri   __call__   s(   


	

zWrapperBackend.__call__N)rc   rd   re   r   ro   r   r   GraphModuler   Tensorr   rh   rh   rh   ri   r      s     r   c                
       s<  e Zd ZdZdeeef dee de	de
de
f
 fddZd	d
 ZddefddZdd Zdd Zdd Zdeg ef fddZdd Zedd Zedd Zdd Zedd  Zejd!d  Zed"d# Zed$d% Zd&d' Zd(d) Zd*d+ Ze j!d,d- Z"ed.d/ Z#ed0d1 Z$ed2d3 Z%ed4e&j'j(fd5d6Z)ed4eeef fd7d8Z*dd:d;Z+d<d= Z,d>d? Z-ed@dA Z.dBe/fdCdDZ0dEdF Z1dGdH Z2dIdJ Z3ddLdMZ4dNdO Z5e6dPdQ Z7dRe8e&j9j:e&j;ef fdSdTZ<dUdV Z=	9ddXee> fdYdZZ?d[d\ Z@d]d^ ZAd_d` ZBdaefdbdcZCe j!ddde ZDe&j'jEF dfdg ZGed4eHeIjJ fdhdiZKed4eHe/ fdjdkZLeMdldmdneIjNd4eOfdodpZPd4eHe&j; fdqdrZQddsdtZRdueHeS d4d9fdvdwZTddxdyZUd4efdzd{ZVd4efd|d}ZWdd~dZXde	d4d9fddZYdeeIjNgd9f d4d9fddZZde&jIjJfddZ[  Z\S )OutputGrapha  
    Wrapper class to hold outputs of InstructionTranslator.  Mainly the
    generated fx.Graph.

    OutputGraph is 1:1 with a frame being processed. Each frame is associated
    with some root InstructionTranslator. When user code calls a function,
    we construct a InliningInstructionTranslator that continues to write into
    the root InstructionTranslator's OutputGraph.
    code_optionscompiler_fnexportlocal_scopeglobal_scopec
                    s  t    t| |dg| _i | _|| _|| _|| _i | _g | _	t
t| _t | _|	j|	j|	jd| _g | _t | _t| jtjtjtjtj| jd}
dd lm  m} |jdd tjj |
| jrbdnd| jd}W d    n1 srw   Y  t!|| _"| #  t$%t&| _'t( | _)t* | _+t, | _-t./ | _0t(|| _1g | _2d| _3g | _4|| _5|| _6|| _7|| _8i | _9g | _:g | _;d| _<i | _=tj>? | _@d| _Ati | _Bti | _C| D  i | _Eg | _Fd | _Gg | _Hi | _Id | _Jd | _K| L | _Mt | _Nd S )	N)export_root)co_nameco_filenameco_firstlineno)tracked_fakesallow_scalar_outputsallow_dynamic_output_shape_ops+prefer_deferred_runtime_asserts_over_guards(_allow_complex_guards_as_runtime_asserts	co_fieldsr   F(fake_tensor_allow_unsafe_data_ptr_accessT)	shape_envallow_non_fake_inputsr   )Or   ro   SubgraphTracertracersinput_source_to_varr   export_constraintsframe_stateinput_source_to_sizes_stridescleanup_hooksnext_compile_id_counter
compile_idsetinstalled_globalsr   r   r   r   r   bound_symbolsr   r   capture_scalar_outputs capture_dynamic_output_shape_opsr   r   torch._functorch.config
_functorchpatchr   _subclassesFakeTensorModer   tracing_contextinit_ambient_guardscollectionsdefaultdictlisttracked_fakes_id_to_sourcedictparam_name_to_sourcer.   side_effectsrj   variable_tracker_cache	itertoolscountunique_var_idr   output_instructions	timestampregister_finalizer_fnsr   r   r   root_txsource_to_user_stacks_current_txcleanupsshould_exitunspec_variable_map_C_is_torch_function_enabledtorch_function_enabled!has_user_defined_allowed_in_graphnon_compliant_opscompliant_custom_opssave_global_state dynamo_flat_name_to_original_fqnr   random_values_varpregraph_bytecodebackward_statebackward_state_proxybackward_state_var!install_builtins_dict_in_fglobals%name_of_builtins_dict_key_in_fglobalsguard_on_key_order)rn   r   r   r   r   r   r   r   r   f_coder   _config	fake_moder   rh   ri   ro      s   


	



zOutputGraph.__init__c                 C   s&   | j d }t|ts|j}| d|S )N__builtins____builtins_dict__)r   
isinstancer   __dict__install_global)rn   
f_builtinsrh   rh   ri   r    s   

z-OutputGraph.install_builtins_dict_in_fglobalshookc                 C   s6   | t | j }|| jvsJ || j|< ||  fS rk   )lenr   get_backward_state_proxy)rn   r  prefixnamerh   rh   ri   add_backward_state_hook  s   
z#OutputGraph.add_backward_state_hookc                 C   s^   | j d u r,| jrtd | jjdtt d| _ t | j jj	d< t
| j jt  |  | _| j S )Nz&backward_state does not support exportdynamo_backward_state)rb   grapharg)r  r   r(   root_tracercreate_graph_inputr   r0   rM   nodemetarK   new_varr  rm   rh   rh   ri   r    s   

z$OutputGraph.get_backward_state_proxyc                 C   s   | j t tj | j t tj | j t tj | j t tj	 | j t tj
 tjj }|d urN| j t tj d S d S rk   )guardsrw   r8   
make_guardr*   	SHAPE_ENVr3   DETERMINISTIC_ALGORITHMS	GRAD_MODEDEFAULT_DEVICETORCH_FUNCTION_STATEr   r   r   peek_interpreter_stackFUNCTORCH_STACK_MATCH)rn   cirh   rh   ri   r     s   zOutputGraph.init_ambient_guardsc                 C   s   || }|   }t| j}||j|j |ttj	j
| |t|d || | j|  t|}t| j||}t jj| |S )z]
        call fn(*args) before the graph runs and turn the result into a fake input.
        T)r  r#   r   load_import_fromrd   rc   foreachmapr   ConstantVariablecreatecall_functionr  storer   extendget_instructionsr9   rP   r   getguards_contextdynamo_guardsremove_guards_with_source)rn   r   r   example_valuevarnamecgrb   r   rh   rh   ri   synthetic_graph_input  s"   

z!OutputGraph.synthetic_graph_inputr   c                 C      | j | d S rk   )r   r   )rn   r   rh   rh   ri   add_cleanup_hook     zOutputGraph.add_cleanup_hookc                 C   s$   t | jD ]}|  q| j  d S rk   )reversedr   r{   )rn   r  rh   rh   ri   call_cleanup_hooks  s   zOutputGraph.call_cleanup_hooksc                 C   
   | j d S Nr   r   rm   rh   rh   ri   r    r   zOutputGraph.root_tracerc                 C   r<  Nr>  rm   rh   rh   ri   current_tracer  r   zOutputGraph.current_tracerc                 C   s   t | jdkS )Nr   )r  r   rm   rh   rh   ri   is_root_tracer     zOutputGraph.is_root_tracerc                 C      | j jS rk   rA  r[   rm   rh   rh   ri   r[        zOutputGraph.graphc                 C   s   || j _d S rk   rE  )rn   rs   rh   rh   ri   r[     s   c                 C   rD  rk   )rA  input_name_to_proxyrm   rh   rh   ri   rG    rF  zOutputGraph.input_name_to_proxyc                 C   rD  rk   )rA  real_value_cacherm   rh   rh   ri   rH    rF  zOutputGraph.real_value_cachec                 O      | j j|i |S rk   )rA  create_proxyrn   r   r   rh   rh   ri   rJ       zOutputGraph.create_proxyc                 O   rI  rk   )rA  create_noderK  rh   rh   ri   rM    rL  zOutputGraph.create_nodec                 O   rI  rk   )rA  remove_noderK  rh   rh   ri   rN    rL  zOutputGraph.remove_nodec                 c   s    t  }z2|r|j| ju sJ |  |r|nt| | j|d}| j| |V  W |d d d  | j  d S |d d d  | j  w )N)parentsource_target)	r$   rO  rA  	__enter__r   r   r   __exit__pop)rn   rP  prior_tracernew_scope_ctxtracerrh   rh   ri   	subtracer"  s$   zOutputGraph.subtracerc                 C   s   | S rk   rh   rm   rh   rh   ri   output7  s   zOutputGraph.outputc                 C   rD  rk   )r   r  rm   rh   rh   ri   r  ;  rF  zOutputGraph.fake_modec                 C   
   | j jjS rk   )r   r  r   rm   rh   rh   ri   r   ?  r   zOutputGraph.shape_envreturnc                 C   rY  rk   )r   r0  r1  rm   rh   rh   ri   r  C  r   zOutputGraph.guardsc                 C   rY  rk   )r   module_contextr   rm   rh   rh   ri   r   G  r   zOutputGraph.nn_modulesNc                 C   s   |dur|n| j jj}| j| jf|d< tjt f|d< t	tj
dtdf|d< t	tj
dtdf|d< t	tjdtdf|d< t	tjdtdf|d	< tjt f|d
< dS )zc
        Saves to out if it is provided. Else saves to the tracing context's global_state.
        Nr   grad_enabledcudaautocast_enabledcpuautocast_cpu_enabledautocast_gpu_dtypeautocast_cpu_dtypeautocast_cache_enabled)r   global_contextglobal_stateset_torch_function_stater   r   set_grad_enabledis_grad_enabled	functoolspartialset_autocast_enabledis_autocast_enabledset_autocast_dtypeget_autocast_dtypeset_autocast_cache_enabledis_autocast_cache_enabled)rn   outre  rh   rh   ri   r   K  s*   zOutputGraph.save_global_statec                 C   r7  rk   )r   r   )rn   txrh   rh   ri   push_txt  r9  zOutputGraph.push_txc                 C   s
   | j  S rk   )r   rS  rm   rh   rh   ri   pop_txw  rp   zOutputGraph.pop_txc                 C   s   | j s| jS | j d S r?  )r   r   rm   rh   rh   ri   
current_txz  s   zOutputGraph.current_txargc                    sD   j rd S |jd usJ fdd  fdd|j|j d S )Nc                    s   t | rt| jjtjsd S | jj}| jv rd S  j| t	d| |
   jjt|tjd|d}t|j|  t|| dd dd|jjd< d S )Nzbind_symint %s %sT)beforerb   F)pass_arg_as_tensorfake_tensor	is_tensorr  )r   r  r  exprsympySymbolr   rw   r   debugr  r  r  r   r   SymIntrK   rN   r  )sprops0proxyrm   rh   ri   bind_symint  s*   
z4OutputGraph.add_symbol_bindings.<locals>.bind_symintc                    s@  t |  D ]\}} |t|tj| q| jtju r<t |  D ]\}} |t|tj	| q! | 
 t|tj nD| jtju rQ|  | |  | n/| jtjtjhv ri|  | |  | n| jtjtjhv r|  | |  | t| r|  \}}|D ]}t| |}|t|| qd S d S rk   )	enumeratesizer;   r:   SIZElayoutr   stridedstrideSTRIDEstorage_offsetSTORAGE_OFFSET
sparse_coo_indices_values
sparse_csr
sparse_bsrcrow_indicescol_indices
sparse_csc
sparse_bscccol_indicesrow_indicesr   __tensor_flatten__getattrr/   )tsrcir  attrsctxattrinner_t)r  handle_tensorrh   ri   r    s2   

z6OutputGraph.add_symbol_bindings.<locals>.handle_tensor)r   ry  rb   rn   rv  rh   )r  r  rn   ri   add_symbol_bindings~  s   zOutputGraph.add_symbol_bindingsc                 C   s
   t | jS rk   )r?   r[   rm   rh   rh   ri   r?     rp   zOutputGraph.count_callsc                 C   s   t t| jjdkS r=  )r  r   r[   nodesrm   rh   rh   ri   is_empty_graph  s   zOutputGraph.is_empty_graphc                 C   s@   |sJ | j }|dD ]}t|tr|| }qt||}q|S N.)r   splitr  r   r  )rn   keysobjr   rh   rh   ri   get_submodule  s   

zOutputGraph.get_submoduletmpc                 C   sF   t | jd }	 | dt| j }||vr"| jd  |f7  < |S q)Nco_varnamesT_)r   r   r   r   )rn   r  existingvarrh   rh   ri   r    s   zOutputGraph.new_varc                 C   s*   || j d vr| j d  |f7  < dS dS )z/Ensure self.code_options.co_names contains nameco_namesN)r   )rn   r  rh   rh   ri   update_co_names  s   zOutputGraph.update_co_namesc                  G   sV   d tt| }tdd|}tdd|}tdd|}|r%|d  s)d| }|S )	Nr  z^[GL]\['?(.*?)'?\]$z\1z	\[(\d+)\]z_\g<1>z[^a-zA-Z0-9]r   sub)joinr(  r   rer  isalpha)namesr  rh   rh   ri   module_key_name  s   zOutputGraph.module_key_nametargetc                    s  t jjrtjfi S tdv sJ d ttr%J ttj	r@j
 s5jfdd}nCttjjrjttjjsPJ rbttj fdd}n!fdd}nttjtjfr|fdd}nfdd}j D ]\}}|u r||  S qtj|   }t D ]L} jvrj < ttjjr fdd	}	td
rψ D ]\}
}|	|
 qtdr D ]\}
}|	|
 q|   S | d|  qtd)Nrb   c                    s   j d usJ j | < jjjv rjjj S tdkr)ttj nt	s5ttj
 tjd| t i fdi }jjj|}|S )Nguardedget_attrr3  )r   r   rX  r   rD   r+   r  r*   ID_MATCHr4   TENSOR_MATCHrQ   rJ  tupletrack_object_existing)
module_keyrv   )optionsrn   rb   r  rV  rh   ri   	wrap_name
  s$   
	z6OutputGraph.register_attr_or_module.<locals>.wrap_namec                    s   t t| fi  S rk   )rT   typer  r  r  rh   ri   r  *  s   c                    s   t jfi  S rk   )r   UnspecializedNNModuleVariabler  r  rh   ri   r  2  rL  c                    s&   t jd| t i fdi S )Nr  sym_num)rV   r*  rJ  r  r  )r  rn   r  rh   ri   r  =  s   c                    s*    j |   j| < t t| dS )N)source_name)rX  r  r   rP   r1   r  )rn   r  rh   ri   r  H  s
   
c                    sV   j d usJ t| }  d|  }|j |< ttr)| jt| < d S d S r  )r   r7   r  r6   r   r   r  r  )	leaf_name
new_sourcenew_name)r  rn   rb   rh   ri   register_leaf_name\  s   


z?OutputGraph.register_attr_or_module.<locals>.register_leaf_name_parameters_buffersr  unreachable)r,   r   r   r   r  r   r  r7   r   r   rA  rB  r  r   r   r+   r  r*   	NN_MODULEr  SymFloatr   r   r   r  r   r   hasattrnamed_parametersnamed_buffersAssertionError)rn   r  r  r  r  r   r   baser  r  r  r  rh   )r  r  rn   rb   r  rV  ri   register_attr_or_module  sP   






z#OutputGraph.register_attr_or_modulec                 C   s  | j d}t|}|sg S g }i }g |j|j | jj }|rm|	 }t
|tr;t
|jts5J ||j7 }q"t
|ttfrVt
|jtrVt
|jjtrV|jjj|v sWq"|jjj}||vrdg ||< || | |s$i }	| jD ][}
t
|
jtrt
|
jtr|
jj|v sqr|
jj}|| jd v sJ || D ]4}|jj}||	vr| | d}||	|< |td|dtd|dtdtd|dg t|	| |_qqr|S )	Nrn   r  _ref	LOAD_FASTargval
LOAD_CONSTBINARY_SUBSCR
STORE_FAST)r   r/  rC   stacksymbolic_localsvaluesr   store_attr_mutationsr  rS  r  rR   r   r   rL   r-   rb   r2   r  r6   
local_namer   	graphargs_exampler   r   indexr  r-  r   )rn   rr  maybe_gmstolen_list_namesalias_instsneeds_aliasqueuexstolen_namevisitedrv  	list_namelist_idx
alias_namerh   rh   ri   handle_aliases_for_stolen_listst  sx   











z+OutputGraph.handle_aliases_for_stolen_listsFr   c                    s  |dusJ ddl m} |_|_d_td| tdd jD s)t	d g  t
jd	krbjD ].}|jd
krE td
|jd q3|jdkrY tdtjd d q3 t| q3jrljrlJ d j    fdd}tjD ]}| q    tj}|D ]}	|	  qdd j  D }
t!|
}g }i }|rt ||d < j"  D ]6\}}t#|j$t%r|j$j&|krqt
jdkrt'(t)|rqnt'(t)|rJ ||vrt ||< || | q|* D ]}|||  ||gt||   qtj+dkrZ|  g },d_-|t.j+}/d|}t0|}||1|d |t2dd ||3j4j- 5| |rtdd |D rtdd |D rtt6|t|krj78 rtj9dksj:s|  5;tt||tdt|dg  5fddt|D  dS ,d}t0||}<|| t0||d d |j=  D d!}<|| d}g }t>j?dkst|j@dkr|;|A | t|j@dkr||3| d}n|td" |  5||B   5fd#dt|D  |rE5t0C|g dS dS )$zw
        Generate a subgraph to continue execution on user code.
        Automatically restore live variables.
        Nr   disableTzCOMPILING GRAPH due to %sc                 s       | ]}|  V  qd S rk   )can_restore)r   blockrh   rh   ri   	<genexpr>      z/OutputGraph.compile_subgraph.<locals>.<genexpr>z&compile_subgraph with block_depth != 0      	MAKE_CELLr  COPY_FREE_VARSco_freevars)rv  z)export does not support pregraph_bytecodec                      s         d S rk   )add_output_instructionsr{   rh   )prefix_instsrn   rh   ri   append_prefix_insts  s   
z9OutputGraph.compile_subgraph.<locals>.append_prefix_instsc                 S   s   i | ]	\}}|t |qS rh   )rI   )r   r  modrh   rh   ri   
<dictcomp>  s    z0OutputGraph.compile_subgraph.<locals>.<dictcomp>r@  )r     r   random_values__gen_rand_valuesFc                 s   s:    | ]}t |tttf ot |to| tu  V  qd S rk   )r  rX   rU   rY   rV   python_typefloat)r   r   rh   rh   ri   r  5  s    

c                 s   s    | ]}t |tV  qd S rk   )r  rW   r   r  rh   rh   ri   r  A  s    UNPACK_SEQUENCEc                       g | ]	}t  |qS rh   r#   create_storer   r  rr  rh   ri   r   O      z0OutputGraph.compile_subgraph.<locals>.<listcomp>	graph_outc                 S   s   i | ]\}}|d kr|dqS )r   Nrh   )r   valr   rh   rh   ri   r  [  s    )tempvarsPOP_TOPc                    r  rh   r  r  r  rh   ri   r   p  r  )D
decoratorsr  partial_convertcompile_subgraph_reasonr   r   r~  allblock_stackr(   sysversion_infor  opnamer   r   r  r  r   r   r   r   r-  r  r:  exitcleanup_graphprune_dead_localsr   r  realizer   r   r   r  r  rb   r6   r  r  __instancecheck__rS   r  r   r  r   r   r  r#   load_function_namer   r  rX  r  r   r   is_emptydebug_localsr   compile_and_call_fx_graphcodegen_suffixusesr?   r[   graph_outputsgraph_output_varsr.  create_delete)rn   rr  r  r   r  instr  r  stack_valuesrs   nn_modules_proxiesrootrestore_varsval_to_namesr   r   random_calls_instructionsrand_fnrand_fn_namecodegengraph_output_varpass1pass2stored_graph_output_varrX  rh   )r  rn   rr  ri   compile_subgraph  s   












 zOutputGraph.compile_subgraphc           	      C   s   | j r$| jrJ | j  D ]\}}|| ||| j || q| j| | j	| |j
D ]#\}}|| |D ]}|| q=|tt|d |tdg q3|j||j d | j| d S )NTr  )value_from_source)r   r   r   append_outputcreate_loadr  
store_attrr   codegen_hookscodegen_save_tempvarsr&  extend_outputr   r  r   restore_stackcodegen_update_mutated)	rn   rr  r.  r5  r  r  	debug_varr   rv  rh   rh   ri   r(  x  s    

zOutputGraph.codegen_suffixc                 C   s   | j sJ t| jj}|D ]	}|jdd qt }t||dd D ]@\}}|j	tj
ju rdt|j| fkrd|jsd|jd }|j	tj
ju rdt|j| fkrd|jsd|jd }| j| | j| q$dS )z
        Remove "creation_timestamp" from node meta

        Remove this pattern from the graph:
            torch._C._set_grad_enabled(False)
            torch._C._set_grad_enabled(True)
        creation_timestampNr   r   )r   r   r[   r  r  rS  r   rh  zipr  r   _set_grad_enabledr  r   _erased
erase_node)rn   r  r  r\  node1node2rh   rh   ri   r     s(   


zOutputGraph.cleanup_graphc                 C   sN   i }| j jD ]}|jdd }t|tjjr$| }dd |D ||j	< q|S )Nr3  c                 S   s"   g | ]}t |tr|nt|qS rh   )r  rf   repr)r   r  rh   rh   ri   r     s   " z:OutputGraph.get_graph_sizes_structured.<locals>.<listcomp>)
r[   r  r  r/  r  r   r   
FakeTensorr  r  )rn   retr  r3  r  rh   rh   ri   get_graph_sizes_structured  s   z&OutputGraph.get_graph_sizes_structuredr  c           	      C   s   d}|d| d7 }| j jD ]U}|jdd }t|tjjrc| }||j	 dt
| d7 }g }d}|D ]}t|trB|| q5t|tjrRd}||jj q5 n|rc||j	 d	t
| d7 }q|S )
NzTRACED GRAPH TENSOR SIZES
z===== z =====
r3  z: 
FTz (concrete): )r[   r  r  r/  r  r   r   rN  r  r  r  rf   r   r  r  hint)	rn   r  graph_sizes_strr  r3  r  concrete_size
has_symintszrh   rh   ri   get_graph_sizes  s,   
zOutputGraph.get_graph_sizesc              
   c   s`    | j j }i }| j|d z| j j| dV  W | j jt| dS | j jt| w )zj
        Momentarily restores the global state to what it was prior to tracing the current output
        )rq  N)r   rd  copy_graphstater   restore_graphstater   )rn   prior_global_statecurrent_global_staterh   rh   ri   restore_global_state  s   z OutputGraph.restore_global_statec              	      sj  ddl m} jsJ td}t|tsJ t|tsJ ddj	t
dd |D fi  tjs@tt|jj|   tj}td d  |7  < j  t|j jD ]}|  qaj _j  jd	< td
t| ddd t j!j"dfdd fddd #  j$j%}j&sddl'm(  m}	 |	j)dd t j*j+|jd}
W d   n1 sw   Y  |
j$_%,  - }W d   n1 sw   Y  ddl.m/} t||stt0|dd|r|j1dkrt||r|n|j2}|3| t||s|j4}||}td d  d7  < 5|| t6|}|7| |8 S )zr
        Generate code from self.graph and return the Instruction()s to
        call that generated code.
        r   r  __compiled_fnrX  c                 s   r  rk   )as_proxyr  rh   rh   ri   r    r  z8OutputGraph.compile_and_call_fx_graph.<locals>.<genexpr>statscalls_capturedr   %sT)include_strideinclude_devicedynamo_output_graphc                      s   d   iS )Nsizes)rP  rh   rm   rh   ri   <lambda>  s    z7OutputGraph.compile_and_call_fx_graph.<locals>.<lambda>c                      s    j ddddS )NFT)print_outputrb  rc  )print_readablerh   )r   rh   ri   rf    s    )
payload_fnr   NFr   )r   )_LazyGraphModule__self___lazy_forwardunique_graphs)9r  r  r   r!   r  r   r   rM  rA  
create_argr  r   do_not_emit_runtime_assertsr   r   r   r[   r   remove_unused_graphargsr?   r@   rH  r{   r   r   r  r   r   r  graph_code_logr~  rG   r   _loggingtrace_structuredr;  r   r  r   r   r   r   r   r   r\  call_user_compilertorch.fx._lazy_graph_modulerj  r  rc   rk  force_recompiler   install_global_unsafer#   make_call_generated_coder.  )rn   rr  rvr0  r  r  ncallsregister_finalizerold_fake_moder  backend_fake_modecompiled_fnrj  lazy_gmr5  rh   )r   rn   ri   r'    s   








	

z%OutputGraph.compile_and_call_fx_graphc                 C   s   | j jddS )Nplaceholder)op)r[   
find_nodesrm   rh   rh   ri   placeholdersI  rC  zOutputGraph.placeholdersc                 C   s   dd | j D S )Nc                 S   s   g | ]}|j d  qS )r  r  )r   r  rh   rh   ri   r   O  s    z)OutputGraph.graphargs.<locals>.<listcomp>)r  rm   rh   rh   ri   r  M  s   zOutputGraph.graphargsbackend_compile)
phase_namer   c              
   C   s  | j d usJ d}g }|jjD ]}|jdv r|d7 }|jdkr$|| qt| |D ]}|jd }|j|_q+| j	|_
| j|_z;t| j drJ| j jnd}t tjd|  | j }tjr`t|}|||  }	t tjd	|  t|	syJ d
W nT ty }
 z%| jrt| j |
|
jd d| j  d}t|
| jj| W Y d }
~
n(d }
~
w t y }
 z|
d }
~
w t!y }
 zt| j |
|
jd d }
~
ww t"ddi | j#|t$|jjt$|d |	S )Nr   r+  call_methodcall_moduler   r  r  rc    zcalling compiler function zdone compiler function z#compiler_fn did not return callablez9Backend compiler failed with a fake tensor exception at 
zAdding a graph break.dynamoOutputGraph.call_user_compiler)op_count
node_countinput_count)%r   r[   r  r  r   rF   r  rb   _dynamo_sourcer   _param_name_to_sourcer   _source_to_user_stacksr  rc   r   r   INFOr   r   r   r   callabler&   r   r%   with_traceback__traceback__r   format_frame_summaryr)   r  r'   r   r   r   r  )rn   r   totr  r  plrv  r  r   r~  emsgrh   rh   ri   rt  Q  s~   







r  c                 C   s    g }| j D ]}||j q|S rk   )r  r   example)rn   r   rv  rh   rh   ri   r     s   
zOutputGraph.example_inputsc                    s6  j sJ dtjjfdd}dtjjfdd  fdd}d	d
 }ttjjD ]:}tt|j	dkrc|j
dks^|j
dkrD|jtju s^|j
dkrV|jtju rV||jd s^||s^||rc| q)dd }fdd}t dttjtjf fddg }jD ]x}||d u}|r|j	s|| q|j	st|jd ts|| q|jd }	t|	trqt|jd jtjr|jd j}
|jd j}t|
 }|  D ]}t!|j"|}t#$tjtjffdd| qq|	j%d ur|	j%n|	j}| q|D ]}||}|d ur|vr|| q&| qd S )Nb_nodec                 S   sf   | du rdS t | tjsdS | jd}|d u rdS |du r dS t |tjr1|j  }d ur1|S dS )NTFr3  )	r  r   Noder  r/  r   SymBoolr  maybe_as_bool)r  brrh   rh   ri   is_static_true  s   
z;OutputGraph.remove_unused_graphargs.<locals>.is_static_trueac                 S   sB   ddl m} t| tttfrdS t| tjrt| j	d|S dS )Nr   SymTypesTr3  F)
torch.fx.experimental.sym_noder  r  rf   r
  r   r   r  r  r/  )r  r  rh   rh   ri   is_symnode_arg  s   z;OutputGraph.remove_unused_graphargs.<locals>.is_symnode_argc                    sp   ddl m} | jdkrdS t| jd|sdS t fdd| jD s&dS t fdd| j	 D s6dS d	S )
Nr   r  r+  Fr3  c                 3       | ]} |V  qd S rk   rh   r   r  r  rh   ri   r    r  zWOutputGraph.remove_unused_graphargs.<locals>.is_symnode_compute_node.<locals>.<genexpr>c                 3   r  rk   rh   r  r  rh   ri   r    r  T)
r  r  r  r  r  r/  r  r   r   r  )r  r  r  rh   ri   is_symnode_compute_node  s   
zDOutputGraph.remove_unused_graphargs.<locals>.is_symnode_compute_nodec              	   S   s   | j dkrt| jd jdtjr| jdv rdS | j dkrJ| jtjj	j
tjj	j
jtjj	j
jtjj	jtjj	jjtjj	jjtjj	jtjj	jjfv rJdS dS )Nr  r   r3  )r  r  r  itemTr+  F)r  r  r   r  r/  r   r   r  opsatensym_sizedefaultrf   
sym_stridesym_storage_offsetr  rh   rh   ri   is_accessor_node  s"   







z=OutputGraph.remove_unused_graphargs.<locals>.is_accessor_noder   r  r+  c                 S   s8   | j d }|j}t|tjrt|jjtjr|jjS d S Nr  )	r  r  r  r   r  r  r{  r|  r}  )r  rv  r  rh   rh   ri   placeholder_binds_symbol  s   

zEOutputGraph.remove_unused_graphargs.<locals>.placeholder_binds_symbolc                    s<   t d| jd j  | jd=  |   j| d  d S )NzREMOVE UNUSED GRAPHARG %sr  )r   r~  r  rb   r  rN  rH  rS  r  rm   rh   ri   remove_unused  s   
z:OutputGraph.remove_unused_graphargs.<locals>.remove_unusedfakec                 S   s   | t |O } d S rk   )r   )used_symbolsr  rh   rh   ri   update_used_symbols  r9  z@OutputGraph.remove_unused_graphargs.<locals>.update_used_symbolsr  c                    s
    | S rk   rh   )r  )r  r  rh   ri   rf  +  s   
 z5OutputGraph.remove_unused_graphargs.<locals>.<lambda>)'r   r   r  Argumentr:  r   r[   r  r  usersr  r  operatorgetitemr   _checkr   rN  r   r   r  r   r  r   r  r  rM   r  ScriptObjectexample_strong_refr   __obj_flatten__r  r  wrapped_objpytreetree_map_onlyry  remove)rn   r  r  r  r  r  r  recheck_placeholdersbinds_symbolrv  real_script_objfake_script_obj	flat_dictr  fake_attr_valr  symbolrh   )r  rn   r  r  ri   rp    sx   




	










z#OutputGraph.remove_unused_graphargsr  c                 C   s   | j | d| _dS )zt
        We call this on the creation of a new compiled subgraph that is inserted
        before user code.
        TN)r   r-  r   )rn   r  rh   rh   ri   r  >  s   
z#OutputGraph.add_output_instructionsc                 C   s6   || j vsJ | j | | jt| j|| dS )a`  
        WARNING: prefer the safer `install_global_by_id/install_global`.
        torch.compile instances should be independent of each other;
        one footgun is to have one instance depend on the existence of
        a global installed by another instance. This can happen if we mangle
        a global the same way across both instances.
        N)r   rw   r   r   r=   r*  r   )rn   r  rs   rh   rh   ri   rw  F  s   z!OutputGraph.install_global_unsafec                 C   s8   | dt | d| j }|| jv r|S | || |S )z
        Installs a global if it hasn't been installed already.
        This is determined by (prefix, id(value)) pair.

        Returns the name of the newly installed global.
        r  _c)rr   r   r   rw  rn   r  rs   r  rh   rh   ri   install_global_by_idR  s
   	
z OutputGraph.install_global_by_idc                 C   s   t |}| || |S )z~
        Installs a global, generating a unique name for it.

        Returns the name of the newly installed global.
        )r!   rw  r  rh   rh   ri   r  a  s   zOutputGraph.install_globalc                 C   s   d | _ | j  d | _| jjD ]}d|jv r|jd= q| j  | j  | j	  | j
  | j  | j  | j  d S r  )r   r   r{   r   r[   r  r  rH  rG  r   r   r   r   r   rn   r  rh   rh   ri   cleanupl  s   







zOutputGraph.cleanupenabledc                 C   r   rk   )r   )rn   r  rh   rh   ri   rf  ~  rp   z$OutputGraph.set_torch_function_stater{  c                 C   r7  rk   )r   r   )rn   r{  rh   rh   ri   add_graph_finalizer  s   zOutputGraph.add_graph_finalizerr  c                 C   s0   |j dkr|jd jS |j dksJ | j|j S )z#Extract the non-fake example tensorr  r  r  )r  r  r  r   r  r  rh   rh   ri   example_value_from_input_node  s   
z)OutputGraph.example_value_from_input_node)r  rk   )r  )FN)rZ  N)]rc   rd   re   r   r   r   r   r   r   r   Scopero   r  rL   r  r  r   r6  r   r8  r;  propertyr  rA  rB  r[   setterrG  rH  rJ  rM  rN  
contextlibcontextmanagerrW  rX  r  r   r   _guards	GuardsSetr  r   r   rs  rt  ru  rN   r  r?   r  r  r  r  staticmethodr  r   r   r   r   r  r  r   r;  r(  r   rP  rW  r\  r   clear_framer'  r   r   r  r  r  rA   r   r   rt  r   rp  r    r  rw  r  r  r  rf  r  r  r   rh   rh   r   ri   r      s    

	 .





	




)
@

	

 	J
 <	


i@
 '


r   a  With the current config, we will graph break (and fall back to eager-mode PyTorch) on all ops that have do not have the 'pt2_compliant_tag'. Please see the following doc for how to mark this op as PT2 compliant https://pytorch.org/tutorials/advanced/custom_ops_landing_page.htmlc              
      sx  |dkrd S  fdd} fdd}t |tjjr1tjj|jv r&|| d S ||d| d d S t |tjjrt|	 }t
|dkrct||d	 }tjj|jv rX|| d S ||d
| d d S tjj j||fd\}}ztjj|jg|R i |}	W n ty }
 ztt|
 W Y d }
~
nd }
~
ww t||	}tjj|jv r|| d S ||d| d|	 d d S d S )Nr+  c                    s   | j dv rd S  j|  d S )N>   r  primprims)	namespacer   rw   )r  output_graphrh   ri   encountered_compliant_op  s   
z8check_pt2_compliant_op.<locals>.encountered_compliant_opc                    s*    j |  tjrt|d t  d S d S )N )r   rw   r   only_allow_pt2_compliant_opsr(   err_epilogue)r  r  r  rh   ri   encountered_non_compliant_op  s   z<check_pt2_compliant_op.<locals>.encountered_non_compliant_opz%Encountered the torch.ops.OpOverload z that is not PT2 compliant.r   r   z:Encountered the non-overloaded torch.ops.OpOverloadPacket z that is not PT2 compliant. Fz+Encountered the torch.ops.OpOverloadPacket z! which resolves to the overload (z) that is not PT2 compliant.)r  r   _ops
OpOverloadTagpt2_compliant_tagtagsOpOverloadPacketr  	overloadsr  r  _dynamoutilsget_fake_values_from_nodesru  r   _jit_resolve_packet_qualified_op_namer   r(   r   )r  kindr  r   r   r  r  r  r  overloadr  rh   r  ri   check_pt2_compliant_op  sh   


r  c                       sj   e Zd ZdZ	d fdd	Z			d fdd	Z	d fdd		Zd
d ZdddZdd Z	dd Z
  ZS )r   a  
    Holds an FX graph that is being traced. OutputGraph owns a SubgraphTracer
    and the separation of responsibilities is that SubgraphTracer is
    responsible for building the graph while OutputGraph is responsible for
    compiling and executing the graph.
    NFc                    s   t    t|| _tj | _|r|d u sJ || _	i | _
i | _|| _i | _d | _d | _d | _d | _d | _| jd u rAg | _d S | jj| j||fg | _d S rk   )r   ro   weakrefr  r  r   r   Graphr[   r   rG  rH  rO  lifted_freevars	prev_inst	_cur_code_orig_gm_meta_orig_gm_lineno_map_orig_gm_firstlinenosource_fn_stack_target_to_str)rn   r  rO  r   rP  r   rh   ri   ro     s(   


zSubgraphTracer.__init__c              	      s  | j d ur't||f\}}	g }
|D ]}| |}|
| qt|
|	\}}t |||||||| jj	}t
jdkrr|dv rr|j  | jurr jd urr jjd urr|j|j jjd fdd}tdt|  | _d}|j| jurt|jdd	d
  }t|tjjrd}dd |jjD | _|j | _!|j"j#j$| _%n	d | _d | _!d | _%|j&}|r|' j(j)d< |dv r| j*j(j+|fg j(j)d< n#|dkr| j d urt,d | j*j(j+j(j)d | d fg j(j)d< | jr>| j!r>| j%r>|jj-}d }|d ur| j!|| j% d }|d ur>| j| }tj.j/D ]}||v r/|| j(j)|< q d|v r>|d j(j)d< |sdj(j)vrV|j&}|rV|' j(j)d< dj(j)vr|dv rq| j*j(j+|fg j(j)d< n%|dkr| j d urt,d | j*j(j+j(j)d | d fg j(j)d< dj(j)vrg }|r||0  t1|dd }|s|2  t3j45|6 }d7|j(_8S )Nr  r  )linenoc                     s(   t   } djj d d|  S )NzTRACE FX call z from rQ  )rB   rstripr  r  )linecur_instheaderry  tx_coderh   ri   get_trace_call_log_str`  s   z;SubgraphTracer.create_proxy.<locals>.get_trace_call_log_strra  Forig_graphmodulec                   S   s   d S rk   rh   rh   rh   rh   ri   rf  k  s    z-SubgraphTracer.create_proxy.<locals>.<lambda>Tc                 S   s   g | ]}|j qS rh   r  )r   ndrh   rh   ri   r   o  s    z/SubgraphTracer.create_proxy.<locals>.<listcomp>nn_module_stack>   r  r+  r  r  z0Invoking an nn.Module inside HigherOrderOperatorr   stack_tracerO  r  )9rO  r  tree_flatten#maybe_lift_tracked_freevar_to_inputr   tree_unflattenr   rJ  r  ru  r  r  current_instructionr  	positionsr  r  get_line_of_code_headertrace_call_logr~  rH   r  r"   get_contextr/  r  r   r   r   r[   r  r  _lineno_mapr  r   __code__r   r   r  r   r  r  r  r  r(   starts_liner  _COPY_META_FIELDSframe_summaryr  reverser   StackSummary	from_listformatr  r  )rn   r  r  r   r   r  	type_exprproxy_factory_fn	flat_args	tree_specnew_flat_argsrv  maybe_new_argrr  r
  is_retracingorig_graphmodule_mayber  r  node_idxr  fieldframe_summariesmsgsr   r  ri   rJ    s   
+




	








zSubgraphTracer.create_proxyc           
         s   t | j|||| | jd ur-tj|i |}|D ]}t|tjjs"q|j	| j	ks,J dqt
 ||||||}	| jj|	jd< |	S )Nz2create_node using arg not from this SubgraphTracerrF  )r  r  rO  r  arg_tree_leavesr  r   r   r  r[   r   rM  r   r  )
rn   r  r  r   r   r  r   r"  rv  r  r   rh   ri   rM    s   
zSubgraphTracer.create_nodec                 C   sz   t |jdkr-g }|j D ]}|j| jkr!|tt|jj q|D ]}|j| q$| j| | j	
|jd  d S r=  )r  r  r  r[   r-  r:  r   r  rJ  rG  rS  r  )rn   r  user_graph_nodesuserother_graph_noderh   rh   ri   rN    s   zSubgraphTracer.remove_nodec                 C   s`  t d||d ur| nd |d u r| jd usJ d| jr2t|dds2| jj|g 	t
  || jv rNt D ]}| d| }|| jvrM|} nq;| jrntt| j}| j| j}|rg| j|}	n| j|}	n| jd }	|	0 | jd|di |d	}
| jr|r| j \}}|
| j|< || j|< n|
| j|< |
W  d    S 1 sw   Y  d S )
Nzcreate_graph_input %s %sz(none)zByou are required to provide a source for inputs on the root tracerF)allow_cell_or_freevarr  r  rh   )r   )r   r~  r  rO  r   r5   r  r   
setdefaultr   r   extract_stackrG  r   r   r   r:  r  r[   inserting_beforeinserting_afterrJ  popitem)rn   r  r   rw  rb   r  candidate_name	prev_namer  r  r  r   r   rh   rh   ri   r    sJ   




$z!SubgraphTracer.create_graph_inputc                 C   sx   | j d us	J d|| jv r| j| S | |jj}t|j|jjd  || j|< | j d ur:|j| j kr:| j | |S )NzIlift_tracked_freevar_to_input should not be called on root SubgraphTracerr3  )	rO  r  r  r  r  rK   r  rV  lift_tracked_freevar_to_input)rn   r  	new_proxyrh   rh   ri   r8  %  s   


z,SubgraphTracer.lift_tracked_freevar_to_inputc                 C   s*   t |tjjs	|S |j| kr|S | |S )z
        If arg is a free variable, then lift it to be an input.
        Returns the new lifted arg (if arg was a freevar), else the
        original arg.
        )r  r   r   ProxyrV  r8  r  rh   rh   ri   r  7  s
   

z2SubgraphTracer.maybe_lift_tracked_freevar_to_input)NFN)NNN)NNNN)rc   rd   re   r   ro   rJ  rM  rN  r  r8  r  r   rh   rh   r   ri   r     s    : 3
5r   )r   r  r   ri  r   r   r  r  r  r   r  dataclassesr   typingr   r   r   r   r   r   r	   r
   r   r|  torch._guardsr   torch._loggingtorch.nntorch.utils._pytreer  _pytreer  r   r   r   r   torch._utils_internalr   ru  r   %torch.fx.experimental._backward_stater   %torch.fx.experimental.symbolic_shapesr   r   r   torch.fx.passes.runtime_assertr   torch.utils._python_dispatchr   r  r   r}   r   backends.registryr   r   bytecode_transformationr   r   r    r!   r"   r6  r#   current_scope_idr$   excr%   r&   r'   r(   r)   r  r*   r+   mutation_guardr,   r   r-   r.   rb   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   variables.baserL   variables.builderrM   rN   rO   rP   rQ   variables.listsrR   variables.miscrS   variables.nn_modulerT   variables.tensorrU   rV   rW   rX   variables.torch_functionrY   torch._dynamo.symbolic_convertrZ   	getLoggerrc   r   rr  getArtifactLoggergraph_tabular_logrq  graph_sizes_logr  r`   rj   	lru_cacher   r   r   r   r   r   r   r   objectr  r   r  r  r   r   Tracerr   rh   rh   rh   ri   <module>   s   ,<H

#           7	@