o
    Zhr                     @   s  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ZddlZddlZddl	Z	ddl
mZmZ ddlZddlmZ ddlm  mZ ddlmZmZ ddlmZmZ ddlmZ ddlmZm Z  dd	l!m"Z"m#Z# dd
l$m%Z% ddl&m'Z'm(Z(m)Z)m*Z* ddlm+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3 ddl4m5Z5 ddl6m7Z7 ddl8m9Z9m:Z: ddl;m<Z<m=Z=m>Z> erddl?m@Z@ G dd dZAG dd de5ZBG dd de5ZCG dd de5ZDG dd deDZEG dd de5ZFG dd  d e5ZGG d!d" d"e5ZHd#d$ ZIG d%d& d&e5ZJejKG d'd( d(ZLG d)d* d*e>ZMG d+d, d,e>ZNG d-d. d.e5ZOG d/d0 d0e5ZPG d1d2 d2e5ZQG d3d4 d4e5ZRG d5d6 d6e5ZSG d7d8 d8e5ZTejUdd9d:d; ZVejUdd9d<d= ZWG d>d? d?e5ZXG d@dA dAe5ZYG dBdC dCe5ZZG dDdE dEe5Z[G dFdG dGe5Z\G dHdI dIe5Z]G dJdK dKe5Z^G dLdM dMe^Z_G dNdO dOe^Z`G dPdQ dQe^ZaG dRdS dSe^ZbG dTdU dUe^ZcejdebejeebejfeciZgG dVdW dWe5ZhG dXdY dYe5ZiG dZd[ d[e5ZjdS )\a  
This module contains miscellaneous variable tracker implementations for various Python types
and features used in Dynamo's symbolic execution. These classes help track and propagate
information about different kinds of variables during graph capture.

Key classes include:
- SuperVariable: Handles super() calls and method resolution
- ExceptionVariable: Tracks exception objects
- RandomVariable: Manages random number generators
- GetAttrVariable: Tracks attribute access
- MethodWrapperVariable: Handles method wrappers
- PythonModuleVariable: Tracks Python modules
- NumpyVariable: Handles numpy functions and types
- StringFormatVariable: Manages string formatting
- DebuggingVariable: Handles print and logging
    N)OptionalTYPE_CHECKING   )config	variables)create_call_functioncreate_instruction)$do_not_convert_to_tracable_parameter)raise_observed_exceptionunimplemented)GuardBuilderinstall_guard)unpatched_nn_module_init)
AttrSourceGetItemSource
TypeSourceWeakRefCallSource)	check_unspec_or_constant_argscmp_name_to_op_mappingidentityis_tensor_base_attr_getteristypelist_methodsproxy_args_kwargsset_example_valuetuple_methods   )VariableTracker)ConstantVariable)NestedUserFunctionVariableUserFunctionVariable)call_random_fnis_standard_setattrUserDefinedObjectVariable)InstructionTranslatorc                   @   s   e Zd ZdS )NO_SUCH_SUBOBJN)__name__
__module____qualname__ r)   r)   K/var/www/auris/lib/python3.10/site-packages/torch/_dynamo/variables/misc.pyr%   ?   s    r%   c                       sp   e Zd Zh ejZdd fddZ fddZd fd	d
ZdddeddfddZ							dddZ
  ZS )SuperVariableNreturnc                    s"   t  jdi | || _|| _d S Nr)   )super__init__typevarobjvar)selfr0   r1   kwargs	__class__r)   r*   r/   H   s   
zSuperVariable.__init__c                    sZ      fdd  | j | jd ur# | j  tdd d S  tdd d S )Nc                      s   t tS N)r   BuiltinVariabler.   r)   )r5   codegenr)   r*   <lambda>U   s    z+SuperVariable.reconstruct.<locals>.<lambda>r   Fr   )add_push_nullr0   r1   extend_outputr   r2   r8   r4   r8   r*   reconstructT   s   


zSuperVariable.reconstructtxr$   c                    s   | j sJ d| j }| j  }| j jrt| j jnd }t|tr*| j j}| j j}d }|j	}z	|
|d }W n tyK   tt|||d f Y S w t|t|D ]$}	||	 j|t }
rw|
turw|rqttt|d|	|}|
|f  S qStd d S )Nz1-arg super not implementedr   __mro__zUnable to resolve super getattr)r1   r0   as_python_constantpython_typesourcer   
issubclasstypevaluer@   index
ValueErrorgetattrr.   rangelen__dict__getr%   r   r   r   )r2   r?   nameZsearch_typeZtype_to_useZtype_to_use_sourcerC   Z
search_mrostart_indexrG   Zresolved_getattrr4   r)   r*   _resolved_getattr_and_source]   s8   

	

z*SuperVariable._resolved_getattr_and_sourcerN   r   c                 C   sJ   |  | |\}}tj|st| |S |rt|tj tjj	||dS )NrC   )
rP   r   r   
is_literalGetAttrVariabler   
make_guardr   ZCONSTANT_MATCHcreate)r2   r?   rN   rF   rC   r)   r)   r*   var_getattr   s   	
zSuperVariable.var_getattrargslist[VariableTracker]r3   dict[str, VariableTracker]c                 C   s  |  | |\}}|tju rttS |tjjju r\| j}ddl	m
} t|tjrVt|j|rV|sV|sVt  tjt|d|| jg| |W  d    S 1 sOw   Y  ntd n| jjrt|dr|jdkrtj|r|j}	t|	dr|	jdkrt|	}
n
|j}tj|	|d}
|
|d||S t|trt|jt j!rtj|j|d|||S t|t"rt|jt j!rtj#|j| j|d|||S t|t j!rtj||d|| jg| |S t|t j$rtj#|j| j|d|||S t%|rt| jtr| jj&|g|R i |S |tj'u rU|d	 }z|( }W n t)y.   td
|  Y nw |j*j	+| jsDtd| j d| d |j*j	,| j|t-  t.d S t| jtj/rn|| jj0v rn| jj1||||S t| jtj2r|t3v r| jj4||||S t| jtj5r|t6v r| jj7||||S |tj8u r|d	 j9}|j*j	:| j|r|j*j	j;| j|dd}t|tj-rt<t=| |S z	| jj98|}W n t=y   t<t=| Y nw | jot>| j|}t?@|||S td|  d S )Nr   )AttributeMutationNewrQ   zsuper() nn.Module.__init__r&   __new__r'   builtinsr   znon-const delattr attr: zdelattr(, z, ...)T)Z
deleted_okznon-function or method super: )ArP   objectr/   LambdaVariabler   torchnnModuler1   side_effectsrZ   
isinstancer   r#   mutation_typer	   r    r   call_functionr   rC   hasattrr&   UserDefinedClassVariableZis_supported_new_method__self__r'   r7   membercall_methodstaticmethod__func__typesFunctionTypeclassmethodUserMethodVariable
MethodTyper"   method_setattr_standard__delattr__rA   NotImplementedErroroutputZis_attribute_mutation
store_attrDeletedVariabler   ZUserDefinedDictVariableZ_dict_methodsZ_dict_vtZUserDefinedTupleVariabler   Z	_tuple_vtZUserDefinedListVariabler   Z_list_vt__getattribute__rF   has_pending_mutation_of_attr	load_attrr
   AttributeErrorr   r   build)r2   r?   rN   rW   r3   Zinner_fnrC   r1   rZ   Zuser_clsZuser_cls_vtZuser_cls_sourceattrZ	attr_nameresult
