Repository: pytorch
Issue: TorchScript: Optional sized lists cannot be called with optional scalar values
Labels: oncall: jit,days

## 🐛 Bug

Given a schema containing an optional sized list (e.g. `int[1]?`), I should be able to call this with a variable of type `int?` but `torch.jit.script` will fail to compile it.

## To Reproduce

Reproduce with this script:

```python
import torch.fft
from typing import Optional
def fn(t, n: Optional[int]):
    return torch.fft.fftn(t, n)
torch.jit.script(fn)
```

Which produces the following stack trace:
```
~/.conda/envs/pytorch-dev/lib/python3.8/site-packages/torch/jit/_script.py in script(obj, optimize, _frames_up, _rcb)
    951         if _rcb is None:
    952             _rcb = _jit_internal.createResolutionCallbackFromClosure(obj)
--> 953         fn = torch._C._jit_script_compile(
    954             qualified_name, ast, _rcb, get_default_args(obj)
    955         )

RuntimeError: 

aten::fft_fftn(Tensor self, int[1]? s=None, int[1]? dim=None, str? norm=None) -> (Tensor):
Expected a value of type 'Optional[List[int]]' for argument 's' but instead found type 'Optional[int]'.
:
  File "<ipython-input-6-5b14014ab4c6>", line 3
def fn(t, n: Optional[int]):
    return torch.fft.fftn(t, n)
           ~~~~~~~~~~~~~~ <--- HERE
```

## Expected behavior

The script should compile without issue, since both `None` and `int` are valid values to pass to an `int[n]?` argument.

## Environment

`collect_env.py` output:
```
PyTorch version: 1.8.0a0+a84ae0b
Is debug build: False
CUDA used to build PyTorch: 11.1
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.1 LTS (x86_64)
GCC version: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Clang version: Could not collect
CMake version: version 3.18.2

Python version: 3.8 (64-bit runtime)
Is CUDA available: True
CUDA runtime version: Could not collect
GPU models and configuration: 
GPU 0: GeForce RTX 2060
GPU 1: GeForce RTX 2060

Nvidia driver version: 455.23.05
cuDNN version: Probably one of the following:
/usr/local/cuda-10.1.243/targets/x86_64-linux/lib/libcudnn.so.8
/usr/local/cuda-10.1.243/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8
/usr/local/cuda-10.1.243/targets/x86_64-linux/lib/libcudnn_adv_train.so.8
/usr/local/cuda-10.1.243/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8
/usr/local/cuda-10.1.243/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8
/usr/local/cuda-10.1.243/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8
/usr/local/cuda-10.1.243/targets/x86_64-linux/lib/libcudnn_ops_train.so.8
/usr/local/cuda-10.2.89/targets/x86_64-linux/lib/libcudnn.so.8
/usr/local/cuda-10.2.89/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8
/usr/local/cuda-10.2.89/targets/x86_64-linux/lib/libcudnn_adv_train.so.8
/usr/local/cuda-10.2.89/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8
/usr/local/cuda-10.2.89/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8
/usr/local/cuda-10.2.89/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8
/usr/local/cuda-10.2.89/targets/x86_64-linux/lib/libcudnn_ops_train.so.8
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] numpy==1.19.2
[pip3] torch==1.8.0a0
[conda] magma-cuda102             2.5.2                         1    pytorch
[conda] mkl                       2020.2                      256    conda-forge
[conda] mkl-include               2020.2                      256    conda-forge
[conda] numpy                     1.19.2           py38hf89b668_1    conda-forge
[conda] torch                     1.8.0a0                  pypi_0    pypi
```

## Additional context

I think the non-optional value version is handled by this code:
https://github.com/pytorch/pytorch/blob/671ee71ad4b6f507218d1cad278a8e743780b716/torch/csrc/jit/frontend/schema_matching.cpp#L146-L153



cc @gmagogsfm