
    9iz                        d 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 ddlmZmZmZ ddlmZmZ ddlmZmZ dd	lmZmZ dd
lmZmZ ddlmZmZmZm Z m!Z!m"Z"m#Z# ddl$m%Z%m&Z& ddl'm(Z( ddl)m*Z* e
rddl+m,Z, ddl-m.Z. ddl/m0Z0 dede1fdZ2	 d2de&de	d         ddfdZ3de&de1fdZ4 G d de&          Z5 G d de&          Z6 G d  d!e5          Z7 G d" d#e5          Z8 G d$ d%e5          Z9 G d& d'e9          Z: G d( d)e9          Z; G d* d+e&          Z< G d, d-e<          Z= G d. d/e<          Z> G d0 d1e<          Z?dS )3a  
Dictionary-related variable tracking classes for PyTorch Dynamo.

This module implements variable tracking for different types of dictionary-like objects:
- Regular Python dictionaries (dict)
- Ordered dictionaries (collections.OrderedDict)
- Default dictionaries (collections.defaultdict)
- Dictionary views (keys and values)
- Sets and frozensets (implemented internally using dictionaries)

These classes are responsible for tracking dictionary operations during graph compilation,
maintaining proper guards for dictionary mutations and key existence checks. They handle
dictionary creation, modification, key/value access, and view operations while ensuring
correct behavior in the compiled code through appropriate guard installation.

The implementation uses a special _HashableTracker wrapper to handle dictionary keys
while preserving proper aliasing semantics. Sets are implemented as dictionaries with
None values for efficiency and code reuse.
    N)Sequence)AnyOptionalTYPE_CHECKINGUnion   )graph_break_hints	polyfills	variables)create_call_functioncreate_instruction)raise_observed_exceptionunimplemented)GuardBuilderinstall_guard)is_constant_sourceis_from_local_source)cmp_name_to_op_mapping
dict_items	dict_keysdict_valuesistyperaise_args_mismatchspecialize_symnode   )ValueMutationNewVariableTracker)ConstantVariable)ListIteratorVariable)	PyCodegenInstructionTranslator)UserFunctionVariableobjreturnc                 R    t          |           j                            dd          S )N__instancecheck__F)type__dict__get)r$   s    P/var/www/icac/venv/lib/python3.11/site-packages/torch/_dynamo/variables/dicts.pywas_instancecheck_overrider,   ;   s"    99!!"5u===    argtxr"   c                 2   |ddl m}  |j                    }	 |                                 }n# t          $ r t          |           }Y nw xY wt          t          |t          d|dt          | 	                                                     g           d S )Nr   r!   zunhashable type: z and variable tracker = args)
torch._dynamo.symbolic_convertr"   
current_txpython_type	Exceptionr(   r   	TypeErrorr   realize)r.   r/   r"   arg_types       r+   raise_unhashabler:   ?   s     
zHHHHHH-"-//??$$   99 
]H]]S[[]]H[H[]] 
     s   . A
	A
xc                     t          | t          j                  r*|                                 s|                                 rdS |                                 S )NT)
isinstancer   LazyVariableTrackeris_realizedis_hashableis_python_hashable)r;   s    r+   r@   r@   V   sT     	1i344 MMOO
 t!!!r-   c                       e Zd Zej        Zdhej        Z G d d          Ze	fde	eef         de
deddf fdZde
de
fd	Zde	eef         fd
ZdefdZde	eef         fdZde	eef         fdZde
fdZdedefdZdddddedee         de	eef         defdZdefdZdefdZdee         dedefdZd0d Zd0d!Zddd"edefd#Zddd"edefd$Z d"edee         fd%Z!d"eddfd&Z"d1d'Z#ddd(e$e         ddfd)Z%ddd*ed(e$e         de	eef         def
 fd+Z&ddde$e         fd,Z'ddd*ede(fd-Z)dedef fd.Z*d/ Z+ xZ,S )2ConstDictVariableuser_clsc                   :    e Zd ZdZdeddfdZdefdZdefdZ	dS )"ConstDictVariable._HashableTrackeraB  
        Auxiliary opaque internal class that wraps a VariableTracker and makes it hashable
        This should not be seen or touched by anything outside of ConstDictVariable and its children
        Note that it's also fine to put VTs into dictionaries and sets, but doing so does not take into account aliasing
        vtr%   Nc                 n    t          |          }t          |          st          |           || _        d S N)r   r@   r:   rG   )selfrG   s     r+   __init__z+ConstDictVariable._HashableTracker.__init__s   s8    #B''B r?? % $$$DGGGr-   c                 "   t          | j        t          j                  rX| j                                        s?| j                                        r&t          | j                                                  S | j                                        S )a  
            Computes the hash value for the wrapped VariableTracker.

            For unrealized LazyVariableTrackers, uses the hash of the original value
            to avoid realizing the tracker and inserting unnecessary guards.
            For all other cases, delegates to the VariableTracker's get_python_hash method.

            Returns:
                The hash value of the underlying variable tracker
            )	r=   rG   r   r>   r?   r@   hashoriginal_valueget_python_hashrJ   s    r+   __hash__z+ConstDictVariable._HashableTracker.__hash__|   s{     47I$ABB6++--6 G''))6
 DG22445557**,,,r-   c                 `    | j         |j         u rdS | j                             |j                   S )a  
            Checks equality between two _HashableTracker instances.

            Delegates to the VariableTracker's is_python_equal method to compare
            the underlying variable trackers for Python-level equality.

            Args:
                other: Another _HashableTracker instance to compare with

            Returns:
                True if the underlying variable trackers are Python-equal, False otherwise
            T)rG   is_python_equalrJ   others     r+   __eq__z)ConstDictVariable._HashableTracker.__eq__   s0     w%(""t7**58444r-   )
__name__
__module____qualname____doc__r   rK   intrQ   boolrV    r-   r+   _HashableTrackerrF   l   sv        	 		 	4 	 	 	 		-c 	- 	- 	- 	-&	54 	5 	5 	5 	5 	5 	5r-   r^   itemskwargsr%   Nc                 \   d|v r|                     d           d|v r|                     d            t                      j        d
i | t          j        t          fd|                                D                       sJ dt          t          df         ddffd| 	                    |          } |fd|                                D                       | _        | j
        rt          | j
                   nd	| _        |                                | _        || _        d S )Noriginal_itemsshould_reconstruct_allc              3   v   K   | ]3\  }}t          |t          f          ot          |t                    V  4d S rI   )r=   r   ).0r;   vHashables      r+   	<genexpr>z-ConstDictVariable.__init__.<locals>.<genexpr>   s^       
 
 1 q?H566 /1o..
 
 
 
 
 
r-   keyrF   r%   c                 >    t          |           r| n
 |           S rI   )r=   )ri   rg   s    r+   make_hashablez1ConstDictVariable.__init__.<locals>.make_hashable   s&     %S(33F33#Fr-   c                 .    i | ]\  }} |          |S r]   r]   )re   r;   rf   rk   s      r+   
<dictcomp>z.ConstDictVariable.__init__.<locals>.<dictcomp>   s)    MMMtq!}}Q//MMMr-   Tr]   )popsuperrK   rC   r^   allr_   r   r   _get_dict_cls_from_user_clssourcer   rc   copyrb   rD   )rJ   r_   rD   r`   dict_clsrg   rk   	__class__s        @@r+   rK   zConstDictVariable.__init__   s~    v%%JJ'(((#v--JJ/000""6"""$5  
 
 
 
 
 
 
 
 
 	
 	
 	
	G(LLM	G1	G 	G 	G 	G 	G 	G
 33H==XMMMMu{{}}MMMNN
 6:[J$T[1111d 	# $jjll r-   c                     t           t          j        t          j        f|v r|}n t	          fd|j        D                       }|v s
J |            |t          j        u rt           }|S )Nc              3   $   K   | ]
}|v |V  d S rI   r]   )re   baseaccepted_dict_typess     r+   rh   z@ConstDictVariable._get_dict_cls_from_user_cls.<locals>.<genexpr>   s7        T=P5P5P5P5P5P5P r-   )dictcollectionsOrderedDictdefaultdictnext__mro__)rJ   rD   rt   ry   s      @r+   rq   z-ConstDictVariable._get_dict_cls_from_user_cls   s    #[%<k>UV ***HH     !)!1    H ....... {...Hr-   c                 H    d | j                                          D             S )Nc                 l    i | ]1\  }}|j                                         |                                2S r]   rG   as_proxyre   krf   s      r+   rm   z.ConstDictVariable.as_proxy.<locals>.<dictcomp>   s0    MMM$!QMMMr-   r_   rP   s    r+   r   zConstDictVariable.as_proxy   s$    MM$*:J:J:L:LMMMMr-   c                 z    dd                     d | j                                        D                       z   dz   S )N{, c              3   |   K   | ]7\  }}|j                                          d |                                 V  8dS )z: NrG   
debug_reprr   s      r+   rh   z/ConstDictVariable.debug_repr.<locals>.<genexpr>   sY        =AQ14??$$8888     r-   })joinr_   rP   s    r+   r   zConstDictVariable.debug_repr   sT    ii  EIZEUEUEWEW     		
r-   c                 H    d | j                                          D             S )Nc                 l    i | ]1\  }}|j                                         |                                2S r]   rG   as_python_constantr   s      r+   rm   z8ConstDictVariable.as_python_constant.<locals>.<dictcomp>   sH     
 
 
1 D##%%q';';'='=
 
 
r-   r   rP   s    r+   r   z$ConstDictVariable.as_python_constant   s1    
 

