Repository: pytorch
Issue: torch.jit.script + torch.split + onnxruntime incompatibility
Labels: oncall: jit

### 🐛 Describe the bug

When jit scripting a model that uses a list of ints as the argument for `split_size_or_sections` with `torch.split` we get an error when trying to load the onnx model into an onnxruntime session. Presumably this is because onnxruntime is expecting a tensor as the "splits" argument, whereas PyTorch is expecting a list or tuple.

Is there a reason why this doesn't work for scripting, but appears to work for tracing? (based on [this](https://github.com/pytorch/pytorch/issues/65682) issue)

Thanks

```python
import torch            
import onnxruntime as ort 

class Model(torch.nn.Module):          

    def forward(self, x, splits):

        splits = [int(s) for s in splits]
        outputs = []
        for xi in torch.split(x, splits):
            outputs += [xi]
        
        outputs = torch.cat(outputs)
        return outputs

data =  {"x": torch.randn(7), "splits": torch.tensor([3,4])}

model = torch.jit.script(Model())
model.eval()

torch.onnx.export(model, (data["x"], data["splits"]), "tmp.onnx", opset_version=14,
                  input_names=["x", "splits"], dynamic_axes={"x":[0], "splits":[0]}, verbose=False, do_constant_folding=True)

sess = ort.InferenceSession("tmp.onnx", providers=["CPUExecutionProvider"])
```

```
---------------------------------------------------------------------------
InvalidGraph                              Traceback (most recent call last)
/tmp/ipykernel_2698/2817419627.py in <module>
     22                   input_names=["x", "splits"], dynamic_axes={"x":[0], "splits":[0]}, verbose=False, do_constant_folding=True)
     23 
---> 24 sess = ort.InferenceSession("tmp.onnx", providers=["CPUExecutionProvider"])

/venv/lib/python3.8/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py in __init__(self, path_or_bytes, sess_options, providers, provider_options, **kwargs)
    333 
    334         try:
--> 335             self._create_inference_session(providers, provider_options, disabled_optimizers)
    336         except ValueError:
    337             if self._enable_fallback:

/venv/lib/python3.8/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py in _create_inference_session(self, providers, provider_options, disabled_optimizers)
    366         session_options = self._sess_options if self._sess_options else C.get_default_session_options()
    367         if self._model_path:
--> 368             sess = C.InferenceSession(session_options, self._model_path, True, self._read_config_from_model)
    369         else:
    370             sess = C.InferenceSession(session_options, self._model_bytes, False, self._read_config_from_model)

InvalidGraph: [ONNXRuntimeError] : 10 : INVALID_GRAPH : Load model from tmp.onnx failed:This is an invalid model. Type Error: Type 'seq(tensor(int64))' of input parameter (9) of operator (SplitToSequence) in node (SplitToSequence_12) is invalid.
```

### Versions

```
Collecting environment information...
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.8.12 (default, Sep 10 2021, 00:16:05)  [GCC 7.5.0] (64-bit runtime)
Python platform: Linux-5.4.0-70-generic-x86_64-with-glibc2.27
Is CUDA available: False
CUDA runtime version: 11.2.152
GPU models and configuration: 
GPU 0: TITAN RTX
GPU 1: TITAN RTX
GPU 2: TITAN RTX
GPU 3: TITAN RTX
GPU 4: TITAN RTX
GPU 5: TITAN RTX
GPU 6: TITAN RTX
GPU 7: TITAN RTX

Nvidia driver version: 460.32.03
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.1.1
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.1.1
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.1.1
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.1.1
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.1.1
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.1.1
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.1.1
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.21.4
[pip3] pytorch-memlab==0.2.3
[pip3] torch==1.10.0a0+git36449ea
[pip3] torch-tb-profiler==0.3.1
[pip3] torchaudio==0.10.0a0+3bb5feb
[pip3] torchpq==0.1.8.3
[pip3] torchsummary==1.5.1
[pip3] torchvision==0.11.1
[conda] Could not collect
```