Repository: pytorch
Issue: TorchScript assertion failure for a `List[...]` inside a `NamedTuple`
Labels: oncall: jit

### 🐛 Describe the bug

Minimal example below. Trying to access a `List[float]` inside a `NamedTuple` fails an assert and asks for a bug report.

```python
import torch
from typing import List, Optional, NamedTuple

class MyTuple(NamedTuple):
  item: List[float] = []


class Module(torch.nn.Module):
  def forward(self, data: MyTuple) -> Optional[torch.Tensor]:
    print(len(data.item))
    return None


tup = MyTuple([0.1, 0.2, 0.4])
mod = Module()
mod = torch.jit.script(mod)
mod(tup)
```

Here's the output from PyTorch:
```
	Traceback (most recent call last):
  File "/tmp/test.py", line 16, in <module>
    mod = torch.jit.script(mod)
  File "/home/sharvil/.miniconda2/envs/torch110/lib/python3.9/site-packages/torch/jit/_script.py", line 1257, in script
    return torch.jit._recursive.create_script_module(
  File "/home/sharvil/.miniconda2/envs/torch110/lib/python3.9/site-packages/torch/jit/_recursive.py", line 451, in create_script_module
    return create_script_module_impl(nn_module, concrete_type, stubs_fn)
  File "/home/sharvil/.miniconda2/envs/torch110/lib/python3.9/site-packages/torch/jit/_recursive.py", line 517, in create_script_module_impl
    create_methods_and_properties_from_stubs(concrete_type, method_stubs, property_stubs)
  File "/home/sharvil/.miniconda2/envs/torch110/lib/python3.9/site-packages/torch/jit/_recursive.py", line 368, in create_methods_and_properties_from_stubs
    concrete_type._create_methods_and_properties(property_defs, property_rcbs, method_defs, method_rcbs, method_defaults)
  File "/home/sharvil/.miniconda2/envs/torch110/lib/python3.9/site-packages/torch/jit/annotations.py", line 388, in try_ann_to_type
    return torch._C._resolve_type_from_object(ann, loc, fake_rcb)
RuntimeError: type_INTERNAL ASSERT FAILED at "/home/sharvil/build/pytorch/aten/src/ATen/core/jit_type.h":2543, please report a bug to PyTorch. 
```

### Versions

PyTorch version: 1.10.0a0+git36449ea
Is debug build: False
CUDA used to build PyTorch: 11.2
ROCM used to build PyTorch: N/A

OS: Ubuntu 18.04.6 LTS (x86_64)
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Clang version: Could not collect
CMake version: version 3.21.3
Libc version: glibc-2.27

Python version: 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 19:20:46)  [GCC 9.4.0] (64-bit runtime)
Python platform: Linux-4.15.0-163-generic-x86_64-with-glibc2.27
Is CUDA available: True
CUDA runtime version: 11.2.152
GPU models and configuration: 
GPU 0: GeForce RTX 3090
GPU 1: GeForce RTX 2080 Ti

Nvidia driver version: 460.32.03
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.5
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn.so.8.1.0
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.1.0
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.1.0
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.1.0
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.1.0
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.1.0
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.1.0
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] numpy==1.19.5
[pip3] torch==1.10.0a0+git36449ea
[pip3] torchaudio==0.10.0+d2634d8
[pip3] torchtext==0.11.0a0+d697db5
[conda] magma-cuda112             2.5.2                         1    pytorch
[conda] mkl                       2021.4.0           h8d4b97c_729    conda-forge
[conda] mkl-include               2021.4.0           h8d4b97c_729    conda-forge
[conda] numpy                     1.19.5                   pypi_0    pypi
[conda] torch                     1.10.0a0+git36449ea          pypi_0    pypi
[conda] torchaudio                0.10.0+d2634d8           pypi_0    pypi
[conda] torchtext                 0.11.0a0+d697db5          pypi_0    pypi