((**
 
 
 	
r-   c                 p    |                                   d | j                                        D             S )Nc                 H    i | ]\  }}|j                                         | S r]   r   r   s      r+   rm   z=ConstDictVariable.keys_as_python_constant.<locals>.<dictcomp>   s,    LLLA''))1LLLr-   install_dict_keys_match_guardr_   rP   s    r+   keys_as_python_constantz)ConstDictVariable.keys_as_python_constant   s6    **,,,LL9I9I9K9KLLLLr-   c                     | j         S rI   rD   rP   s    r+   r5   zConstDictVariable.python_type   s
    }r-   rG   c                     t          |t                    sJ t          j        }|                                o@ ||          | j        v o.t          | j         ||                   t          j                   S rI   )r=   r   rC   r^   rA   r_   r   DeletedVariable)rJ   rG   rg   s      r+   __contains__zConstDictVariable.__contains__   st    "o.....$5!!## T
*Ttz((2,,79RSSS	
r-   r/   r"   tree_map_fnr#   map_fnresttree_map_kwargsc           
         g }|D ]}|                                 }t          |t                    r*t          |j                  t          | j                  k    r|                     |||||          c S |                    |            t          | j                              | j                                        D ]v\  }}	g }
|D ]P}	 |
                    |j        |                    $# t          $ r  |                     |||||          cY c c S w xY w|		                    ||||
|          |<   wfdD             }| 
                    |dd t                                S )Nc                 ,    i | ]}|j         |         S r]   rG   )re   key_trackernew_items_hasheds     r+   rm   z:ConstDictVariable.call_tree_map_branch.<locals>.<dictcomp>!  s3     "
 "
 "
 N,[9"
 "
 "
r-   T)r_   rb   rc   rr   mutation_type)r8   r=   rC   lenr_   _tree_map_fallbackappendr(   KeyErrorcall_tree_mapcloner   )rJ   r/   r   r   r   r   other_dicts	candidater   valuesibling_leavesupdated_original_itemsr   s               @r+   call_tree_map_branchz&ConstDictVariable.call_tree_map_branch   s    02 	* 	*I!))++Ii):;; s@ @TZ@! @! ..VT?     y))))+4
++--"&*"2"2"4"4 	 	K46N(  	")))/+*FGGGG   22K         -2,?,?- -[))"
 "
 "
 "
/"
 "
 "

 zz"1#'*,,  
 
 	
s    C..#DDc                 b    t          d | j                                        D                       S )Nc              3   L   K   | ]}t          |t          j                   V   d S rI   )r=   r   r   re   r;   s     r+   rh   z(ConstDictVariable.len.<locals>.<genexpr>/  sC       
 
=>
1i7888
 
 
 
 
 
r-   )sumr_   valuesrP   s    r+   r   zConstDictVariable.len.  s>     
 
BF*BSBSBUBU
 
 
 
 
 	
r-   c                 v      j         p1t           fd j                                        D                       S )Nc              3      K   | ]:\  }}                     j                            |j                  |          V  ;d S rI   )is_new_itemrb   r*   rG   )re   ri   r   rJ   s      r+   rh   z2ConstDictVariable.has_new_items.<locals>.<genexpr>4  s^       2
 2
U T044SV<<eDD2
 2
 2
 2
 2
 2
r-   )rc   anyr_   rP   s   `r+   has_new_itemszConstDictVariable.has_new_items3  sS    * 
c 2
 2
 2
 2
"j..002
 2
 2
 /
 /
 	
r-   r   rU   c                    |rl|                                 rX|                                 rDt          |                                          t          |                                          k    S t          |          t          |          k    S rI   )r?   idr8   )rJ   r   rU   s      r+   r   zConstDictVariable.is_new_item9  st      	>U&&(( 	>U->->-@-@ 	>emmoo&&"U]]__*=*===%yyBuII%%r-   codegenr    c                 H   d}| j                                          D ]a\  }}| j                            |j                  }|                     ||          s| j        r  ||j                    ||           |dz  }b|                    t          d|                     d S )Nr   r   	BUILD_MAPr.   )r_   rb   r*   rG   r   rc   append_outputr   )rJ   r   num_argsri   r   items         r+   reconstruct_kvs_into_new_dictz/ConstDictVariable.reconstruct_kvs_into_new_dictA  s    ***,, 	 	JC&**3622De,, 0K A0(KKKLLLLLr-   c                     | j         t          j        u rR                    fd           |                                                    t          dd                     d S |                                d S )Nc                                                                 t                                         d          g          S )Nr|   extend_outputcreate_load_python_moduler{   create_load_attrr   s   r+   <lambda>z/ConstDictVariable.reconstruct.<locals>.<lambda>Q  s>    --99+FF00??  r-   r   F)rD   r{   r|   add_push_nullr   r   r   rJ   r   s    `r+   reconstructzConstDictVariable.reconstructM  s    =K333!!      ..w777!!"6q%"@"@AAAAA..w77777r-   r.   c                 L   t                               |          }|| j        vru	 dt          |           d|                                }n4# t
          $ r' t          j        dt          |                     }Y nw xY wt          t          ||g           | j        |         S )NzDict key lookup failed for z%. Debug representation of the key is r1   )