attr_valuer)   r)   r*   rk      s   


$











zSuperVariable.call_methodr6   r,   Nr?   r$   rW   rX   r3   rY   r,   r   )r&   r'   r(   r   _nonvar_fieldsr/   r>   rP   strrV   rk   __classcell__r)   r)   r4   r*   r+   C   s    	/r+   c                       sr   e Zd Zd fddZdddZdd	 Zd
d ZdddedefddZ fddZ	 fddZ
dd ZeZ  ZS )ExceptionVariabler,   Nc                    sJ   t  jdi | || _|| _td | _td | _td| _td | _d S )NFr)   )	r.   r/   exc_typerW   r   __context__	__cause____suppress_context____traceback__)r2   r   rW   r3   r4   r)   r*   r/     s   


zExceptionVariable.__init__contextc                 C   s
   || _ d S r6   )r   )r2   r   r)   r)   r*   set_context$     
zExceptionVariable.set_contextc                    sf      fdd  j  tjd dtdd f fdd}|d |d	 |d
 d S )Nc                      s     djjS )Nr\   )load_import_fromr   r&   r)   r8   r2   r)   r*   r9   )      z/ExceptionVariable.reconstruct.<locals>.<lambda>FrN   r,   c                    sX   t | }t|tr|jdv sJ |d S     |   d  |  d S )N)TFNr   )rI   r   r   rF   dup_topr;   Zrot_nrw   )rN   r~   r   r)   r*   codegen_attr.  s   

z3ExceptionVariable.reconstruct.<locals>.codegen_attrr   r   r   )r:   ZforeachrW   rf   rK   r   )r2   r8   r   r)   r   r*   r>   '  s   
zExceptionVariable.reconstructc                 C      | j S r6   )r   r2   r)   r)   r*   rB   <     zExceptionVariable.python_typer?   r$   name_varvalc                    s   fdd}|  }|dkr| | nj|dkr>t|tr"|jd u s/t|tjtjtjtj	fr9|| _
td| _nE|d n@|dkrUt|trP|jdv rP|| _n.|d n)|d	krst|trg|jd u rg|| _ntd
| d| d ntd
| d| d td S )Nc                    s   t t t| gd d S )N)rW   )r
   	TypeErrorr   )msgr?   r)   r*   raise_errorE  s   z3ExceptionVariable.call_setattr.<locals>.raise_errorr   r   Tz9exception cause must be None or derive from BaseExceptionr   )TFr   zsetattr(ExceptionVariable, r]   ))rA   r   rd   r   rF   r   r7   r   Z!UserDefinedExceptionClassVariableZ"UserDefinedExceptionObjectVariabler   r   r   r   )r2   r?   r   r   r   rN   r)   r   r*   call_setattr?  s4   	


zExceptionVariable.call_setattrc                    sP   |dkr| j |g|R  S |dkr|\}|  |td| | S t ||||S )N__setattr__with_tracebackr   )r   r   r.   rk   )r2   r?   rN   rW   r3   tbr4   r)   r*   rk   g  s   zExceptionVariable.call_methodc                    sd   |dkr| j S |dkr| jS |dkr| jS |dkrtd S |dkr+tj| j| jdS t 	||S )Nr   r   r   r   rW   rQ   )
r   r   r   r   r   ZListVariablerW   rC   r.   rV   )r2   r?   rN   r4   r)   r*   rV   q  s   
zExceptionVariable.var_getattrc                 C   s   | j j d| j dS )N(r   )r5   r&   r   r   r)   r)   r*   __str__~     zExceptionVariable.__str__r   )r   r   )r&   r'   r(   r/   r   r>   rB   r   r   rk   rV   r   __repr__r   r)   r)   r4   r*   r     s     

(
r   c                   @      e Zd ZdZdS )UnknownVariablez
    It could be anything!
    Nr&   r'   r(   __doc__r)   r)   r)   r*   r         r   c                   @   r   )DelayGraphBreakVariablez^
    Used to insert a dummy variable in the stack to do the graph break at CALL_FUNCTION.
    Nr   r)   r)   r)   r*   r     r   r   c                   @   sH   e Zd ZdZdd Zdddeddfd	d
Z								dddZdS )ComptimeVariableza
    This variable is special, it lets you execute arbitrary code at
    Dynamo compile time
    c                 C   s   t d)Nzcomptime is special form)ru   r<   r)   r)   r*   r>     s   zComptimeVariable.reconstructr?   r$   rN   r,   r   c                 C   s2   ddl m } ddlm} |t||t| j|dS )Nr   )comptimer   )r    rQ   )r   	functionsr    rI   r   rC   )r2   r?   rN   r   r    r)   r)   r*   rV     s
   zComptimeVariable.var_getattrrW   rX   r3   rY   c                 C   s   ddl m} |r
J t|dksJ |d }t|tr$| || n:t|trU| }|jr8J d|j	 t
||j|j |jrJt|jjnd d}||| n	tdt| tjd S )Nr   )ComptimeContextr   zOcomptime function must not have free variables, but these variables were free: r)   z"unsupported argument to comptime: )r   r   rK   rd   r    Zget_functionr   get_codeclosureco_freevarsrn   ro   	f_globalsfn_namerA   defaultstupleitemsRuntimeErrorrE   r   r   rU   )r2   r?   rW   r3   r   fncodefuncr)   r)   r*   rf     s.   

