Repository: pytorch
Issue: Failure to export scripted models to ONNX when input is a list of tensor
Labels: needs reproduction,module: onnx,triaged,onnx-needs-info

### 🐛 Describe the bug

Given the following example:

```python
import torch

class MyModule(torch.nn.Module):
    def __init__(self):
        super().__init__()
        self.a = torch.nn.Conv2d(512, 1024, kernel_size=1)
        self.b = torch.nn.Conv2d(512, 1024, kernel_size=1)

    def forward(self, features: list[torch.Tensor]) -> torch.Tensor:
        a = self.a(features[0])
        b = self.b(features[0])
        return a + b


input = [
    torch.randn((1, 512, 64, 64)),
    torch.randn((1, 512, 64, 64)),  # Removing this fixes the error.
]

# Create a scripted model.
model = MyModule()
model.eval()
model = torch.jit.script(model)

# Export to ONNX.
torch.onnx.export(
    model,
    (input,),
    'model.onnx',
    verbose=True,
)

# Test the model using ONNX.
import onnx
model = onnx.load('./model.onnx')
onnx.checker.check_model(model)

# Load the model using onnxruntime.
import onnxruntime
onnxruntime.InferenceSession('./model.onnx')
```

I get the following output:

```
Exported graph: graph(%features.1 : Float(1, 512, 64, 64, strides=[2097152, 4096, 64, 1], requires_grad=0, device=cpu)[],
      %a.weight : Float(1, 512, 64, 64, strides=[2097152, 4096, 64, 1], requires_grad=0, device=cpu),
      %a.bias : Float(1024, 512, 1, 1, strides=[512, 1, 1, 1], requires_grad=0, device=cpu),
      %b.weight : Float(1024, strides=[1], requires_grad=0, device=cpu),
      %b.bias : Float(1024, 512, 1, 1, strides=[512, 1, 1, 1], requires_grad=0, device=cpu)):
  %/Constant_output_0 : Long(device=cpu) = onnx::Constant[value={0}, onnx_name="/Constant"](), scope: MyModule::
  %/SequenceAt_output_0 : Float(1, 512, 64, 64, strides=[2097152, 4096, 64, 1], device=cpu) = onnx::SequenceAt[onnx_name="/SequenceAt"](%features.1, %/Constant_output_0), scope: MyModule:: # /tmp/2022-10-27-15-20-00/test.py:10:19
  %/a/Conv_output_0 : Float(1, 1024, 1, 1, strides=[1, 1, 1, 1], device=cpu) = onnx::Conv[dilations=[1, 1], group=1, kernel_shape=[64, 64], pads=[0, 0, 0, 0], strides=[1, 1], onnx_name="/a/Conv"](%/SequenceAt_output_0, %a.weight), scope: MyModule::/torch.nn.modules.conv.Conv2d::a # /usr/lib/python3.10/site-packages/torch/nn/modules/conv.py:459:15
  %/a/Add_output_0 : Float(1024, 1024, 1, 1, strides=[512, 1, 1, 1], device=cpu) = onnx::Add[onnx_name="/a/Add"](%/a/Conv_output_0, %a.bias), scope: MyModule::/torch.nn.modules.conv.Conv2d::a # /usr/lib/python3.10/site-packages/torch/nn/modules/conv.py:459:15
  %/b/Conv_output_0 : Tensor = onnx::Conv[dilations=[1, 1], group=1, kernel_shape=annotate(List[int], []), pads=[0, 0, 0, 0], strides=[1, 1], onnx_name="/b/Conv"](%/SequenceAt_output_0, %b.weight), scope: MyModule::/torch.nn.modules.conv.Conv2d::b # /usr/lib/python3.10/site-packages/torch/nn/modules/conv.py:459:15
  %/b/Add_output_0 : FloatTensor = onnx::Add[onnx_name="/b/Add"](%/b/Conv_output_0, %b.bias), scope: MyModule::/torch.nn.modules.conv.Conv2d::b # /usr/lib/python3.10/site-packages/torch/nn/modules/conv.py:459:15
  %11 : Float(*, *, *, *, strides=[4194304, 4096, 64, 1], requires_grad=1, device=cpu) = onnx::Add[onnx_name="/Add"](%/a/Add_output_0, %/b/Add_output_0), scope: MyModule:: # /tmp/2022-10-27-15-20-00/test.py:12:15
  return (%11)

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/torch/onnx/utils.py", line 1652, in _export
    _C._check_onnx_proto(proto, full_check=True)
RuntimeError: Attribute 'kernel_shape' is expected to have field 'ints'

==> Context: Bad node spec for node. Name: /b/Conv OpType: Conv

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/2022-10-27-15-20-00/test.py", line 27, in <module>
    torch.onnx.export(
  File "/usr/lib/python3.10/site-packages/torch/onnx/utils.py", line 504, in export
    _export(
  File "/usr/lib/python3.10/site-packages/torch/onnx/utils.py", line 1654, in _export
    raise errors.CheckerError(e)
torch.onnx.errors.CheckerError: Attribute 'kernel_shape' is expected to have field 'ints'

==> Context: Bad node spec for node. Name: /b/Conv OpType: Conv
```

Interestingly, if I remove one of the two inputs so that there is only one input (still as a list) then the error disappears. 

Also, if I don't script the model, so that it traces before conversion, then there is no error either. However, this is not what I want because my input has dynamic shapes and as far as I know this does not work well with traced models (or am I wrong here?). Regardless, this seems to be an issue for scripted models.

An additional observation: if I remove `self.b` entirely and just return the output of `self.a`, then I get the following error:

```
[ShapeInferenceError] Inferred shape and existing shape differ in dimension 0: (1) vs (1024)
```

Which also disappears if I use tracing instead of scripting.

### Versions

I tried this both on 1.12.1 from the Arch repositories, as well as the current `master` branch, both provided the same results.

```
PyTorch version: 1.14.0a0+git1780e0e
Is debug build: False
CUDA used to build PyTorch: Could not collect
ROCM used to build PyTorch: N/A

OS: Arch Linux (x86_64)
GCC version: (GCC) 12.2.0
Clang version: 14.0.6
CMake version: version 3.24.2
Libc version: glibc-2.36

Python version: 3.10.8 (main, Oct 13 2022, 21:13:48) [GCC 12.2.0] (64-bit runtime)
Python platform: Linux-5.15.75-1-lts-x86_64-with-glibc2.36
Is CUDA available: False
CUDA runtime version: 11.8.89
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3060 Laptop GPU
Nvidia driver version: 520.56.06
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] efficientnet-pytorch==0.7.1
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.23.4
[pip3] segmentation-models-pytorch==0.3.0
[pip3] torch==1.14.0a0+git1780e0e
[conda] Could not collect
```