Unable to compile the function which contains dict of types
Labels: triaged, oncall: pt2, module: dynamo

### 🐛 Describe the bug

Whenever I try to use dictionary of types for example x = {tuple:True,list:True} inside torch.compile. It fails.

### Error logs

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
[/workspaces/ivy/torch.fix.ipynb](https://vscode-remote+codespaces-002bfluffy-002dspoon-002dq4g9qr7rq79295v9.vscode-resource.vscode-cdn.net/workspaces/ivy/torch.fix.ipynb) Cell 4 line 8
      <a href='[vscode-notebook-cell://codespaces%2Bfluffy-spoon-q4g9qr7rq79295v9/workspaces/ivy/torch.fix.ipynb#X11sdnNjb2RlLXJlbW90ZQ%3D%3D?line=4'>5</a>](vscode-notebook-cell://codespaces%2Bfluffy-spoon-q4g9qr7rq79295v9/workspaces/ivy/torch.fix.ipynb#X11sdnNjb2RlLXJlbW90ZQ%3D%3D?line=4'%3E5%3C/a%3E)     return x
      <a href='[vscode-notebook-cell://codespaces%2Bfluffy-spoon-q4g9qr7rq79295v9/workspaces/ivy/torch.fix.ipynb#X11sdnNjb2RlLXJlbW90ZQ%3D%3D?line=6'>7</a>](vscode-notebook-cell://codespaces%2Bfluffy-spoon-q4g9qr7rq79295v9/workspaces/ivy/torch.fix.ipynb#X11sdnNjb2RlLXJlbW90ZQ%3D%3D?line=6'%3E7%3C/a%3E) torch_fn = torch.compile(fn)
----> <a href='[vscode-notebook-cell://codespaces%2Bfluffy-spoon-q4g9qr7rq79295v9/workspaces/ivy/torch.fix.ipynb#X11sdnNjb2RlLXJlbW90ZQ%3D%3D?line=7'>8</a>](vscode-notebook-cell://codespaces%2Bfluffy-spoon-q4g9qr7rq79295v9/workspaces/ivy/torch.fix.ipynb#X11sdnNjb2RlLXJlbW90ZQ%3D%3D?line=7'%3E8%3C/a%3E) torch_fn(torch.tensor([1., 2.]))

File [/opt/fw/torch/torch/_dynamo/eval_frame.py:209](https://vscode-remote+codespaces-002bfluffy-002dspoon-002dq4g9qr7rq79295v9.vscode-resource.vscode-cdn.net/opt/fw/torch/torch/_dynamo/eval_frame.py:209), in _TorchDynamoContext.__call__.<locals>._fn(*args, **kwargs)
    207 dynamic_ctx.__enter__()
    208 try:
--> 209     return fn(*args, **kwargs)
    210 finally:
    211     set_eval_frame(prior)

File [/opt/fw/torch/torch/_dynamo/eval_frame.py:337](https://vscode-remote+codespaces-002bfluffy-002dspoon-002dq4g9qr7rq79295v9.vscode-resource.vscode-cdn.net/opt/fw/torch/torch/_dynamo/eval_frame.py:337), in catch_errors_wrapper.<locals>.catch_errors(frame, cache_size)
    334             return hijacked_callback(frame, cache_size, hooks)
    336 with compile_lock:
--> 337     return callback(frame, cache_size, hooks)

File [/opt/fw/torch/torch/_dynamo/convert_frame.py:404](https://vscode-remote+codespaces-002bfluffy-002dspoon-002dq4g9qr7rq79295v9.vscode-resource.vscode-cdn.net/opt/fw/torch/torch/_dynamo/convert_frame.py:404), in convert_frame.<locals>._convert_frame(frame, cache_size, hooks)
    402 counters["frames"]["total"] += 1
    403 try:
--> 404     result = inner_convert(frame, cache_size, hooks)
    405     counters["frames"]["ok"] += 1
    406     return result

File [/opt/fw/torch/torch/_dynamo/convert_frame.py:104](https://vscode-remote+codespaces-002bfluffy-002dspoon-002dq4g9qr7rq79295v9.vscode-resource.vscode-cdn.net/opt/fw/torch/torch/_dynamo/convert_frame.py:104), in wrap_convert_context.<locals>._fn(*args, **kwargs)
    102 torch.fx.graph_module._forward_from_src = fx_forward_from_src_skip_result
    103 try:
--> 104     return fn(*args, **kwargs)
    105 finally:
    106     torch._C._set_grad_enabled(prior_grad_mode)

File [/opt/fw/torch/torch/_dynamo/convert_frame.py:262](https://vscode-remote+codespaces-002bfluffy-002dspoon-002dq4g9qr7rq79295v9.vscode-resource.vscode-cdn.net/opt/fw/torch/torch/_dynamo/convert_frame.py:262), in convert_frame_assert.<locals>._convert_frame_assert(frame, cache_size, hooks)
    259 global initial_grad_state
    260 initial_grad_state = torch.is_grad_enabled()
--> 262 return _compile(
    263     frame.f_code,
    264     frame.f_globals,
    265     frame.f_locals,
    266     frame.f_builtins,
    267     compiler_fn,
    268     one_graph,
    269     export,
    270     hooks,
    271     frame,
    272 )

File [/opt/fw/torch/torch/_dynamo/utils.py:163](https://vscode-remote+codespaces-002bfluffy-002dspoon-002dq4g9qr7rq79295v9.vscode-resource.vscode-cdn.net/opt/fw/torch/torch/_dynamo/utils.py:163), in dynamo_timed.<locals>.dynamo_timed_inner.<locals>.time_wrapper(*args, **kwargs)
    161     compilation_metrics[key] = []
    162 t0 = time.time()
--> 163 r = func(*args, **kwargs)
    164 time_spent = time.time() - t0
    165 # print(f"Dynamo timer: key={key}, latency={latency:.2f} sec")

File [/opt/fw/torch/torch/_dynamo/convert_frame.py:324](https://vscode-remote+codespaces-002bfluffy-002dspoon-002dq4g9qr7rq79295v9.vscode-resource.vscode-cdn.net/opt/fw/torch/torch/_dynamo/convert_frame.py:324), in _compile(code, globals, locals, builtins, compiler_fn, one_graph, export, hooks, frame)
    322 for attempt in itertools.count():
    323     try:
--> 324         out_code = transform_code_object(code, transform)
    325         orig_code_map[out_code] = code
    326         break

File [/opt/fw/torch/torch/_dynamo/bytecode_transformation.py:445](https://vscode-remote+codespaces-002bfluffy-002dspoon-002dq4g9qr7rq79295v9.vscode-resource.vscode-cdn.net/opt/fw/torch/torch/_dynamo/bytecode_transformation.py:445), in transform_code_object(code, transformations, safe)
    442 instructions = cleaned_instructions(code, safe)
    443 propagate_line_nums(instructions)
--> 445 transformations(instructions, code_options)
    446 return clean_and_assemble_instructions(instructions, keys, code_options)[1]

File [/opt/fw/torch/torch/_dynamo/convert_frame.py:311](https://vscode-remote+codespaces-002bfluffy-002dspoon-002dq4g9qr7rq79295v9.vscode-resource.vscode-cdn.net/opt/fw/torch/torch/_dynamo/convert_frame.py:311), in _compile.<locals>.transform(instructions, code_options)
    298 nonlocal output
    299 tracer = InstructionTranslator(
    300     instructions,
    301     code,
   (...)
    309     mutated_closure_cell_contents,
    310 )
--> 311 tracer.run()
    312 output = tracer.output
    313 assert output is not None

File [/opt/fw/torch/torch/_dynamo/symbolic_convert.py:1726](https://vscode-remote+codespaces-002bfluffy-002dspoon-002dq4g9qr7rq79295v9.vscode-resource.vscode-cdn.net/opt/fw/torch/torch/_dynamo/symbolic_convert.py:1726), in InstructionTranslator.run(self)
   1724 def run(self):
   1725     _step_logger()(logging.INFO, f"torchdynamo start tracing {self.f_code.co_name}")
-> 1726     super().run()

File [/opt/fw/torch/torch/_dynamo/symbolic_convert.py:576](https://vscode-remote+codespaces-002bfluffy-002dspoon-002dq4g9qr7rq79295v9.vscode-resource.vscode-cdn.net/opt/fw/torch/torch/_dynamo/symbolic_convert.py:576), in InstructionTranslatorBase.run(self)
    571 try:
    572     self.output.push_tx(self)
    573     while (
    574         self.instruction_pointer is not None
    575         and not self.output.should_exit
--> 576         and self.step()
    577     ):
    578         pass
    579 except BackendCompilerFailed:

File [/opt/fw/torch/torch/_dynamo/symbolic_convert.py:540](https://vscode-remote+codespaces-002bfluffy-002dspoon-002dq4g9qr7rq79295v9.vscode-resource.vscode-cdn.net/opt/fw/torch/torch/_dynamo/symbolic_convert.py:540), in InstructionTranslatorBase.step(self)
    538     if not hasattr(self, inst.opname):
    539         unimplemented(f"missing: {inst.opname}")
--> 540     getattr(self, inst.opname)(inst)
    542     return inst.opname != "RETURN_VALUE"
    543 except BackendCompilerFailed:

File [/opt/fw/torch/torch/_dynamo/symbolic_convert.py:1129](https://vscode-remote+codespaces-002bfluffy-002dspoon-002dq4g9qr7rq79295v9.vscode-resource.vscode-cdn.net/opt/fw/torch/torch/_dynamo/symbolic_convert.py:1129), in InstructionTranslatorBase.BUILD_MAP(self, inst)
   1127 result = dict()
   1128 for k, v in zip(items[::2], items[1::2]):
-> 1129     assert isinstance(k, (ConstantVariable, EnumVariable)) or (
   1130         isinstance(k, TensorVariable) and k.specialized_value is not None
   1131     )
   1133     result[ConstDictVariable.get_key(k)] = v
   1134 assert len(result) == len(items) [/](https://vscode-remote+codespaces-002bfluffy-002dspoon-002dq4g9qr7rq79295v9.vscode-resource.vscode-cdn.net/) 2

AssertionError: 

from user code:
   File "/tmp/ipykernel_5484/2819566581.py", line 4, in fn
    temp = {tuple:True}


You can suppress this exception and fall back to eager by setting:
    torch._dynamo.config.suppress_errors = True

### Minified repro

import torch
def fn(x):
    temp = {tuple:True} #this gives error
    return x

torch_fn = torch.compile(fn)
torch_fn(torch.tensor([1., 2.]))

### Versions

Collecting environment information...
PyTorch version: 2.0.1+cu118
Is debug build: False
CUDA used to build PyTorch: 11.8
ROCM used to build PyTorch: N/A

OS: Debian GNU/Linux 10 (buster) (x86_64)
GCC version: (Debian 8.3.0-6) 8.3.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.28

Python version: 3.10.0 (default, Mar  3 2022, 09:58:08) [GCC 7.5.0] (64-bit runtime)
Python platform: Linux-5.15.0-1041-azure-x86_64-with-glibc2.28
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: Tesla V100-PCIE-16GB
Nvidia driver version: 535.86.10
cuDNN version: Probably one of the following:
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn.so.8
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_adv_train.so.8
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_ops_train.so.8
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
Address sizes:       46 bits physical, 48 bits virtual
CPU(s):              6
On-line CPU(s) list: 0-5
Thread(s) per core:  1
Core(s) per socket:  6
Socket(s):           1
NUMA node(s):        1
Vendor ID:           GenuineIntel
CPU family:          6
Model:               79
Model name:          Intel(R) Xeon(R) CPU E5-2690 v4 @ 2.60GHz
Stepping:            1
CPU MHz:             2593.991
BogoMIPS:            5187.98
Hypervisor vendor:   Microsoft
Virtualization type: full
L1d cache:           32K
L1i cache:           32K
L2 cache:            256K
L3 cache:            35840K
NUMA node0 CPU(s):   0-5
Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx smap xsaveopt md_clear

Versions of relevant libraries:
[pip3] numpy==1.25.2
[pip3] torch==2.0.1+cu118
[pip3] torch-scatter==2.1.1
[pip3] triton==2.0.0
[conda] No relevant packages

cc @ezyang @msaroufim @wconstab @bdhirsh @anijain2305 @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @Xia-Weiwen @wenzhe-nrv @jiayisunx @chenyang78 @aakhundov @kadeng