zComptimeVariable.call_functionNr?   r$   rW   rX   r3   rY   r,   r   )r&   r'   r(   r   r>   r   rV   rf   r)   r)   r)   r*   r     s    
r   c                       sL   e Zd ZU ee ed< dZee ed< 	ddee ddf fddZ  Z	S )CellVariablepre_existing_contentsN
local_namer,   c                       t  jdi | || _d S r-   )r.   r/   r   )r2   r   r3   r4   r)   r*   r/     s   
zCellVariable.__init__r6   )
r&   r'   r(   r   r   __annotations__r   r   r/   r   r)   r)   r4   r*   r     s   
 r   c                       s   e Zd Zd fddZ  ZS )NewGlobalVariabler,   Nc                       t  jdi | d S r-   r.   r/   r2   r3   r4   r)   r*   r/     r   zNewGlobalVariable.__init__r   )r&   r'   r(   r/   r   r)   r)   r4   r*   r     s    r   c                    s    fdd}t |_|S )Nc                     s    j | i |S r6   )applyrW   r3   fn_clsr)   r*   trampoline_autograd_apply  s   zDproduce_trampoline_autograd_apply.<locals>.trampoline_autograd_apply)!produce_trampoline_autograd_applyZ_origin)r   r   r)   r   r*   r     s   r   c                       s^   e Zd ZdZdhejZd fddZdd	d
ZdddZdddZ					dddZ
  ZS )AutogradFunctionVariablez-represents a torch.autograd.Function subclassr   r,   Nc                    r   r-   )r.   r/   r   )r2   r   r3   r4   r)   r*   r/        
z!AutogradFunctionVariable.__init__r?   r$   c                    s*  d  fdd}t |||f  rt rtjdu r!td ddlm	} ddl
m} | jj}|| jj}|rB|| jj| jj}| jj}	|	tjjjurQtd | jj}
|
tjjjur`td	 d
dlm} | j}|d u ryt| jj| jj}||| jj|t|ddd||}| jrt| jd}t|tj  |rt| jd}t|tj  |S | jrt| jd}nd }| jj}t!"||}|g|}t#|t$j%rt&'|}t(|d
 t(|j)kr|d
d  }t*j+||d||S t#|t$j,rt*j-|j.t*/| j|d||S td|  d S )NFc                    s@   t | tjr| jdurd t | tjr| rd d S d S d S )NFT)rd   r   TensorVariablerequires_gradNNModuleVariableZis_training)noder   r?   r)   r*   visit  s   

z2AutogradFunctionVariable.call_apply.<locals>.visitzNThe config.capture_autograd_function flag is deprecated, it's now always true.r   )#autograd_function_forward_rewritten)_is_setup_context_definedzNYI - User defind vjpzNYI - User defind jvpr   )AutogradFunctionApplyVariabler   )rj   rQ   forwardsetup_contextz?non-function or method in subclass of torch.autograd.Function: )0r   r   r`   Zis_grad_enabledr   Zcapture_autograd_functionwarningswarnZ"torch._functorch.autograd_functionr   Ztorch.autograd.functionr   r   r   r   ZvjpautogradFunctionr   ZjvpZhigher_order_opsr   rC   r   Zimport_sourcer'   r&   backwardrf   r   rT   r   ZFUNCTION_MATCHAutogradFunctionContextVariablerU   rd   rn   ro   inspect	signaturerK   _parametersr   r    rr   rq   rm   rh   )r2   r?   rW   r3   r   r   r   Z
forward_fnZis_setup_ctx_definedZvjp_fnZjvp_fnr   rC   r   Zfwd_srcZsetup_ctx_srcr   ctxsigr)   r   r*   
call_apply  s   	






z#AutogradFunctionVariable.call_applyc                 C   sX   | j j}t|d jtjjju sJ t|t	j
sJ t| jd}tj||d|||S )Nr   r   rQ   )r   r   rE   rF   r`   _dynamoexternal_utilsZFakeBackwardCFunctionrd   rn   ro   r   rC   r   r    rf   )r2   r?   rW   r3   r   Z	fn_sourcer)   r)   r*   call_backward[  s   z&AutogradFunctionVariable.call_backwardc                 C   s
   t | jS r6   )r   r   r2   r?   rW   r3   r)   r)   r*   rf   e  r   z&AutogradFunctionVariable.call_functionrW   rX   r3   rY   c                 C   sX  ddl m} ddlm} |dkr3|| jr,t| j}|||jjd|gt||R  dS | 	|||S |dkr>| 
|||S dd	lm } | jd urOt| j|nd }	z	t| j|}
W n tye   d }
Y nw t|
tr|
| j}|	d ur||j||	d
|||S ||||||S t|
trtj|
j| |	d
|||S td|  d S )Nr   )is_callable_allowedr   )wrap_fx_proxyr   rf   )r?   proxyr   )trace_rulesrQ   zUnsupported method: )r   r   builderr   r   r   rv   create_proxyr   r   r    rC   r   r   getattr_staticr|   rd   rl   __get__lookupZcreate_with_sourcerf   rp   r   rq   rm   r   )r2   r?   rN   rW   r3   r   r   r   r   rC   objr   r)   r)   r*   rk   h  sX   
	



z$AutogradFunctionVariable.call_methodr   r   )rW   rX   r3   rY   )r&   r'   r(   r   r   r   r/   r   r   rf   rk   r   r)   r)   r4   r*   r     s    

a

r   c                   @   s&   e Zd ZU ejedZee ed< dS )SavedTensorBox)default_factorytensorsN)	r&   r'   r(   dataclassesfieldlistr   r   r   r)   r)   r)   r*   r     s   
 r   c                       s   e Zd ZdZdddhejZ						d	d fdd	ZeddddZdd Z							d fddZ
d fddZ  ZS )r   zZ
    Tracks an autograd.Function() context using mutation tracking in side_effects.py
    r   	inferencesaved_tensorsNFr,   c           	         s:   t  jd||d| || _|| _|| _|| _|| _d S N)rF   
value_typer)   )r.   r/   r   r   r   needs_input_gradnon_differentiable)	r2   rF   r   r   r   r   r   r   r3   r4   r)   r*   r/     s   
z(AutogradFunctionContextVariable.__init__r?   r$   c                 C   st   d }|r|st dd |D }| jdtjjjdi }| jjd tjjjt	j
td|t |di }t|j|j |S )Nc                 s   s"    | ]}t |tjo|jV  qd S r6   )rd   r   r   r   .0xr)   r)   r*   	<genexpr>  s
    
z9AutogradFunctionContextVariable.create.<locals>.<genexpr>rf   r)   T)r   r   r   r   )r   rv   r   r`   r   functionZFunctionCtxrc   Ztrack_object_new	functoolspartialr   r   r   r   rF   )r?   rW   r3   r   r   outr)   r)   r*   rU     s,   z&AutogradFunctionContextVariable.createc                 C   s   | j d u r	td | j S )Nzproxy not set)r   r   r   r)   r)   r*   as_proxy  s   
z(AutogradFunctionContextVariable.as_proxyrW   rX   r3   rY   r   c                    s   |dkrt  ||||S |dkr't|dksJ t|i d | _tjd S |dkr2td|  | j	d u r;td | j
sM| jrC|rEJ |jj| | t| j	jdkrYg | j	_|D ]	}| j	j| q[tjd S )Nr   mark_non_differentiabler   save_for_backwardz"autograd.Function context method: zCsave_for_backward only supported on a newly constructed FunctionCtx)r.   rk   rK   r   r   r   r   rU   r   r   r   rC   rv   rc   Ztrack_save_for_backwardr   append)r2   r?   rN   rW   r3   argr4   r)   r*   rk     s(   
z+AutogradFunctionContextVariable.call_methodc                    s    dv rt  fddS  dkr jd ur ttjjS  dkrBjd ur0tjjS j	rBt
j	d}tjj|S t  S )N)r  r
  c                     s     | |S r6   )rk   r   rN   r2   r?   r)   r*   r9     r   z=AutogradFunctionContextVariable.var_getattr.<locals>.<lambda>r   r   )r_   r   r   TupleVariabler   r   r   r   rU   rC   r   r   r}   rF   r.   rV   r2   r?   rN   rC   r4   r  r*   rV     s   
