Incompatible dimensions error for FusedMatMul
Labels: module: onnx, triaged

### 🐛 Describe the bug

I am getting a `[ShapeInferenceError] Incompatible dimensions for matrix multiplication` error when attempting to load an ONNX model. 

```
Traceback (most recent call last):
  File "/Users/jajal/research/exporter_testing/bugs/torch/bug_1/repro_jit.py", line 11, in <module>
    ort.InferenceSession("./model.onnx", providers=["CPUExecutionProvider"])
  File "/Users/jajal/anaconda3/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 419, in __init__
    self._create_inference_session(providers, provider_options, disabled_optimizers)
  File "/Users/jajal/anaconda3/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 471, in _create_inference_session
    sess.initialize_session(providers, provider_options, disabled_optimizers)
onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ONNXRuntimeError] : 1 : FAIL : Node (/MatMul_FusedMatMulAndScale) Op (FusedMatMul) [ShapeInferenceError] Incompatible dimensions for matrix multiplication
```


This appears similar to this ONNXRuntime issue [microsoft/onnxruntime#7098](https://github.com/microsoft/onnxruntime/issues/7098) and PyTorch #55597 . 

I found this using the [NNSmith Fuzzing Tool](https://github.com/ise-uiuc/nnsmith) on the `torch.onnx` converter. Due to the way NNSmith creates models I am unable to provide a minimal reproduction but I was able to trace the model and have the TorchScript version of it ([here](https://drive.google.com/file/d/1m5ouLOA5ZbIOEmF-eg55uXJ6x6g05t_9/view?usp=sharing)). 

The reproduction requires the download of: [model](https://drive.google.com/file/d/1m5ouLOA5ZbIOEmF-eg55uXJ6x6g05t_9/view?usp=drive_link) and [inputs](https://drive.google.com/file/d/1cygSJOsJJdP6IXpKyJArMeexDZPXOhi-/view?usp=drive_link). After the download execute the following:

```python
import onnxruntime as ort
import torch


model_args = torch.load("model_args.pt")
loaded = torch.jit.load("traced_model.pt")


torch.onnx.export(loaded, model_args, "./model.onnx", opset_version=16)

ort.InferenceSession("./model.onnx", providers=["CPUExecutionProvider"])
```

### Versions

PyTorch version: 2.0.1
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 13.5.2 (arm64)
GCC version: Could not collect
Clang version: 15.0.0 (clang-1500.0.40.1)
CMake version: version 3.27.5
Libc version: N/A

Python version: 3.10.13 (main, Sep 11 2023, 08:16:02) [Clang 14.0.6 ] (64-bit runtime)
Python platform: macOS-13.5.2-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

Versions of relevant libraries:
[pip3] numpy==1.25.2
[pip3] pytorch-lightning==2.0.3
[pip3] torch==2.0.1
[pip3] torch-tb-profiler==0.4.1
[pip3] torchaudio==2.0.0
[pip3] torchdata==0.6.1
[pip3] torchmetrics==0.11.4
[pip3] torchtext==0.15.2
[pip3] torchvision==0.15.0
[pip3] torchviz==0.0.2
[conda] numpy                     1.25.2          py310h3b2db8e_0  
[conda] numpy-base                1.25.2          py310ha9811e2_0  
[conda] pytorch-lightning         2.0.3                    pypi_0    pypi
[conda] torch                     2.0.1                    pypi_0    pypi
[conda] torch-tb-profiler         0.4.1                    pypi_0    pypi
[conda] torchaudio                2.0.0                 py310_cpu    pytorch
[conda] torchdata                 0.6.1                    pypi_0    pypi
[conda] torchmetrics              0.11.4                   pypi_0    pypi
[conda] torchtext                 0.15.2                   pypi_0    pypi
[conda] torchvision               0.15.0                py310_cpu    pytorch
[conda] torchviz                  0.0.2                    pypi_0    pypi