[dynamo] can't compile if tensor subclass implements __torch_function__ using super()
Labels: triaged, oncall: pt2, module: dynamo

### 🐛 Describe the bug

I can't compile operations on a simple subclass of `torch.Tensor` if it implements `__torch_function__` like so:

```python
# fails
import torch


class MyTensor(torch.Tensor):
    @classmethod
    def __torch_function__(cls, func, types, args=(), kwargs=None):
        return super().__torch_function__(
            func,
            (torch.Tensor for _ in types),
            tuple(torch.Tensor() for _ in args),
            kwargs,
        )


def add(a, b):
    return torch.add(a, b)


t = MyTensor()
add(t, t)  # works
torch.compile(add, backend="eager")(t, t)  # RuntimeError
```

However, if I explicitly replace `super()` with `torch.Tensor` it works:

```python
# works
import torch


class MyTensor(torch.Tensor):
    @classmethod
    def __torch_function__(cls, func, types, args=(), kwargs=None):
        return torch.Tensor.__torch_function__(
            func,
            (torch.Tensor for _ in types),
            tuple(torch.Tensor() for _ in args),
            kwargs,
        )


def add(a, b):
    return torch.add(a, b)


t = MyTensor()
add(t, t)  # works
torch.compile(add, backend="eager")(t, t)  # works
```

This seems like a bug to me.
Or am I misunderstanding the usage of `super()` in this context?

Thanks!

### Error logs

```
/home/johannes/Documents/jina/docarrayv2/venv/bin/python /home/johannes/.config/JetBrains/PyCharmCE2023.2/scratches/scratch_185.py 
Traceback (most recent call last):
  File "/home/johannes/Documents/jina/docarrayv2/venv/lib/python3.8/site-packages/torch/_dynamo/variables/constant.py", line 62, in unpack_var_sequence
    return [ConstantVariable(x, **options) for x in self.as_python_constant()]
TypeError: 'NoneType' object is not iterable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/johannes/Documents/jina/docarrayv2/venv/lib/python3.8/site-packages/torch/_dynamo/convert_frame.py", line 324, in _compile
    out_code = transform_code_object(code, transform)
  File "/home/johannes/Documents/jina/docarrayv2/venv/lib/python3.8/site-packages/torch/_dynamo/bytecode_transformation.py", line 445, in transform_code_object
    transformations(instructions, code_options)
  File "/home/johannes/Documents/jina/docarrayv2/venv/lib/python3.8/site-packages/torch/_dynamo/convert_frame.py", line 311, in transform
    tracer.run()
  File "/home/johannes/Documents/jina/docarrayv2/venv/lib/python3.8/site-packages/torch/_dynamo/symbolic_convert.py", line 1726, in run
    super().run()
  File "/home/johannes/Documents/jina/docarrayv2/venv/lib/python3.8/site-packages/torch/_dynamo/symbolic_convert.py", line 576, in run
    and self.step()
  File "/home/johannes/Documents/jina/docarrayv2/venv/lib/python3.8/site-packages/torch/_dynamo/symbolic_convert.py", line 540, in step
    getattr(self, inst.opname)(inst)
  File "/home/johannes/Documents/jina/docarrayv2/venv/lib/python3.8/site-packages/torch/_dynamo/symbolic_convert.py", line 342, in wrapper
    return inner_fn(self, inst)
  File "/home/johannes/Documents/jina/docarrayv2/venv/lib/python3.8/site-packages/torch/_dynamo/symbolic_convert.py", line 965, in CALL_FUNCTION
    self.call_function(fn, args, {})
  File "/home/johannes/Documents/jina/docarrayv2/venv/lib/python3.8/site-packages/torch/_dynamo/symbolic_convert.py", line 474, in call_function
    self.push(fn.call_function(self, args, kwargs))
  File "/home/johannes/Documents/jina/docarrayv2/venv/lib/python3.8/site-packages/torch/_dynamo/variables/misc.py", line 702, in call_function
    new_kwargs = args[3].items
  File "/home/johannes/Documents/jina/docarrayv2/venv/lib/python3.8/site-packages/torch/_dynamo/variables/constant.py", line 43, in items
    return self.unpack_var_sequence(tx=None)
  File "/home/johannes/Documents/jina/docarrayv2/venv/lib/python3.8/site-packages/torch/_dynamo/variables/constant.py", line 64, in unpack_var_sequence
    raise NotImplementedError from e
NotImplementedError: 

from user code:
   File "/home/johannes/.config/JetBrains/PyCharmCE2023.2/scratches/scratch_185.py", line 8, in __torch_function__
    return super().__torch_function__(

Set torch._dynamo.config.verbose=True for more information


You can suppress this exception and fall back to eager by setting:
    torch._dynamo.config.suppress_errors = True


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/johannes/.config/JetBrains/PyCharmCE2023.2/scratches/scratch_185.py", line 22, in <module>
    torch.compile(add, backend="eager")(t, t)  # RuntimeError
  File "/home/johannes/Documents/jina/docarrayv2/venv/lib/python3.8/site-packages/torch/_dynamo/eval_frame.py", line 209, in _fn
    return fn(*args, **kwargs)
  File "/home/johannes/.config/JetBrains/PyCharmCE2023.2/scratches/scratch_185.py", line 17, in add
    return torch.add(a, b)
  File "/home/johannes/Documents/jina/docarrayv2/venv/lib/python3.8/site-packages/torch/_dynamo/eval_frame.py", line 337, in catch_errors
    return callback(frame, cache_size, hooks)
  File "/home/johannes/Documents/jina/docarrayv2/venv/lib/python3.8/site-packages/torch/_dynamo/convert_frame.py", line 404, in _convert_frame
    result = inner_convert(frame, cache_size, hooks)
  File "/home/johannes/Documents/jina/docarrayv2/venv/lib/python3.8/site-packages/torch/_dynamo/convert_frame.py", line 104, in _fn
    return fn(*args, **kwargs)
  File "/home/johannes/Documents/jina/docarrayv2/venv/lib/python3.8/site-packages/torch/_dynamo/convert_frame.py", line 262, in _convert_frame_assert
    return _compile(
  File "/home/johannes/Documents/jina/docarrayv2/venv/lib/python3.8/site-packages/torch/_dynamo/utils.py", line 163, in time_wrapper
    r = func(*args, **kwargs)
  File "/home/johannes/Documents/jina/docarrayv2/venv/lib/python3.8/site-packages/torch/_dynamo/convert_frame.py", line 394, in _compile
    raise InternalTorchDynamoError() from e
torch._dynamo.exc.InternalTorchDynamoError

Process finished with exit code 1
```