z+AutogradFunctionContextVariable.var_getattr)NFNNNNr   NNr   r   )r&   r'   r(   r   r#   r   r/   rl   rU   r	  rk   rV   r   r)   r)   r4   r*   r     s8    

 r   c                       s>   e Zd ZdZ	d	d fddZ							
dddZ  ZS )AutogradEngineVariablez;
    Represents a torch._C._ImperativeEngine instance.
    Nr,   c                    s   t  jd||d| d S r   r   )r2   rF   r   r3   r4   r)   r*   r/     s   zAutogradEngineVariable.__init__rW   rX   r3   rY   r   c                 C   sp   |dkr/t jjjr)|jsJ dtjt jjjj	| j
d||jj g|R |S td d S td|  d S )Nqueue_callbackzXqueue_callback() is only supported when Compiled Autograd is enabled with fullgraph=TruerQ   z#torch._C._ImperativeEngine method: )r`   r   Zcompiled_autogradZin_compiled_autograd_regionZ	one_graphr   r    r   ZFakeCompiledAutogradEnginer  rC   rf   rv   rc   Zget_ca_final_callbacks_varr   r2   r?   rN   rW   r3   r)   r)   r*   rk   "  s&   

	z"AutogradEngineVariable.call_methodr6   r   r   r&   r'   r(   r   r/   rk   r   r)   r)   r4   r*   r    s    r  c                       s8   e Zd Zd fddZ							
		dddZ  ZS )r_   r,   Nc                    r   r-   )r.   r/   r   )r2   r   r3   r4   r)   r*   r/   ?  r   zLambdaVariable.__init__r?   r$   rW   rX   r3   rY   r   c                 C   s   | j |i |S r6   )r   r   r)   r)   r*   rf   C  s   zLambdaVariable.call_functionr   r   )r&   r'   r(   r/   rf   r   r)   r)   r4   r*   r_   >  s    r_   c                       s   e Zd ZddhejZd!d" fddZ fddZdefd	d
Ze	de
jjfddZdd Zdd Zd#ddZdd Z								d$ddZdee deeef def fdd Z  ZS )%rS   rN   py_typeNr,   c                    sD   t  jdi | t|tsJ t|tsJ || _|| _|| _d S r-   )r.   r/   rd   r   r   r   rN   r  )r2   r   rN   r  r3   r4   r)   r*   r/   S  s   
zGetAttrVariable.__init__c                    s   | j d ur| j S t  S r6   )r  r.   rB   r   r4   r)   r*   rB   [  s   

zGetAttrVariable.python_typec                 C   s   | j j d| j d| j dS Nr   r]   r   )r5   r&   r   rN   r   r)   r)   r*   r   a  s   zGetAttrVariable.__repr__
base_proxyc                 C   s
   t | |S r6   )rI   )r  r~   r)   r)   r*   create_getattr_proxyd  s   
z$GetAttrVariable.create_getattr_proxyc                 C   s   t | j | jS r6   )rS   r  r   r	  rN   r   r)   r)   r*   r	  h  s   zGetAttrVariable.as_proxyc                 C   s8   | j  }zt|| jW S  ty   t|  dd w )Nz is not a constant)r   rA   rI   rN   r|   ru   )r2   constantr)   r)   r*   rA   k  s   
z"GetAttrVariable.as_python_constantr?   r$   c                 C   sZ   t | jtjs	t|j| jj}| j|j	vrtt
|| j}||j	vr'tt
||S r6   )rd   r   r   r   ru   rv   Zget_submoduleZ
module_keyrN   rL   r   r   )r2   r?   rN   Zstep1Zstep2r)   r)   r*   const_getattrr  s   
zGetAttrVariable.const_getattrc                 C   s    || j  ||| j d S r6   )r   r;   Zcreate_load_attrsrN   r<   r)   r)   r*   r>   }  s   
zGetAttrVariable.reconstructrW   rX   r3   rY   r   c                 C   s   | j || j||S r6   )r   rk   rN   r   r)   r)   r*   rf     s   zGetAttrVariable.call_functionc                    sl  |dv rF| j dkrF|sF|d  rFt| jtjtjtjfrF| j}|d  }|	||r2|
||S |dkrEt|dkr@|d S td S ng|dkr| j dkrt|dkr|d  r|st| jtjtjtjfr| j}|d  }|	||r}tdS td	S |d
kr| j dkr|st| jtjr| j||d |d S t| jtjr| j| t ||||S )N)__getitem__rM   rL   r   rM   r   r   __contains__TF__setitem__)rN   is_python_constantrd   r   r   r#   r   rh   rA   Zhas_key_in_generic_dictrV   rK   r   rs   Zconvert_to_unspecializedr.   rk   )r2   r?   rN   rW   r3   r   keyr4   r)   r*   rk     sb   






