Attribute 'kernel_shape' is expected to have field 'ints' when exporting a module with `List[Tensor]` inputs/outputs
Labels: module: onnx, triaged

### 🐛 Describe the bug

Hi folks 👋 

I have a model that performs much better when I keep some of its states during inference. 

To do so, I have to accept a `List[Tensor]` as argument and return the new state in the output as well. I wasn't able to use it with `Tuple[Tensor,...]` because the amount of Tensors in the state might vary according to the model's configuration.

This is the error I have:

```sh
================ Diagnostic Run torch.onnx.export version 2.0.1 ================
verbose: False, log level: Level.ERROR
======================= 0 NONE 0 NOTE 0 WARNING 0 ERROR ========================

Traceback (most recent call last):
  File "/Users/.../repos/vendor/onnx-issue/.venv/lib/python3.11/site-packages/torch/onnx/utils.py", line 1636, in _export
    _C._check_onnx_proto(proto)
RuntimeError: Attribute 'kernel_shape' is expected to have field 'ints'

==> Context: Bad node spec for node. Name: /layer2/Conv OpType: Conv

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/.../repos/vendor/onnx-issue/example.py", line 77, in <module>
    export()
  File "/Users/.../repos/vendor/onnx-issue/example.py", line 44, in export
    torch.onnx.export(
  File "/Users/.../repos/vendor/onnx-issue/.venv/lib/python3.11/site-packages/torch/onnx/utils.py", line 506, in export
    _export(
  File "/Users/.../repos/vendor/onnx-issue/.venv/lib/python3.11/site-packages/torch/onnx/utils.py", line 1638, in _export
    raise errors.CheckerError(e) from e
torch.onnx.errors.CheckerError: Attribute 'kernel_shape' is expected to have field 'ints'

==> Context: Bad node spec for node. Name: /layer2/Conv OpType: Conv
```

To simplify its reproducibility I wrote a minimal setup:  https://github.com/rcelha/onnx-issue-example/blob/main/example.py

---

First I thought the issue was with varying size of tensors in the `aux` parameter, but I have the same issue in this other example: https://github.com/rcelha/onnx-issue-example/blob/main/example_same_len_aux.py

Here is a version of a similar model that works (without the `aux` argument): https://github.com/rcelha/onnx-issue-example/blob/main/example_working_module.py

---

Also, I noticed that does export the model if my conv1d has `bias=False`, but it will fail later when running the model:

```sh
================ Diagnostic Run torch.onnx.export version 2.0.1 ================
verbose: False, log level: Level.ERROR
======================= 0 NONE 0 NOTE 0 WARNING 0 ERROR ========================

2023-09-14 14:43:02.125355 [E:onnxruntime:, sequential_executor.cc:514 ExecuteKernel] Non-zero status code returned while running Conv node. Name:'/layer1/Conv' Status Message: kernel_shape is not compatible with W shape. kernel_shape: {100} W: {16,1,1} channels_last: 0
Traceback (most recent call last):
  File "/Users/.../repos/vendor/onnx-issue/example.py", line 78, in <module>
    test_inference()
  File "/Users/.../repos/vendor/onnx-issue/example.py", line 70, in test_inference
    ort_outputs = ort_session.run(None, ort_inputs)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../repos/vendor/onnx-issue/.venv/lib/python3.11/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 217, in run
    return self._sess.run(output_names, input_feed, run_options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ONNXRuntimeError] : 1 : FAIL : Non-zero status code returned while running Conv node. Name:'/layer1/Conv' Status Message: kernel_shape is not compatible with W shape. kernel_shape: {100} W: {16,1,1} channels_last: 0
```

### Versions

Collecting environment information...
PyTorch version: 2.0.1
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 14.0 (arm64)
GCC version: Could not collect
Clang version: 16.0.6
CMake version: version 3.26.3
Libc version: N/A

Python version: 3.11.5 (main, Aug 24 2023, 15:09:45) [Clang 14.0.3 (clang-1403.0.22.14.1)] (64-bit runtime)
Python platform: macOS-14.0-arm64-arm-64bit
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:
Apple M1 Max

Versions of relevant libraries:
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.25.2
[pip3] torch==2.0.1
[conda] Could not collect