rC   r^   r_   strr   r6   r   creater   r   )rJ   r/   r.   ri   error_messages        r+   'getitem_const_raise_exception_if_absentz9ConstDictVariable.getitem_const_raise_exception_if_absent]  s      0055dj  O#c(( O O:=..:J:JO O      0 7<#c((<<! ! %XrHHHHz#s   'A .A>=A>c                     t                               |          }|| j        vr3d|j         d}t	          dd|j         |dgt
          j                   | j        |         S )NzDictionary key z not found during tracingzkey not found in dictzKey z>Check if the key exists in the dictionary before accessing it.gb_typecontextexplanationhints)rC   r^   r_   r   r   r	   
USER_ERROR)rJ   r/   r.   ri   msgs        r+   getitem_constzConstDictVariable.getitem_constn  s      0055dj  HCIHHHC/*sy**T&1	    z#r-   c                 f    t                               |          }|| j        vrd S | j        |         S rI   )rC   r^   r_   )rJ   r.   ri   s      r+   maybe_getitem_constz%ConstDictVariable.maybe_getitem_const  s3    0055dj  4z#r-   c                 p   || v sJ t                               |          }t          | j                                                                      |          }t          | j                                                  |         }t          |t          j	                  r|
                                 d S d S rI   )rC   r^   tupler_   keysindexrb   r=   r   r>   r8   )rJ   r.   ri   r   original_key_vts        r+   realize_key_vtz ConstDictVariable.realize_key_vt  s    d{{{{0055djoo''((..s33 3 8 8 : :;;EBoy'DEE 	&##%%%%%	& 	&r-   c                 p    | j         r.t          |                     t          j                             d S d S rI   )rr   r   
make_guardr   DICT_KEYS_MATCHrP   s    r+   r   z/ConstDictVariable.install_dict_keys_match_guard  s<    ; 	I$//,*FGGHHHHH	I 	Ir-   r2   c           	         | j         sd S |j        j                            |           rd S |d         | v }|d         j         ~|d                                         rdt          |                     t          j        t          |           j
        |d                                         |                                d S |d         j         r5|r|                     |d                    d S |                                  d S d S )Nr   )ri   invert)rr   outputside_effectsis_modifiedis_python_constantr   r   	functoolspartialr(   CONTAINS_GUARDr   r   r   )rJ   r/   r2   containss       r+   install_dict_contains_guardz-ConstDictVariable.install_dict_contains_guard  s   " { 	F9!--d33 	F7d?7>!d1g&@&@&B&B!%T

1 G6688#+|        !W^ 	5 5##DG,,,,,2244444		5 	5r-   namec           
      "   ddl m}m t          j        |dk    rv t          j        t                    j        |g|R i |}|j        j	        
                    |            | j                            |j                    j        d           S |dk    rQt          |          dk    r"t          ||dt          |           d           |                     ||d                   S |dk    r|s|r2t          ||d	t          |           d
t          |           d           |                                  | j        r$|j        j                            | j                   t+          |           S |dk    rt          |          r"t          ||dt          |           d           |                                  | j        r$|j        j                            | j                   t-          |           S |dk    r|s|r2t          ||d	t          |           d
t          |           d           |                                  | j        r$|j        j                            | j                   |s|rt/          t0          |           t3          |           S |dk    r|                                  |s|r2t          ||d	t          |           d
t          |           d           |                     | j                                        t9                      d           S |dk    rl|s|r2t          ||d	t          |           d
t          |           d           |                                   j        t          | j                            S |dk    r|                                 r|ot=          |d                   }|st?          |d         |           |                                  |st          |          dk    r2t          ||dt          |           d
t          |           d           |j        j	        
                    |            |d         | j         |d                   <    j        d           S |dk    r|                                 r|ot=          |d                   }|rs|                                  d| _         |j        j	        
                    |            | j        !                     |d                               j        d           S tE                      #                    ||||          S |dk    rt          |          dvr"t          ||dt          |           d           |ot=          |d                   }|st?          |d         |           |d         | vrA| $                    ||           t          |          dk    r j        d           S |d         S | %                    ||d                   S |dk    r|                                 rt          |          dvr"t          ||dt          |           d           |ot=          |d                   }|st?          |d         |           |d         | vrF| $                    ||           t          |          dk    rt/          tL          |           |d         S d| _         |j        j	        
                    |            | j        '                     |d                             S |dk    r|                                 rtQ          | j)        t                    r>tQ          | j)        tT          j+                  st          |          rt          ||           | j        s( j        d          }t/          tL          ||g           | j)        tT          j+        u rt          |          dk    sd|v rt          |          dk    r5|d         ,                                r|d         -                                }	nP|.                    d          x}
r)|
,                                r|
-                                }	nt          ||           | j        /                    |	          \  }}
n| j        /                                \  }}
d| _         |j        j	        
                    |            t          j0        |j1        |
g          S |d k    r|s|r2t          ||d	t          |           d
t          |           d           d| _         |j        j	        
                    |            | j        2                                  j        d           S |d!k    rd|                                 rO|                                  t          |          dk    }t          |          dk    }|s|r|j        j	        
                    |            |rtg          |d         t                    r#|d                                          |d         }n"|4                    |t          |d                   }| j                            |j                   |r;fd"|                                D             }| j                            |            j        d           S tE                      #                    ||||          S |d#k    rt          |          s2t          ||d$t          |           d
t          |           d           |ot=          |d                   }|st?          |d         |           | $                    ||           |d         | v } j        |          S |d%k    rg|                                 rRt          |          dvr2t          ||d&t          |           d
t          |           d           |ot=          |d                   }|st?          |d         |           |                                  |st          |          dk    r2t          ||d't          |           d
t          |           d           | 5                    |d                   }||S t          |          dk    r j        d           }n|d         }|j        j	        
                    |            || j         |d                   <   |S |d(k    r|                                  |j        j	        
                    |            |d         | vrt/          tL          |           d}	t          |          dk    r4|d         ,                                r|d         -                                }	|rEd|v rA|d         ,                                r'|.                    d          -                                }	 |d                   }| j        6                    ||	            j        d           S |d)k    rto          | t                    rpt          |          dk    r"t          ||dt          |           d           t          j8        tr          j:                  ;                    || |d         gi           S |d*k    r, j        | #                    |d)||          j<                   S |d+k    rxt          |          dk    r"t          ||dt          |           d           |d         }to          |t          t
          j=        f          sOd,| >                                j?         d-|>                                j?         d.}t/          t0          ||g           | j)        |j)        h}t          d/ |D                       rtT          j+        nt          }|                                  |                     | j                                        t9                      d |0          }|d                                          |j                            |d         j                   |S |d1k    r| #                    |d!||           | S |d2k    ro| j        r8t          | j                  s$|j        j                            | j                   t          | C                    |          t9                      3          S tE                      #                    ||||          S )4Nr   )BuiltinVariabler   rK   __getitem__1 args argsr   r_   0 args and 0 kwargs
 args and  kwargsr   z0 argsr   rs   )r_   r   rr   __len____setitem__r   z2 args and 0 kwargs__delitem__Tr*   )r   r   z1 or 2 argsrn   popitemzpopitem(): dictionary is emptyr1   last)r  clearupdatec                 J    i | ]\  }}  j         |                    | S r]   )r   )re   r   rf   r   rg   s      r+   rm   z1ConstDictVariable.call_method.<locals>.<dictcomp>  sH     ' ' ' Aq !!8!1!8!;!;<<a' ' 'r-   r   zmore than 1 args and 0 kwargs
setdefaultz1 or 2 args and 0 kwargszat most 2 args and 0 kwargsmove_to_endrV   __ne____or__z$unsupported operand type(s) for |: 'z'and ''c              3   J   K   | ]}t          |t          j                  V  d S rI   )
issubclassr{   r|   )re   ts     r+   rh   z0ConstDictVariable.call_method.<locals>.<genexpr>   s/      JJ!z![%<==JJJJJJr-   )r_   r   rr   rD   __ior____iter__r   )D r   r   rC   r^   r   rz   	call_dictr   r   mutationr_   r  r   r   r   r   r   rr   guard_on_key_orderaddDictItemsVariableDictKeysVariabler   r7   DictValuesVariabler   rs   r   
is_mutabler@   r:   rc   r  ro   call_methodr   r   r   rn   r  rD   r{   r|   r   r   r*   r  TupleVariablerG   r  r=   call_custom_dictr   r  r   r#   r
   dict___eq__call_functionr   UserDefinedDictVariabler5   rW   r   r   r   unpack_var_sequence)rJ   r/   r   r2   r`   r   temp_dict_vtarg_hashabler   r  rf   r   has_arg
has_kwargsdict_vtkwargs_hashabler   r   r;   ri   rU   err_msgtsrD   new_dict_vtr   rg   ru   s                            @@r+   r  zConstDictVariable.call_method  s    	87777777$5:D94T::D  # L I"++D111Jl0111*#*4000]""4yyA~~#Bh3t998K8K8KLLL??DGLLLW__ v #)4yy@@CKK@@@	   ..000{ >	,00===$T***V^^4yy M#Bh3t998K8K8KLLL..000{ >	,00===#D)))X v #)4yy@@CKK@@@	   ..000{ >	,00=== 8v 8(B777%d+++V^^..000 v #)4yy@@CKK@@@	   ::joo''7G7I7IRV     Y v #)4yy@@CKK@@@	   ..000*#*3tz??;;;]""t'8'8"8KQ$8$8L . a"---..000 Ta#)4yy@@CKK@@@	   I"++D111,0GDJxxQ(()*#*4000]""t'8'8"8KQ$8$8L C22444.2+	&//555
&&xxQ'8'8999.'.t444ww**2tT6BBBU]]4yy&&#BmD		=P=P=PQQQ8KQ$8$8L . a"---Awd""00T:::t99>>2+24888Aw%%b$q'222U]]t00]4yy&&#BmD		=P=P=PQQQ8KQ$8$8L . a"---Awd""00T:::t99>>,Xr:::Aw*.D'I"++D111:>>((47"3"3444Y4??#4#44=$//."4=+2IJJ. II.
 $B---: C-&-.NOO(2SEBBBB} 777D		Q&F"2"2t99>>d1g&@&@&B&B>75577DD!::f---a 213G3G3I3I 2//11DD'D111z))t)4411z))++1*.D'I"++D111*AD!9555W__ v #)4yy@@CKK@@@	   +/D'I"++D111J*#*4000X$//"3"3 ..000$ii1nGVqJ C* C	&//555 5!$q'+<== V Q==???59!W"1"B"B2tTRSW"U"UJ%%gm444 7' ' ' ' '$*LLNN' ' 'O J%%o666.'.t444ww**2tT6BBB^##t99 #34yy@@CKK@@@	    8KQ$8$8L . a"---,,R666Aw$H*#*8444\!!doo&7&7!4yy&&#.4yy@@CKK@@@	    8KQ$8$8L . a"---..000 TQ#14yy@@CKK@@@	   ,,T!W55E t99>>/(/55AAQA	&//55501
88DG,,-]""..000I"++D111Awd""(2666D4yyA~~$q'"<"<">">~Aw1133 ?&F**vf~/P/P/R/R*zz&))<<>>(47##CJ""3T"222*#*4000X&##
 #
 4yyA~~#Bh3t998K8K8KLLL1)2GHHVVT47OR   X*#*$$R4@@FF   X4yyA~~#Bh3t998K8K8KLLLGE& )9+LM  H<4;K;K;M;M;V < <!--//8< < <  )BgYGGGG -0B JJrJJJJJ''  ..000**joo''.00!	 %  K G11333$$T!W]333YR4888KZ{ >#5dk#B#B >	,00==='((,,<L<N<N    77&&r4v>>>r-   c                 L    |                                   d | j        D             S )Nc                     g | ]	}|j         
S r]   r   r   s     r+   
<listcomp>z9ConstDictVariable.unpack_var_sequence.<locals>.<listcomp>  s    ))))))r-   r   rJ   r/   s     r+   r!  z%ConstDictVariable.unpack_var_sequence  s*    **,,,))dj))))r-   c                 r    t           fdt          t          j        t          j        fD                       rKt           j        |          rt          j        d          S  j        t          u rt          j        d          S d j         d}t          dd j         |dgt          j        	           d S )
Nc              3   *   K   | ]}j         |u V  d S rI   r   )re   r  rJ   s     r+   rh   z5ConstDictVariable.call_obj_hasattr.<locals>.<genexpr>&  s>       
 
 MQ
 
 
 
 
 
r-   TFzhasattr on z is not supportedzunsupported hasattr operationzClass z+Consider using a regular dictionary insteadr   )r   rz   r{   r|   r}   hasattrrD   r   r   r   r	   SUPPORTABLE)rJ   r/   r   r   s   `   r+   call_obj_hasattrz"ConstDictVariable.call_obj_hasattr!  s    
  
 
 
 
K3[5LM
 
 
 
 
 	6 t}d++ 5'.t444}$$'.u555<DM<<<3,T],,=".		
 	
 	
 	
 	
 	
r-   c                 ^    |                                    t                      j        di |S Nr]   )r   ro   r   )rJ   r`   ru   s     r+   r   zConstDictVariable.clone:  s1    **,,,uww}&&v&&&r-   c                     dS )zP
        Dictionaries are mutable and therefore not hashable in Python.
        Fr]   rP   s    r+   rA   z$ConstDictVariable.is_python_hashable>  	     ur-   r   r    r%   Nr%   N)-rW   rX   rY   r   DICT_CONTAINSr   r   _nonvar_fieldsr^   rz   r(   r   rK   rq   r   r   r   r   r   r5   r\   r   r   r   r[   r   r   r   r   r   r   r   r   r   r   r   listr   r  r!  r   r3  r   rA   __classcell__ru   s   @r+   rC   rC   d   s       !/N 			'N
25 25 25 25 25 25 25 25n %! %!O_45%! %! 	%!
 
%! %! %! %! %! %!ND T    &N$sCx. N N N N
C 
 
 
 

DcN 
 
 
 
Mc?.B)C M M M MT    
 
4 
 
 
 
0
#0
 ,0
  	0

 '0
 c?230
 
0
 0
 0
 0
d
S 
 
 
 


t 
 
 
 
&o.&7F&	& & & &
M 
M 
M 
M8 8 8 8 )0?	   ")0?	   " 8O;T    &/ &d & & & &I I I I&5)&515o1F&5	&5 &5 &5 &5Pa?#a? a? ?#	a?
 S/)*a? 
a? a? a? a? a? a?F*&= *$BW * * * *
)
14
	
 
 
 
2'c 'o ' ' ' ' ' '      r-   rC   c            
            e Zd Zdededdf fdZdefdZdddee	         fd	Z
ddZdddedee	         deee	f         de	f
dZdddedef fdZ xZS )MappingProxyVariabledv_dictr`   r%   Nc                 v     t                      j        di | t          |t                    sJ || _        d S r5  )ro   rK   r=   rC   rA  rJ   rA  r`   ru   s      r+   rK   zMappingProxyVariable.__init__G  sB    ""6"""'#455555r-   c                     t           j        S rI   )typesMappingProxyTyperP   s    r+   r5   z MappingProxyVariable.python_typeL  s    %%r-   r/   r"   c                 6    | j                             |          S rI   )rA  r!  r.  s     r+   r!  z(MappingProxyVariable.unpack_var_sequenceO  s    |//333r-   r   r    c                    | j         r3d| j          d}t          dd| j          |dgt          j                                       fd            | j                                       t          dd	                     d S )
Nz*Preexisting MappingProxyVariable (source: zS) cannot be reconstructed because the connection to the original dict will be lost.z%mapping proxy cannot be reconstructedSource: zCUse a mapping proxy constructed in the same `torch.compile` region.r   c                                                                 t                                         d          g          S )NrF  )r   r   rE  r   r   s   r+   r   z2MappingProxyVariable.reconstruct.<locals>.<lambda>c  s?    G))55e<<,,-?@@  r-   r   F)rr   r   r	   r2  r   rA  r   r   )rJ   r   r   s    ` r+   r   z MappingProxyVariable.reconstructR  s    ; 	LT[ L L L  ?04;00Y&2	    	   	
 	
 	
 	21e<<=====r-   r   r2   c                     | j         r>|j        j                                        r d}t	          dd| j          d|ddg           | j                            ||||          S )Na  A dict has been modified while we have an existing mappingproxy object. A mapping proxy object, as the name suggest, proxies a mapping object (usually a dict). If the original dict object mutates, it is reflected in the proxy object as well. For an existing proxy object, we do not know the original dict it points to. Therefore, for correctness we graph break when there is dict mutation and we are trying to access a proxy object.z-mapping proxy affected by dictionary mutationrI  z, Dict mutation detectedzNAvoid modifying dictionaries that might be referenced by mapping proxy objectszROr avoid using the mapping proxy objects after modifying its underlying dictionaryr   )rr   r   r   has_existing_dict_mutationr   rA  r  )rJ   r/   r   r2   r`   r   s         r+   r  z MappingProxyVariable.call_methodm  s     ; 	291LLNN 	7  GH4;HHHdh	    |''D$???r-   c                     |                                  t          j        u r%t          j        |t          j        j        v           S t                                          ||          S rI   )r5   rE  rF  r   r   r)   ro   r3  )rJ   r/   r   ru   s      r+   r3  z%MappingProxyVariable.call_obj_hasattr  sU     !777#*453I3R+RSSSww''D111r-   r8  )rW   rX   rY   rC   r   rK   r(   r5   r<  r   r!  r   r   rz   r  r   r3  r=  r>  s   @r+   r@  r@  E  s<        1 S T      
&T & & & &4&= 4$BW 4 4 4 4> > > >6@#@ @ ?#	@
 S/)*@ 
@ @ @ @:2)2142	2 2 2 2 2 2 2 2 2 2r-   r@  c                   6    e Zd ZddZdddee         ddfdZdS )	NNModuleHooksDictVariabler%   Nc                     d S rI   r]   rP   s    r+   r   z7NNModuleHooksDictVariable.install_dict_keys_match_guard  s    r-   r/   r"   r2   c                     d S rI   r]   rJ   r/   r2   s      r+   r   z5NNModuleHooksDictVariable.install_dict_contains_guard  s	     	r-   r9  )rW   rX   rY   r   r<  r   r   r]   r-   r+   rO  rO    sY           )15o1F	     r-   rO  c                        e Zd Z	 ddeeef         dedee         deddf
 fdZde	f fdZ
def fd	Zed
ede	fd            Zdddedee         deeef         def
 fdZddZ xZS )DefaultDictVariableNr_   rD   default_factoryr`   r%   c                      t                      j        ||fi | |t          j        u sJ |t	          j        d           }|| _        d S rI   )ro   rK   r{   r}   r   r   rU  )rJ   r_   rD   rU  r`   ru   s        r+   rK   zDefaultDictVariable.__init__  s^     	33F333;22222".5d;;O.r-   c                     | j         t          t          t          fvr	| j        sdS t                                                      S )NF)rU  r<  r   rz   r_   ro   r   rJ   ru   s    r+   r   z&DefaultDictVariable.is_python_constant  s<     eT':::4::5ww))+++r-   c                     | j         J d| j                                          dt                                                       dS )Nzdefaultdict(r   ))rU  r   ro   rX  s    r+   r   zDefaultDictVariable.debug_repr  sL    #///W4/::<<WW@R@R@T@TWWW	
r-   r.   c                     t          | t          j                  r!| j        t          t
          t          t          fv S t          | t          j        j	        t          j        j
        f          S rI   )r=   r   r   fnr<  r   rz   set	functionsBaseUserFunctionVariablePolyfilledFunctionVariabler   s    r+   is_supported_argz$DefaultDictVariable.is_supported_arg  sY    c9455 		6dE4555'@'B  r-   r/   r"   r   r2   c                 .   |dk    rt          |          dk    r"t          ||dt          |           d           |d         | v r|                     ||d                   S t          | j        t
                    r,| j        j         t          t          ||d         g           d S | j        	                    |g i           }t                                          |d|d         |g|           |S t                                          ||||          S )Nr   r   r   r   r   r1   r   )r   r   r   r   rU  r   r   r   r   r  ro   r  )rJ   r/   r   r2   r`   default_varru   s         r+   r  zDefaultDictVariable.call_method  s    =  4yyA~~#Bh3t998K8K8KLLLAw$))"d1g666 4/1ABB
',2:,Xra	JJJJJJ"&"6"D"DRR"P"PKGG''MDG[+A6   '&77&&r4v>>>r-   r   r    c                                          fd            | j                   |                                                    t	          dd                     d S )Nc                                                                 t                                         d          g          S )Nr}   r   r   s   r+   r   z1DefaultDictVariable.reconstruct.<locals>.<lambda>  s>    G))55kBB,,];;  r-   r   F)r   rU  r   r   r   r   s    `r+   r   zDefaultDictVariable.reconstruct  s}       	
 	
 	
 	$%%%**733321e<<=====r-   rI   r8  )rW   rX   rY   rz   r   r(   r   r   rK   r\   r   r   r   staticmethodra  r<  r  r   r=  r>  s   @r+   rT  rT    so       
 6:	/ /O_45/ / "/2	/
 / 
/ / / / / /,D , , , , , ,
C 
 
 
 
 
 
 
o 
$ 
 
 
 \
?#? ? ?#	?
 S/)*? 
? ? ? ? ? ?8> > > > > > > >r-   rT  c            
       V    e Zd ZdZej        Zdee         de	ddf fdZ
defdZeded         fd	            Zedefd
            Zde	fdZdefdZde	fdZddZddde	dee         deeef         def
dZdddedee         deeef         def
 fdZdddedefdZddZ xZS )SetVariablez.We model a sets as dictionary with None valuesr_   r`   r%   Nc                     t                               |t                                                    } t	                      j        |fi | d S rI   )rz   fromkeysrh  _default_valuero   rK   )rJ   r_   r`   ru   s      r+   rK   zSetVariable.__init__  sI     e[%?%?%A%ABB))&)))))r-   c                 h    | j         sdS dd                    d | j         D                       z   dz   S )Nzset()r   ,c              3   H   K   | ]}|j                                         V  d S rI   r   re   r   s     r+   rh   z)SetVariable.debug_repr.<locals>.<genexpr>  .      !H!H!$//"3"3!H!H!H!H!H!Hr-   r   r_   r   rP   s    r+   r   zSetVariable.debug_repr  s?    z 	O7!H!HTZ!H!H!HHHH3NNr-   rF   c                 N    t          | j                                                  S rI   )r]  r_   r   rP   s    r+   	set_itemszSetVariable.set_items  s    4:??$$%%%r-   c                  *    t          j        d           S rI   )r   r   r]   r-   r+   rk  zSetVariable._default_value  s      &t,,,r-   c                 $    d | j         D             S )Nc                 @    h | ]}|j                                         S r]   r   ro  s     r+   	<setcomp>z'SetVariable.as_proxy.<locals>.<setcomp>  s"    888A888r-   rs  rP   s    r+   r   zSetVariable.as_proxy  s    888888r-   c                     t           S rI   )r]  rP   s    r+   r5   zSetVariable.python_type  s    
r-   c                 $    d | j         D             S )Nc                 @    h | ]}|j                                         S r]   r   ro  s     r+   rw  z1SetVariable.as_python_constant.<locals>.<setcomp>  s&    BBBa''))BBBr-   rx  rP   s    r+   r   zSetVariable.as_python_constant  s    BB4>BBBBr-   r   r    c                     |                     d | j        D                        |                    t          dt	          | j                                       d S )Nc                     g | ]	}|j         
S r]   r   r   s     r+   r-  z+SetVariable.reconstruct.<locals>.<listcomp>      666!666r-   	BUILD_SETr   )foreachrs  r   r   r   r   s     r+   r   zSetVariable.reconstruct  sW    66t~6667770#dnBUBUVVVWWWWWr-   r/   r"   r\  r2   c                 R   	  |d | g|D             i d |                                 D             }n`# t          $ rS}t          t          |          |t	          t          t          j        |j                                       Y d }~nd }~ww xY wt          j
        ||          S )Nc                 6    g | ]}|                                 S r]   r   r   s     r+   r-  z0SetVariable._fast_set_method.<locals>.<listcomp>'  s$    @@@Q!&&((@@@r-   c                 >    i | ]\  }}||                                 S r]   r  r   s      r+   rm   z0SetVariable._fast_set_method.<locals>.<dictcomp>(  s*    HHHA1a**,,HHHr-   r1   )r_   r6   r   r(   r<  mapr   r   r2   r   build)rJ   r/   r\  r2   r`   resexcs          r+   _fast_set_methodzSetVariable._fast_set_method  s    	"@@4-$-@@@HHHHH CC  	 	 	$S		2D-=-Dch)O)O$P$P        	
 $R---s   14 
BA	BBr   c                    ddl m} |dv ra |||          rU|                                 t          u r:|                                 }|                     |t          ||          ||          S |dk    r t          j        t                    j        |g|R i |}|j	        j
                            |            | j                                         | j                            |j                   t          j        d           S |dk    rl|st#          |          dk    r2t%          ||dt#          |           dt#          |           d	           d
}|d         t&                                          g}	nU|dk    r|s|r2t%          ||dt#          |           dt#          |           d	           	 | j                                        j        }nX# t0          $ rK}	t3          t0          |t5          t7          t          j        |	j                                       Y d }	~	nd }	~	ww xY wt;                                          |||g|           |S |dk    r|st#          |          dk    r2t%          ||dt#          |           dt#          |           d	           t          j        t@          j!                  "                    || |d         gi           S |dk    rZ|r"t%          ||dt#          |           d	           t          j        t@          j#                  "                    || g|i           S |dk    rZ|r"t%          ||dt#          |           d	           t          j        t@          j$                  "                    || g|i           S |dk    rZ|r"t%          ||dt#          |           d	           t          j        t@          j%                  "                    || g|i           S |dk    rZ|r"t%          ||dt#          |           d	           t          j        t@          j&                  "                    || g|i           S |dk    rZ|r"t%          ||dt#          |           d	           t          j        t@          j'                  "                    || g|i           S |dk    r}|st#          |          dk    r2t%          ||dt#          |           dt#          |           d	           t          j        t@          j(                  "                    || g|i           S |dk    r}|st#          |          dk    r2t%          ||dt#          |           dt#          |           d	           t          j        t@          j)                  "                    || g|i           S |dk    rn| *                                rZ|r"t%          ||dt#          |           d	           t          j        t@          j+                  "                    || g|i           S |dk    r|st#          |          dk    r2t%          ||dt#          |           dt#          |           d	           |d         | vrt3          t0          ||           t;                                          |d||          S |dk    r|st#          |          dk    r2t%          ||dt#          |           dt#          |           d	           |d         | v r$t;                                          |d||          S t          j        d           S |dv rt#          |          dk    r"t%          ||dt#          |           d           tX          j-        tX          j.        d}
|d         /                                }ta          |t&                    s/t          j        t                    "                    ||gi           }t          j        |
1                    |                    "                    || |gi           S |d v rddddd 1                    |          }te          |d         t&          t          j3        f          s`t          j        d!| d"| 4                                 d#|d         4                                 d$          }t3          tj          ||g           |J |                     ||||          S |d%v rte          |d         t&          t          j3        f          s`t          j        d!| d"| 4                                 d#|d         4                                 d$          }t3          tj          ||g           ddddd%1                    |          }|J |                     ||||           | S |d&k    r}te          |d         t&          t          j3        f          st          j        d'          S |                     |d||          }t          j        t#          |j                  dk              S |tl          v rxte          |d         t&          t          j3        f          st          j        tn                    S t          j        tm          |         | j        |d         j                            S t;                                          ||||          S )(Nr   )check_constant_args)
isdisjointunionintersection
differencesymmetric_differencerK   r  r   z1 args and 0 kwargsr   r   r   r   rn   r   r1   r  r  z0 kwargsintersection_updater  r  zExpect: 0 kwargs, Actual: difference_updater  symmetric_difference_updater  removediscard)r   )issubset
issupersetr   r   )__and__r
  __xor____sub__z unsupported operand type(s) for z: 'z' and 'r  )__iand__r  __ixor____isub__rV   F)8utilsr  r5   r]  r  getattrr   r   call_setr   r   r  r_   r  r  r   r   r   r   rh  rk  rs  rn   rG   r   r   r<  r  r2   ro   r  r#   r
   set_isdisjointr  set_intersectionset_intersection_update	set_unionset_differenceset_difference_updateset_symmetric_differenceset_symmetric_difference_updater  
set_updateoperatorleger8   r   r*   r=   UserDefinedSetVariablepython_type_namer7   r   NotImplemented)rJ   r/   r   r2   r`   r  py_typetemp_set_vtresulteoprU   mr   rru   s                  r+   r  zSetVariable.call_method1  s    	0/////   $#D&11   ""c))&&((G((WWd-C-CT6RRR:A)3C88A"VtVVVvVVKI"++D111JJk/000#*4000U]] Ta#)4yy@@CKK@@@	   !DG[7799:DDU]]  #)4yy@@CKK@@@	  *..*<*<*>*>*A   (btC0@0G,P,P'Q'Q        
 GGD6(F;;;M\!! Ta#)4yy@@CKK@@@	   1( mBtAw445 ^## S#BjS[[:Q:Q:QRRR1* mBr223 *** S#BjS[[:Q:Q:QRRR11 mBr223 W__ S#BjS[[:Q:Q:QRRR1)2EFFTTTMDM2   \!! #O3v;;OOO   1( mBr223 ((( S#BjS[[:Q:Q:QRRR1/ mBr223 +++ Ta#)4yy@@CKK@@@	   12 mBr223 222 Ta#)4yy@@CKK@@@	   19 mBr223 X$//"3"3 S#BjS[[:Q:Q:QRRR1)2FGGUUTMDM2   X Ta#)4yy@@CKK@@@	   Awd""(2DAAAA77&&r5$???Y Ta#)4yy@@CKK@@@	   Aw$ww**2udFCCC'.T::::///4yyA~~#Bh3t998K8K8KLLL %K&k B GOO%%E%-- V!1#66DDR%RTUU,RVVD\\::HHT5M2   @@@)!1'	 
 c$ii  d1gY5U'VWW D&-}t}}@U@U@W@W}}`def`g`x`x`z`z}}}  )BcUCCCC===##B4888DDDd1gY5U'VWW D&-}t}}@U@U@W@W}}`def`g`x`x`z`z}}}  )BcUCCCC1#9/	 
 c$ii  ===RD&111KXd1gY5U'VWW 6'.u555  %;T6JJA#*3q{+;+;q+@AAA+++d1gY5U'VWW ?'.~>>>#*&t,T^T!W=NOO   ww""2tT6:::s   5G 
H)AH$$H)r.   c                      t          d          )NzIllegal to getitem on a set)RuntimeError)rJ   r/   r.   s      r+   r   zSetVariable.getitem_const  s     8999r-   c                     d S rI   r]   rP   s    r+   r   z)SetVariable.install_dict_keys_match_guard      r-   r8  r9  )rW   rX   rY   rZ   r   SET_CONTAINSr   r<  r   r   rK   r   r   propertyr]  rs  rf  rk  r   r(   r5   r   r   rz   r  r  r   r   r=  r>  s   @r+   rh  rh    sJ       88!.N*O$* * 
	* * * * * *OC O O O O &3CD & & & X& -O - - - \-9# 9 9 9 9T    CC C C C CX X X X.#. . ?#	.
 S/)*. 
. . . .&P;#P; P; ?#	P;
 S/)*P; 
P; P; P; P; P; P;d:):0?:	: : : :
       r-   rh  c            
            e Zd ZdefdZeded         fd            ZdefdZ	de
fdZdd
Zdddedee         deeef         def
 fdZd Zd Zd Z xZS )FrozensetVariabler%   c                 h    | j         sdS dd                    d | j         D                       z   dz   S )Nzfrozenset()r   rm  c              3   H   K   | ]}|j                                         V  d S rI   r   ro  s     r+   rh   z/FrozensetVariable.debug_repr.<locals>.<genexpr>  rp  r-   r   rq  rP   s    r+   r   zFrozensetVariable.debug_repr  s?    z 	O =!H!HTZ!H!H!HHHH3NNr-   rF   c                 4    | j                                         S rI   )r_   r   rP   s    r+   rs  zFrozensetVariable.set_items  s    z   r-   c                     t           S rI   )	frozensetrP   s    r+   r5   zFrozensetVariable.python_type      r-   c                 >    t          d | j        D                       S )Nc                 @    h | ]}|j                                         S r]   r   ro  s     r+   rw  z7FrozensetVariable.as_python_constant.<locals>.<setcomp>  s&    LLL!$1133LLLr-   )r  rs  rP   s    r+   r   z$FrozensetVariable.as_python_constant  s!    LLT^LLLMMMr-   r   r    Nc                                          d | j        D                                            fd                               t	          dd                     d S )Nc                     g | ]	}|j         
S r]   r   r   s     r+   r-  z1FrozensetVariable.reconstruct.<locals>.<listcomp>  r~  r-   c                  V                                               d          g          S )Nr  )r   create_load_globalr   s   r+   r   z/FrozensetVariable.reconstruct.<locals>.<lambda>!  s-    G))..{;;  r-   r   F)r  rs  r   r   r   r   s    `r+   r   zFrozensetVariable.reconstruct  sy    66t~666777   	
 	
 	
 	21e<<=====r-   r/   r"   r   r2   r`   c                 &   |dv rt          d| d          |dk    rt          j        d           S |dv r8t                                          ||||          }t          |j                  S t                                          ||||          S )Nr  rn   r  r  r  r  Illegal call_method z on a frozensetrK   )rs   r  r  r  )r  r   r   ro   r  r  r_   )rJ   r/   r   r2   r`   r  ru   s         r+   r  zFrozensetVariable.call_method)  s     IIIKdKKKLLLZ $*4000 
 
 
 ##BdF;;A$QW---ww""2tT6:::r-   c                     dS )zB
        Frozensets are immutable and hashable in Python.
        Tr]   rP   s    r+   rA   z$FrozensetVariable.is_python_hashableE  s	     tr-   c                 D    t          |                                           S rI   )rM   r   rP   s    r+   rO   z!FrozensetVariable.get_python_hashK  s    D++--...r-   c                 V    |                                  |                                 k    S rI   r  rT   s     r+   rS   z!FrozensetVariable.is_python_equalN  s%    &&((E,D,D,F,FFFr-   r8  )rW   rX   rY   r   r   r  r]  rs  r(   r5   r   r   r   r<  r   rz   r  rA   rO   rS   r=  r>  s   @r+   r  r    sL       OC O O O O !3CD ! ! ! X!T    NC N N N N	> 	> 	> 	>;#; ; ?#	;
 S/)*; 
; ; ; ; ; ;8  / / /G G G G G G Gr-   r  c            
            e Zd ZdefdZddZdddee         ddfdZe	de
fd	            Zdefd
Zde
fdZdddedee         deeef         def
 fdZ xZS )DictKeySetVariabler%   c                 h    | j         sdS dd                    d | j         D                       z   dz   S )Nzdict_keys([])zdict_keys([rm  c              3   H   K   | ]}|j                                         V  d S rI   r   ro  s     r+   rh   z0DictKeySetVariable.debug_repr.<locals>.<genexpr>X  s.      (O(Oq):):(O(O(O(O(O(Or-   z])rq  rP   s    r+   r   zDictKeySetVariable.debug_reprS  sC    z 	"? (O(ODJ(O(O(O O OORVVr-   Nc                     d S rI   r]   rP   s    r+   r   z0DictKeySetVariable.install_dict_keys_match_guard[  r  r-   r/   r"   r2   c                     d S rI   r]   rR  s      r+   r   z.DictKeySetVariable.install_dict_contains_guard_  s	     	r-   c                     | j         S rI   r   rP   s    r+   rs  zDictKeySetVariable.set_itemse  s
    zr-   c                     t           S rI   r   rP   s    r+   r5   zDictKeySetVariable.python_typei  r  r-   c                 z    t                               d | j        D             d                                           S )Nc                 @    h | ]}|j                                         S r]   r   ro  s     r+   rw  z8DictKeySetVariable.as_python_constant.<locals>.<setcomp>n  s&    ???1QT$$&&???r-   )rz   rj  rs  r   rP   s    r+   r   z%DictKeySetVariable.as_python_constantl  s6    }}?????
 

$&&	r-   r   r`   c                 z    |dv rt          d| d          t                                          ||||          S )Nr  r  z on a dict_keys)r  ro   r  rJ   r/   r   r2   r`   ru   s        r+   r  zDictKeySetVariable.call_methodq  sI     IIIKdKKKLLLww""2tT6:::r-   r9  )rW   rX   rY   r   r   r   r<  r   r   r  r   rs  r(   r5   r   rz   r  r=  r>  s   @r+   r  r  R  s9       C       )15o1F	    3    XT    C    
	;#	; 	; ?#		;
 S/)*	; 
	; 	; 	; 	; 	; 	; 	; 	; 	; 	;r-   r  c            
           e Zd ZU dZdZee         ed<   dede	ddf fdZ
ede	fd            Zedee         fd	            Zd
ddee         fdZddZd
ddedefdZd
ddedee         deeef         def
 fdZ xZS )DictViewVariablezu
    Models _PyDictViewObject

    This is an "abstract" class. Subclasses will override kv and the items method
    NkvrA  r`   r%   c                      t                      j        di | | j        dv sJ t          |t                    sJ || _        d S )N)r   r   r_   r]   )ro   rK   r  r=   rC   rA  rC  s      r+   rK   zDictViewVariable.__init__  sV    ""6"""w55555'#455555r-   c                 b    | j         J  t          | j        j        | j                               S rI   )r  r  rA  r_   rP   s    r+   
view_itemszDictViewVariable.view_items  s/    w"""3wt|)4733555r-   c                     t           rI   )NotImplementedErrorrP   s    r+   view_items_vtzDictViewVariable.view_items_vt  s
     "!r-   r/   r"   c                     | j         S rI   )r  r.  s     r+   r!  z$DictViewVariable.unpack_var_sequence  s    !!r-   r   r    c                     | j         J  || j                   |                    | j                    |                    d           d S )Nr   )r  rA  load_methodr  r   s     r+   r   zDictViewVariable.reconstruct  sR    w"""DG$$$Ar-   r   c                     | j         J ||                                 j        v rt          j        d          S t          j        d          S )NTF)r  r5   r)   r   r   )rJ   r/   r   s      r+   r3  z!DictViewVariable.call_obj_hasattr  sN     w"""4##%%...#*4000&u---r-   r2   c                     |dk    r| j                             ||||          S |dk    r"t          | j        t	                                S t                                          ||||          S )Nr   r  r  )rA  r  r   r  r   ro   r  s        r+   r  zDictViewVariable.call_method  s}     9<++BdFCCCZ'"2B2D2D    ww""2tT6:::r-   r8  )rW   rX   rY   rZ   r  r   r   __annotations__rC   r   rK   r  r  r<  r   r  r!  r   r   r3  rz   r  r=  r>  s   @r+   r  r  }  s          B 1 S T       6C 6 6 6 X6 "tO4 " " " X"
"&= "$BW " " " "   .).14.	. . . .;#; ; ?#	;
 S/)*; 
; ; ; ; ; ; ; ; ; ;r-   r  c            
            e Zd ZdZedee         fd            Zedee         fd            Z	de
fdZddded	ee         d
eeef         def
 fdZ xZS )r  r   r%   c                 *    t          | j                  S rI   )r]  r  rP   s    r+   rs  zDictKeysVariable.set_items  s    4?###r-   c                 $    d | j         D             S )Nc                     g | ]	}|j         
S r]   r   r   s     r+   r-  z2DictKeysVariable.view_items_vt.<locals>.<listcomp>  s    ......r-   r  rP   s    r+   r  zDictKeysVariable.view_items_vt  s     /.do....r-   c                     t           S rI   r  rP   s    r+   r5   zDictKeysVariable.python_type  r  r-   r/   r"   r   r2   r`   c                    |dk    r| j                             ||||          S |dv r:t          | j        |          } ||d         j                  }t	          |          S |t
          v rst          |d         t          t          f          st          j	        t                    S t          j	        t          |         | j        |d         j                            S t                                          ||||          S )Nr   )r  r  r
  r  r  r  r  r  r   )rA  r  r  rs  rh  r   r=   r  r   r   r  ro   )rJ   r/   r   r2   r`   r  r  ru   s          r+   r  zDictKeysVariable.call_method  s     >!!<++BdFCCC 	
 	
 	
 --A$q'#$$Aq>>!)))d1g5E'FGG ?'.~>>>#*&t,T^T!W=NOO   ww""2tT6:::r-   )rW   rX   rY   r  r  r]  r   rs  r<  r  r(   r5   r   rz   r  r=  r>  s   @r+   r  r    s        	B$3/ $ $ $ X$ /tO4 / / / X/T    ;#; ; ?#	;
 S/)*; 
; ; ; ; ; ; ; ; ; ;r-   r  c                   F    e Zd ZdZedee         fd            ZdefdZ	dS )r  r   r%   c                 *    t          | j                  S rI   )r<  r  rP   s    r+   r  z DictValuesVariable.view_items_vt  s    DO$$$r-   c                     t           S rI   )r   rP   s    r+   r5   zDictValuesVariable.python_type  s    r-   N)
rW   rX   rY   r  r  r<  r   r  r(   r5   r]   r-   r+   r  r    s^        	B%tO4 % % % X%T      r-   r  c            
            e Zd ZdZedee         fd            ZdefdZ	ddde
dee         d	ee
ef         def
 fd
Zd Z xZS )r  r_   r%   c                 $    d | j         D             S )Nc                 J    g | ] \  }}t          j        |j        |g          !S r]   )r   r  rG   r   s      r+   r-  z3DictItemsVariable.view_items_vt.<locals>.<listcomp>  s-    OOOtq!	'q	22OOOr-   r  rP   s    r+   r  zDictItemsVariable.view_items_vt  s     POtOOOOr-   c                     t           S rI   )r   rP   s    r+   r5   zDictItemsVariable.python_type  s    r-   r/   r"   r   r2   r`   c                 r   |dk    rt          |          dk    r"t          ||dt          |           d           t          |d         t                    r)| j                            |d|d         j        gi           S t          j        d          S t                                          ||||          S )NrV   r   r   r   r   F)	r   r   r=   r  rA  r  r   r   ro   r  s        r+   r  zDictItemsVariable.call_method  s     84yyA~~#Bh3t998K8K8KLLL$q'#455 U|//HtAw>OQSTTT#*5111ww""2tT6:::r-   c                     dS )zC
        Dictionary item views are not hashable in Python.
        Fr]   rP   s    r+   rA   z$DictItemsVariable.is_python_hashable  r7  r-   )rW   rX   rY   r  r  r<  r   r  r(   r5   r   rz   r  rA   r=  r>  s   @r+   r  r    s        	BPtO4 P P P XPT    ;#; ; ?#	;
 S/)*; 
; ; ; ; ; ;"      r-   r  rI   )@rZ   r{   r   r  rE  collections.abcr   typingr   r   r   r   r  r	   r
   r   bytecode_transformationr   r   r  r   r   guardsr   r   rr   r   r   r  r   r   r   r   r   r   r   rx   r   r   constantr   listsr   torch._dynamo.codegenr    r3   r"   r^  r#   r\   r,   r:   r@   rC   r@  rO  rT  rh  r  r  r  r  r  r  r]   r-   r+   <module>r     s_   (           $ $ $ $ $ $ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 N N N N N N N N 9 9 9 9 9 9 9 9 0 0 0 0 0 0 0 0 = = = = = = = =                  4 3 3 3 3 3 3 3 & & & & & & ' ' ' ' ' '  0//////DDDDDD//////>C >D > > > >
 CG 	&'>?	   ."? "t " " " "^ ^ ^ ^ ^ ^ ^ ^BJ2 J2 J2 J2 J2? J2 J2 J2Z     1   P> P> P> P> P>+ P> P> P>lW W W W W# W W WtBG BG BG BG BG BG BG BGJ(; (; (; (; (; (; (; (;V8; 8; 8; 8; 8; 8; 8; 8;v,; ,; ,; ,; ,;' ,; ,; ,;^	 	 	 	 	) 	 	 	         (          r-   