zGetAttrVariable.call_methodr6   r   r   r   )r&   r'   r(   r   r   r/   rB   r   r   rl   r`   ZfxZProxyr  r	  rA   r  r>   rf   r   dictrk   r   r)   r)   r4   r*   rS   L  s>    


rS   c                       sL   e Zd Zd fddZ							
		d fddZdd Zdd Z  ZS )MethodWrapperVariabler,   Nc                    s"   t  jdi | || _i | _d S r-   )r.   r/   method_wrapperZ_builtin_fns)r2   r#  r3   r4   r)   r*   r/     s   
zMethodWrapperVariable.__init__r?   r$   rW   rX   r3   rY   r   c                    s   t | jr&t|d tjr&t|dkrt|dksJ |d || jjjS | jj}| jj}|dkrJt	|j
}|tj
u rJtt|||g||S t ||| d S )Nr   r   r/   )r   r#  rd   r   r   rK   rV   ri   r&   rE   r/   r^   r7   rk   r.   rf   )r2   r?   rW   r3   Zself_objZwrapper_nameZfn_objr4   r)   r*   rf     s   



z#MethodWrapperVariable.call_functionc                 C      dS NTr)   r   r)   r)   r*   r       z(MethodWrapperVariable.is_python_constantc                 C   r   r6   )r#  r   r)   r)   r*   rA     r   z(MethodWrapperVariable.as_python_constantr   r   )r&   r'   r(   r/   rf   r  rA   r   r)   r)   r4   r*   r"    s    r"  c                       s<   e Zd Zd fddZd fddZd	d
 Zdd Z  ZS )GetSetDescriptorVariabler,   Nc                    r   r-   )r.   r/   desc)r2   r(  r3   r4   r)   r*   r/     r   z!GetSetDescriptorVariable.__init__r?   r$   c                    s:   |dkr| j rt| j d}t|| jj|S t ||S )Nr   )rC   r   r   r}   r(  r   r.   rV   r  r4   r)   r*   rV     s   z$GetSetDescriptorVariable.var_getattrc                 C   r$  r%  r)   r   r)   r)   r*   r    r&  z+GetSetDescriptorVariable.is_python_constantc                 C   r   r6   )r(  r   r)   r)   r*   rA     r   z+GetSetDescriptorVariable.as_python_constantr   r   )r&   r'   r(   r/   rV   r  rA   r   r)   r)   r4   r*   r'    s
    r'  c                       sh   e Zd ZddhejZdejddf fddZdd Zd	d
 Z	de
fddZdddZdddZ  ZS )PythonModuleVariablerF   is_torchr,   Nc                    s6   t  jdi | || _| jtu p| jjd| _d S )Nztorch.r)   )r.   r/   rF   r`   r&   
startswithr*  r2   rF   r3   r4   r)   r*   r/     s   zPythonModuleVariable.__init__c                 C      t jS r6   )rn   
ModuleTyper   r)   r)   r*   rB     r   z PythonModuleVariable.python_typec                 C   r   r6   rF   r   r)   r)   r*   rA     r   z'PythonModuleVariable.as_python_constantc                 C   s   d| j  dS )NzPythonModuleVariable(r   r/  r   r)   r)   r*   r     s   zPythonModuleVariable.__repr__r?   r$   c                 C   s   t | j|}tj|S r6   )rg   rF   r   r   rU   r2   r?   rN   r   r)   r)   r*   call_obj_hasattr   s   z%PythonModuleVariable.call_obj_hasattrc                 C   sl   |j j| |r|j j| |S | js|| jjvr t| j|}n| jj| }| jo.t	| j|}t
|||S r6   )rv   rc   rz   r{   r*  rF   rL   rI   rC   r   r   r}   )r2   r?   rN   r   rC   r)   r)   r*   rV   $  s   z PythonModuleVariable.var_getattrr   )r&   r'   r(   r   r   rn   r.  r/   rB   rA   r   r   r1  rV   r   r)   r)   r4   r*   r)    s    
r)  c                       sX   e Zd Zd fddZ							dd
dZdddefddZdd ZdddZ  Z	S )TypingVariabler,   Nc                    r   r-   r.   r/   rF   r,  r4   r)   r*   r/   2  r   zTypingVariable.__init__rW   rX   r3   rY   r   c                 C   s:   |dkrt |dkr| j|d   }t|S td d S )Nr  r   r   z+unsupported method call on typing variablel)rK   rF   rA   r2  r   )r2   r?   rN   rW   r3   Z
new_typingr)   r)   r*   rk   6  s   zTypingVariable.call_methodr?   r$   rN   c                 C   sz   ddl m}m} |tv rt| |S |jj| |r!|j	| |S t
| j|}| jr7t| j|}||||S |||S )Nr   )SourcelessBuilderVariableBuilder)r   r4  r5  r   r   rS   rv   rc   rz   r{   rI   rF   rC   r   rU   )r2   r?   rN   r4  r5  rF   Zattr_sourcer)   r)   r*   rV   C  s   zTypingVariable.var_getattrc                 C   r   r6   r/  r   r)   r)   r*   rA   S  r   z!TypingVariable.as_python_constantr8   torch._dynamo.codegen.PyCodegenc                 C   s   | || j d S r6   )append_outputcreate_load_constrF   r<   r)   r)   r*   r>   V  s   zTypingVariable.reconstructr   r   )r8   r6  r,   N)
r&   r'   r(   r/   rk   r   rV   rA   r>   r   r)   r)   r4   r*   r2  1  s    
r2  )maxsizec                  C   sZ   ddl m}  i }|  D ]\}}|j D ]\}}t|r)t||d }r)|||< qq|S )zd
    This generates a mapping from numpy modules to their torch._numpy
    modules equivalents.
    r   )NP_TO_TNP_MODULEN)utilsr:  r   rL   callablerI   )r:  Znp_fn_to_tnp_fnZnp_modZtnp_modr   Ztnp_fnZnp_fnr)   r)   r*   get_np_to_tnp_mapq  s   r=  c                  C   s   t  } dd |  D S )z
    This is just the reverse mapping of get_np_to_tnp_map() - mapping from
    torch._numpy modules to numpy equivalents.
    c                 S   s   i | ]\}}||qS r)   r)   r  kvr)   r)   r*   
<dictcomp>  s    z%get_tnp_to_np_map.<locals>.<dictcomp>)r=  r   )mr)   r)   r*   get_tnp_to_np_map  s   rC  c                       s   e Zd ZdZejfZd fddZedd Z	edd	 Z
	
							dddZ						dddZdd Z fddZ  ZS )NumpyVariablezz
    Wrapper around `numpy.*`. Currently, is able to trace a small subset of numpy functions as well as numpy dtypes.
    r,   Nc                    r   r-   r3  r,  r4   r)   r*   r/     r   zNumpyVariable.__init__c                 C   s:   |j d}t|dkr|d d ddgksJ || jv S N.r   r`   _numpy)r'   splitrK   constant_fold_functionsclsr   modr)   r)   r*   can_constant_fold_through  s   $
