Repository: pytorch
Issue: [ONNX] AssertionError: A mismatch between the number of arguments (5) and their descriptors (4) was found at symbolic function 'scatter'
Labels: needs reproduction,module: onnx,triaged

### 🐛 Describe the bug

Dear experts:

Thanks for your dedication to the great project pytorch. I was intended to use scatter_add_ and scatter_ where reduce is 'multiply' ([TORCH.TENSOR.SCATTER_](https://pytorch.org/docs/stable/generated/torch.Tensor.scatter_.html)) to achieve torch.scatter_reduce mean ops  which is not supported currently [[ONNX] Support aten::scatter_reduce](https://github.com/pytorch/pytorch/issues/84260).

However, when I uesd torch.onnx.export() function to try to convert .pt model to .onnx model, I got the error : " AssertionError: A mismatch between the number of arguments (5) and their descriptors (4) was found at symbolic function 'scatter'". It turns out that scatter_(dim, index, src, reduce='multiply') is wrong

I simplified my code as follows：

```python
import torch
import torch.nn as nn
from torch.onnx import utils as onnx_utils


class Model(nn.Module):
    def __init__(self):
        super(Model, self).__init__()

    def forward(self, x, index, ratio):
        print("x: ", x)
        print("index: ", index)
        print("ratio: ", ratio)

        index = index.unsqueeze(-1).expand_as(x)

        # not supported yet
        # y_mean_with_scatter_reduce = torch.zeros_like(x).scatter_reduce(1, index, x, reduce="mean", include_self=False)
        # print("y_mean with scatter_reduce and slice: ", y_mean_with_scatter_reduce[:, :index.max()+1, :])

        y_sum = torch.zeros((index.shape[0], index.max() + 1, index.shape[-1]), dtype=x.dtype).scatter_add_(1, index, x)
        print("y_sum: ", y_sum)

        ratio = ratio.unsqueeze(-1).expand_as(y_sum)
        ratio = torch.ones_like(ratio) / ratio
        index_mul = torch.tensor(range(index.max() + 1)).unsqueeze(1).expand_as(y_sum)
        y_mean = y_sum.to(dtype=ratio.dtype).scatter_(1, index_mul, ratio, reduce='multiply')
        print("y_mean: ", y_mean)

        return y_mean


model = Model()
model.eval()

x = torch.tensor(range(48)).view((2,6,4))
index = torch.tensor([[0,1,1,2,2,2], [0,1,2,3,3,4]])
ratio = torch.tensor([[1,2,3,float('inf'),float('inf')], [1,1,1,2,1]])

args = (x, index, ratio)
opset_version=16

model(x, index, ratio)

torch.onnx.export(model, args, 'model.onnx', opset_version=opset_version)
```

The model output is the same as I expect like follows:

```
x:  tensor([[[ 0,  1,  2,  3],
         [ 4,  5,  6,  7],
         [ 8,  9, 10, 11],
         [12, 13, 14, 15],
         [16, 17, 18, 19],
         [20, 21, 22, 23]],

        [[24, 25, 26, 27],
         [28, 29, 30, 31],
         [32, 33, 34, 35],
         [36, 37, 38, 39],
         [40, 41, 42, 43],
         [44, 45, 46, 47]]])

y_mean:  tensor([[[ 0.,  1.,  2.,  3.],
         [ 6.,  7.,  8.,  9.],
         [16., 17., 18., 19.],
         [ 0.,  0.,  0.,  0.],
         [ 0.,  0.,  0.,  0.]],

        [[24., 25., 26., 27.],
         [28., 29., 30., 31.],
         [32., 33., 34., 35.],
         [38., 39., 40., 41.],
         [44., 45., 46., 47.]]])
```
But torch.onnx.export() shows the error information as follows:

```
Traceback (most recent call last):
  File "onnx_export_test.py", line 45, in <module>
    torch.onnx.export(model, args, 'model.onnx', opset_version=opset_version)
  File "/mnt/workspace/workgroup/anaconda3/envs/torch1.12/lib/python3.8/site-packages/torch/onnx/__init__.py", line 350, in export
    return utils.export(
  File "/mnt/workspace/workgroup/anaconda3/envs/torch1.12/lib/python3.8/site-packages/torch/onnx/utils.py", line 163, in export
    _export(
  File "/mnt/workspace/workgroup/anaconda3/envs/torch1.12/lib/python3.8/site-packages/torch/onnx/utils.py", line 1074, in _export
    graph, params_dict, torch_out = _model_to_graph(
  File "/mnt/workspace/workgroup/anaconda3/envs/torch1.12/lib/python3.8/site-packages/torch/onnx/utils.py", line 731, in _model_to_graph
    graph = _optimize_graph(
  File "/mnt/workspace/workgroup/anaconda3/envs/torch1.12/lib/python3.8/site-packages/torch/onnx/utils.py", line 308, in _optimize_graph
    graph = _C._jit_pass_onnx(graph, operator_export_type)
  File "/mnt/workspace/workgroup/anaconda3/envs/torch1.12/lib/python3.8/site-packages/torch/onnx/__init__.py", line 416, in _run_symbolic_function
    return utils._run_symbolic_function(*args, **kwargs)
  File "/mnt/workspace/workgroup/anaconda3/envs/torch1.12/lib/python3.8/site-packages/torch/onnx/utils.py", line 1406, in _run_symbolic_function
    return symbolic_fn(g, *inputs, **attrs)
  File "/mnt/workspace/workgroup/anaconda3/envs/torch1.12/lib/python3.8/site-packages/torch/onnx/symbolic_helper.py", line 204, in wrapper
    assert len(arg_descriptors) >= len(args), (
AssertionError: A mismatch between the number of arguments (5) and their descriptors (4) was found at symbolic function 'scatter'. If you believe this is not due to custom symbolic implementation within your code or an external library, please file an issue at https://github.com/pytorch/pytorch/issues/new?template=bug-report.yml to report this bug.
```

Additionally, I wanna ask when do you plan to be able to support scatter_reduce ops. Thanks a lot!

### Versions

torch                   1.12.0+cu102
onnx                    1.12.0
onnxconverter-common    1.12.2
onnxruntime             1.12.1
onnxruntime-tools       1.7.0
tf2onnx                 1.12.1