### Minified repro

running `env TORCHDYNAMO_REPRO_AFTER="dynamo" python /path/to/my/file.py` gives the exact same error output, and is not generating any code. Maybe I am doing something wrong?

### Versions

Collecting environment information...
PyTorch version: 2.0.1+cpu
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.3 LTS (x86_64)
GCC version: (Ubuntu 10.5.0-1ubuntu1~20.04) 10.5.0
Clang version: Could not collect
CMake version: version 3.27.0
Libc version: glibc-2.31

Python version: 3.8.10 (default, May 26 2023, 14:05:08)  [GCC 9.4.0] (64-bit runtime)
Python platform: Linux-5.15.0-78-generic-x86_64-with-glibc2.29
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
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:                   39 bits physical, 48 bits virtual
CPU(s):                          8
On-line CPU(s) list:             0-7
Thread(s) per core:              2
Core(s) per socket:              4
Socket(s):                       1
NUMA node(s):                    1
Vendor ID:                       GenuineIntel
CPU family:                      6
Model:                           140
Model name:                      11th Gen Intel(R) Core(TM) i7-1195G7 @ 2.90GHz
Stepping:                        2
CPU MHz:                         2789.703
CPU max MHz:                     5000,0000
CPU min MHz:                     400,0000
BogoMIPS:                        5836.80
Virtualization:                  VT-x
L1d cache:                       192 KiB
L1i cache:                       128 KiB
L2 cache:                        5 MiB
L3 cache:                        12 MiB
NUMA node0 CPU(s):               0-7
Vulnerability Itlb multihit:     Not affected
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Mmio stale data:   Not affected
Vulnerability Retbleed:          Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:        Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l2 invpcid_single cdp_l2 ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves split_lock_detect dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid movdiri movdir64b fsrm avx512_vp2intersect md_clear flush_l1d arch_capabilities

Versions of relevant libraries:
[pip3] mypy==1.3.0
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.23.4
[pip3] torch==2.0.1+cpu
[conda] Could not collect


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