z'NumpyVariable.can_constant_fold_throughc                 C   s<   |j d}t|dkr|d d ddgksJ t|d S rE  )r'   rH  rK   np_constant_collections_maprM   rJ  r)   r)   r*    get_constant_collection_for_func  s   $z.NumpyVariable.get_constant_collection_for_funcr?   r$   rW   rX   r3   rY   r   c           
   	   C   s  t jstd| j d ddlm} ddlm} t 	| j}|d u r,td| j d | 
| }d urez|| jd	d
 |D i dd | D W S  tyd   t| jj d| d|  Y d S w |jdkrt jrd|j d}|dt j 7 }t| ||j||\}}| |rt||rtj|  dd
 |D i dd | D S |jjd||gt||R  }	|||	S )Nznumpy.z()r   )numpy_to_tensor_wrapperr   )NumpyNdarrayVariablezCan't find numpy function zM in torch._numpy.  Please file an issue to request support for this function.c                 S      g | ]}|  qS r)   rA   r  r)   r)   r*   
<listcomp>      z/NumpyVariable.call_function.<locals>.<listcomp>c                 S      i | ]	\}}||  qS r)   rS  r>  r)   r)   r*   rA        z/NumpyVariable.call_function.<locals>.<dictcomp>z with non-const args:  ztorch._numpy.randomz
delegate 'z' to NumPy itself via zconfg.use_numpy_random_stream=c                 S   rR  r)   rS  r  r)   r)   r*   rT    rU  c                 S   rV  r)   rS  r>  r)   r)   r*   rA    rW  rf   )r   trace_numpyr   rF   r;  rP  ZtensorrQ  r=  rM   rO  r   ru   r&   r'   Zuse_numpy_random_streamr(   Z
patch_argsrM  r   r   r   rU   rA   rv   r   r   )
r2   r?   rW   r3   rP  rQ  r   Zcollection_variable_typr   r   r)   r)   r*   rf     sb   


zNumpyVariable.call_functionc                 C   s   t d d S )Nnumpy)r   r  r)   r)   r*   rk     s   zNumpyVariable.call_methodc                 C   r   r6   r/  r   r)   r)   r*   rA     r   z NumpyVariable.as_python_constantc                    s$   t jrt| jtr| jjS t  S r6   )r   rY  rd   rF   rE   r&   r.   r	  r   r4   r)   r*   r	    s   
zNumpyVariable.as_proxyr   r   r   )r&   r'   r(   r   tnpZ
issubdtyperI  r/   rp   rM  rO  rf   rk   rA   r	  r   r)   r)   r4   r*   rD    s4    


@
	rD  c                       s4   e Zd Zd	 fddZdefddZdd Z  ZS )
NullVariabler,   Nc                    r   r-   r   r   r4   r)   r*   r/     r   zNullVariable.__init__c                 C   r$  )Nr\  r)   r   r)   r)   r*   r     r&  zNullVariable.__repr__c                 C   s$   t jdk r	td |td d S )N)      z0cannot reconstruct NullVariable in < Python 3.11Z	PUSH_NULL)sysversion_infor   r7  r   r<   r)   r)   r*   r>     s   
zNullVariable.reconstructr   )r&   r'   r(   r/   r   r   r>   r   r)   r)   r4   r*   r\    s    r\  c                   @   r   )rx   z"Marker used to implement delattr()Nr   r)   r)   r)   r*   rx     r   rx   c                       sP   e Zd ZdZdhejZedd Zd fddZde	fd	d
Z
dd Z  ZS )StringFormatVariablez[
    Represents a call to str.format(), we delay calling format until after the graph.
    format_stringc                 C   sb   t dd t|| D r'tj|jdd |D i dd | D S | |t	|t
|S )Nc                 s   s    | ]}|  V  qd S r6   )r  r  r)   r)   r*   r    s
    
z.StringFormatVariable.create.<locals>.<genexpr>c                 S   rR  r)   rS  )r  r@  r)   r)   r*   rT    rU  z/StringFormatVariable.create.<locals>.<listcomp>c                 S   rV  r)   rS  r>  r)   r)   r*   rA    rW  z/StringFormatVariable.create.<locals>.<dictcomp>)all	itertoolschainvaluesr   r   rU   formatr   r   r!  )rK  rb  sym_args
sym_kwargsr)   r)   r*   rU     s   zStringFormatVariable.creater,   Nc                    s6   t  jdi | t|tsJ || _|| _|| _d S r-   )r.   r/   rd   r   rb  rh  ri  )r2   rb  rh  ri  r3   r4   r)   r*   r/   $  s
   
zStringFormatVariable.__init__c                 C   s&   | j j d| jd| jd| jdS r  )r5   r&   rb  rh  ri  r   r)   r)   r*   r   +  s   &zStringFormatVariable.__repr__c                    s`    j  fdddd  tj dd j D } t|  tddd	 d S )
Nc                      s      j dgS )Nrg  )r;   r8  rb  create_load_attrr)   r   r)   r*   r9   0  s
    
z2StringFormatVariable.reconstruct.<locals>.<lambda>T)Zcall_function_exc                 S   s   i | ]\}}t j||qS r)   r   r   rU   r>  r)   r)   r*   rA  9  s    z4StringFormatVariable.reconstruct.<locals>.<dictcomp>CALL_FUNCTION_EXr   )r  )	r:   r   r  rh  ri  r   ZConstDictVariabler7  r   )r2   r8   r3   r)   r   r*   r>   .  s   	z StringFormatVariable.reconstructr   )r&   r'   r(   r   r   r   rp   rU   r/   r   r   r>   r   r)   r)   r4   r*   ra    s    
ra  c                       sN   e Zd ZdZd fddZedd Zdd
dZdd ZedddZ	  Z
S )DebuggingVariablez
    Represents a call to a debugging function like print(), or something
    registered to config.reorderable_logging_functions.
    r,   Nc                    r   r-   r3  r,  r4   r)   r*   r/   F  r   zDebuggingVariable.__init__c                 C   s(   t | ot| tjtjfo| tjjjv S r6   )	r<  rd   rn   ro   BuiltinFunctionTyper`   r   r   Zreorderable_logging_functions)r   r)   r)   r*   is_reorderable_logging_functionJ  s
   z1DebuggingVariable.is_reorderable_logging_functionr?   r$   c                 C   sP   |j rd S | | j||std| j d| d| d |j| t|f d S )NzReordering debugging function z with inputs rX  z is not yet implemented.)exportcan_reorder_logsrF   r   Zdebug_localsr  r   r   r)   r)   r*   rf   R  s   
zDebuggingVariable.call_functionc                 C   s   | j |S r6   )rC   r>   r<   r)   r)   r*   r>   _  s   zDebuggingVariable.reconstructTc                 C   s:   t jt jtf}t||g}|D ]
}t||s dS qdS )zm
        Run some additional checks for what sort of function calls can we
        actually reorder.
        FT)r   r   r   ra  pytreeZtree_leavesrd   )r   rW   r3   Zallowed_input_typesZ	flat_argsr  r)   r)   r*   rq  b  s   
z"DebuggingVariable.can_reorder_logsr   r   )r,   T)r&   r'   r(   r   r/   rl   ro  rf   r>   rq  r   r)   r)   r4   r*   rm  @  s    

rm  c                       s8   e Zd ZdZd fddZ							
dddZ  ZS )LoggingLoggerVariablez<
    Represents a call to any of logging.Logger methods
    r,   Nc                    r   r-   r3  r,  r4   r)   r*   r/   |  r   zLoggingLoggerVariable.__init__rW   rX   r3   rY   r   c                 C   sP   |j rd S t| j|d }t|dd }||htjjjr"tj	
d S td d S )Nrm   zLogger not supported for non-export cases. To avoid graph breaks caused by logger in compile-mode, it is recommended to disable logging by adding logging methods to config.ignore_logger_methods)rp  rI   rF   intersectionr`   r   r   Zignore_logger_methodsr   r   rU   r   )r2   r?   rN   rW   r3   methodr  r)   r)   r*   rk     s   z!LoggingLoggerVariable.call_methodr   r   r  r)   r)   r4   r*   rs  w  s    rs  c                       s   e Zd ZdZd ZzddlmZmZ	m
Z W n ey)   eddi Z	eddi ZY nw d fdd	Zd
d Zdee deeef defddZdddedefddZ  ZS )ConstantLikeVariablez8self.value is a compile-time constant, but not a literalr   )dtypefloatinggenericZinvalid_typer)   r,   Nc                    r   r-   r3  r,  r4   r)   r*   r/     r   zConstantLikeVariable.__init__c                 C   r   r6   r/  r   r)   r)   r*   rA     r   z'ConstantLikeVariable.as_python_constantrW   r3   c                 C   s   zdd |D }dd |  D }W n ty,   t| j d| d| d| d Y nw t| j||i |}tj|rDtj	|S t
|tjrNt|S t| j d| d	|  d S )
Nc                 S   rR  r)   rS  r  r)   r)   r*   rT    rU  z4ConstantLikeVariable.call_method.<locals>.<listcomp>c                 S   rV  r)   rS  r>  r)   r)   r*   rA    rW  z4ConstantLikeVariable.call_method.<locals>.<dictcomp>rF  z(*z, **r   z() -> )r   ru   r   _error_prefixrI   rF   r   r   rR   rU   rd   reMatchConstantRegexMatchVariable)r2   r?   rN   rW   r3   ZcargsZckwargsr   r)   r)   r*   rk     s   &z ConstantLikeVariable.call_methodr?   r$   rN   c                 C   st   t | j|}t|| jrt|}t|| jrt|S t|tr)t|| j	r)t
|S tj|r5tj|S t| |S r6   )rI   rF   rd   np_floatingfloatnp_dtypeNumpyDTypeVariablerE   rD   
np_genericrD  r   r   rR   rU   rS   r0  r)   r)   r*   rV     s   
z ConstantLikeVariable.var_getattrr   )r&   r'   r(   r   rz  rZ  rw  r  rx  r~  ry  r  ImportErrorrE   r/   rA   r   r   r!  r   rk   rV   r   r)   r)   r4   r*   rv    s&    

rv  c                   @   r   )RegexPatternVariablez
re.PatternNr&   r'   r(   rz  r)   r)   r)   r*   r    r   r  c                   @   r   )r}  zre.MatchNr  r)   r)   r)   r*   r}    r   r}  c                       s"   e Zd ZdZd fddZ  ZS )TorchVersionVariableztorch.__version__r,   Nc                    s6   | dtj |d tju sJ t jdi | d S )NrF   r)   )
setdefaultr`   __version__r.   r/   r   r4   r)   r*   r/     s   zTorchVersionVariable.__init__r   )r&   r'   r(   rz  r/   r   r)   r)   r4   r*   r    s    r  c                   @   r   )NumpyTypeInfoVariableznp.iinfo/np.finfoNr  r)   r)   r)   r*   r    r   r  c                   @   s   e Zd ZdZdd ZdS )r  znp.dtype[...]c                 C   s
   | j jjS )a0  Similar to how numpy dtype descriptors (e.g. np.float32 ) are handled by NumpyVariable:

        np.dtype() objects are serialized as strings, torch._numpy wrappers will normalize to the torch dtype.
        This also handles unsupported things nicely (i.e. structured arrays and object arrays).
        )rF   rE   r&   r   r)   r)   r*   r	    s   
zNumpyDTypeVariable.as_proxyN)r&   r'   r(   rz  r	  r)   r)   r)   r*   r    s    r  c                       s,   e Zd ZdZd
 fddZddd	Z  ZS )RandomClassVariablezrandom.Randomr,   Nc                    r   r-   r   r   r4   r)   r*   r/     r   zRandomClassVariable.__init__r?   r$   c                 C   sT   t |dkrtd n|rtd t |dkrtjd n|d }t|tj dS )Nr   zrandom.Random() with > 1 argzrandom.Random() with kwargsr   )seedre   )rK   r   r   r   rU   RandomVariablebaseZValueMutationNew)r2   r?   rW   r3   r  r)   r)   r*   rf     s   
 
z!RandomClassVariable.call_functionr   r   )r&   r'   r(   r   r/   rf   r   r)   r)   r4   r*   r    s    r  c                       s   e Zd ZdZdhejZh dZ		ddeej	 dee ddf fdd	Z
d
d Zdd Zedd Zedd Zedd Zedd Zdee deeef def fddZdd Z  ZS )r  zrandom.Random()

    Implemented by wrapping a VariableTracker around a random.Random object.
    The supported methods for the random.Random object cannot be overriden.
    Assumes that random objects behave the same given a set seed or state.
    random>   uniformrandint	randranger  Nrandr  r,   c                    sj   t  jdi | |d ur#| |sJ t | _| j|  d S |d ur+| nd }t|| _d S r-   )r.   r/   is_supported_random_objr  RandomsetstategetstaterA   )r2   r  r  r3   r4   r)   r*   r/     s   
zRandomVariable.__init__c                 C   r-  r6   )r  r  r   r)   r)   r*   rB   +  r   zRandomVariable.python_typec                 C   r   r6   )r  r   r)   r)   r*   rA   .  r   z!RandomVariable.as_python_constantc                 C   s   t | tjur	dS ttjdD ]2}t| |s dS t| |}t	
|r3|ttj|| kr2 dS qt|dd ttj|urB dS qdS )NF)r  r  r  rm   T)rE   r  r  rd  re  r  _supported_fn_namesrg   rI   r   	isbuiltinr   )r   rN   methr)   r)   r*   r  1  s    


z&RandomVariable.is_supported_random_objc                 C   sz   t | tu sJ t | d tu sJ t | d tu sJ tdd | d D s)J | d d u s9t | d tu s;J d S d S )Nr   r   c                 s   s    | ]	}t |tu V  qd S r6   )rE   intr  r)   r)   r*   r  I  s    z-RandomVariable.check_state.<locals>.<genexpr>r   )rE   r   r  rc  r  stater)   r)   r*   check_stateD  s
   (zRandomVariable.check_statec                 C   sF   t |  ttj| d tdd | d D tj| d gS )Nr   c                 S   s   g | ]}t j|qS r)   rk  r  r)   r)   r*   rT  S  s    z-RandomVariable.wrap_state.<locals>.<listcomp>r   r   )r  r  r   r  r   rU   r  r)   r)   r*   
wrap_stateL  s   
zRandomVariable.wrap_statec                 C   s   |   }t| |S r6   )rA   r  r  )r  Z	state_objr)   r)   r*   unwrap_stateY  s   
zRandomVariable.unwrap_staterW   r3   c                    s   dkr&|j j|  | jjdd |D i dd | D  tjd S  dkr2| 	| j
 S  dkrN|j j|  | j| |d  tjd S  | jv r|j j|  | j
  fd	d
}t| j dd |D i dd | D  t||||S t | ||S )Nr  c                 S   rR  r)   rS  r  r)   r)   r*   rT  i  rU  z.RandomVariable.call_method.<locals>.<listcomp>c                 S   rV  r)   rS  )r  r   r   r)   r)   r*   rA  j  rW  z.RandomVariable.call_method.<locals>.<dictcomp>r  r  r   c                     s&   t  }| t| | i |S r6   )r  r  r  rI   )rW   r3   rrN   r  r)   r*   call_random_methw  s   
z4RandomVariable.call_method.<locals>.call_random_methc                 S   rR  r)   rS  r  r)   r)   r*   rT    rU  c                 S   rV  r)   rS  r>  r)   r)   r*   rA    rW  )rv   rc   Zmutationr  r  r   r   r   rU   r  r  r  r  r  rI   r!   r.   rk   )r2   r?   rN   rW   r3   r  r4   r  r*   rk   _  s2   


zRandomVariable.call_methodc                    s\      fdd  dd     d  | | j   dd    d S )Nc                      s      t dgS )Nr  )r;   Zcreate_load_python_moduler  rj  r)   r=   r)   r*   r9     s
    z,RandomVariable.reconstruct.<locals>.<lambda>r   Fr  r   T)r:   rf   r   r{   r  r  r  Zpop_topr<   r)   r=   r*   r>     s   

zRandomVariable.reconstructr  )r&   r'   r(   r   r   r   r  r   r  r  r/   rB   rA   rl   r  r  r  r  r   r!  r   rk   r>   r   r)   r)   r4   r*   r    sD    	




'r  c                       sJ   e Zd Zedd Z fddZ							
		dddZdd Z  ZS )WeakRefVariablec                 K   sD   | dd }| }|ot|}t| ||}||d< t|fi |S )NrC   )rM   r   r   r}   r  )r?   Zweakref_valueoptionsrC   Zreferentreferent_vtr)   r)   r*   r}     s   zWeakRefVariable.buildc                    r   r-   )r.   r/   r  )r2   r  r  r4   r)   r*   r/     r   zWeakRefVariable.__init__r?   r$   rW   rX   r3   rY   r,   r   c                 C   r   r6   )r  r   r)   r)   r*   rf     s   zWeakRefVariable.call_functionc                    s0      fdd  | j  tdd d S )Nc                      s     ddS )Nweakrefref)r   r)   r=   r)   r*   r9     s    z-WeakRefVariable.reconstruct.<locals>.<lambda>r   F)r:   r  r;   r   r<   r)   r=   r*   r>     s   
zWeakRefVariable.reconstructr   )	r&   r'   r(   rl   r}   r/   rf   r>   r   r)   r)   r4   r*   r    s    

r  )kr   r   r  r   rd  r  r{  r_  rn   r   typingr   r   Ztorch._Cr`   Ztorch._numpyrG  r[  Ztorch.utils._pytreer;  Z_pytreerr  r   r   r   Zbytecode_transformationr   r   Zcreate_parameter_opr	   excr
   r   Zguardsr   r   Zmutation_guardr   rC   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r  r   r   r   r    Zuser_definedr!   r"   r#   Ztorch._dynamo.symbolic_convertr$   r%   r+   r   r   r   r   r   r   r   r   	dataclassr   r   r  r_   rS   r"  r'  r)  r2  	lru_cacher=  rC  rD  r\  rx   ra  rm  rs  rv  r  r}  r  r  r  ZfinfoZiinforw  rN  r  r  r  r)   r)   r)   r*   <module>   s   , Os= 4o) ,&
@


	n17:	 