abnormal behavior in function "scatter"
Labels: triaged, module: python frontend

### 🐛 Describe the bug


I have encountered a weird bug, when I use "scatter_max", "scatter_min", "scatter_mul" to deal specifical data, the function could not return expected output. I have no ideal whether I incorrectedly use this function or it have some defact.


```python
import torch
from torch_geometric.utils import scatter

w = torch.load(r'test_tensor.pth')
mu_ConnG = w["mu"].to("cuda")
batch = w["index"].to("cuda")
y = scatter(mu_ConnG, index=batch, dim=0,  reduce="max")
```
The excepted output is:

```python
tensor([[[1.2849e-01, 9.5606e-01, 3.1864e-02],
         [2.5623e-02, 9.2980e-01, 1.5113e-01],
         [6.6616e-03, 7.0254e-01, 3.3186e-01],
         [3.6990e-01, 6.5781e-01, 5.2398e-03],
         [6.1730e-01, 4.0564e-01, 1.1939e-03]],

        [[7.1755e-01, 3.1940e-01, 6.3681e-04],
         [3.2621e-03, 5.7120e-01, 4.4799e-01],
         [2.2195e-01, 8.4002e-01, 1.4240e-02],
         [2.8383e-03, 5.4655e-01, 4.7142e-01],
         [3.1675e-02, 9.5541e-01, 1.2908e-01]],

        [[7.4156e-01, 2.9976e-01, 5.4273e-04],
         [1.6149e-04, 1.7957e-01, 8.9443e-01],
         [6.2777e-05, 1.1652e-01, 9.6872e-01],
         [7.6054e-02, 9.9845e-01, 5.8712e-02],
         [9.3553e-01, 1.4634e-01, 1.0254e-04]],

        ...,

        [[8.4811e-03, 7.4741e-01, 2.9502e-01],
         [6.3141e-01, 3.9305e-01, 1.0959e-03],
         [1.5108e-03, 4.4157e-01, 5.7807e-01],
         [1.4651e-01, 9.3534e-01, 2.6747e-02],
         [2.9298e-02, 9.4651e-01, 1.3697e-01]],

        [[8.4811e-03, 7.4741e-01, 2.9502e-01],
         [6.3141e-01, 3.9305e-01, 1.0959e-03],
         [1.5108e-03, 4.4157e-01, 5.7807e-01],
         [1.4651e-01, 9.3534e-01, 2.6747e-02],
         [2.9298e-02, 9.4651e-01, 1.3697e-01]],

        [[2.3792e-02, 9.1984e-01, 1.5929e-01],
         [3.7287e-01, 6.5439e-01, 5.1442e-03],
         [6.9620e-02, 9.9985e-01, 6.4318e-02],
         [8.0458e-05, 1.3087e-01, 9.5342e-01],
         [4.1389e-04, 2.6855e-01, 7.8049e-01]]], device='cuda:0',
       grad_fn=<CopySlices>)
```
however I got:

```python
tensor([[[0., 0., 0.],
         [0., 0., 0.],
         [0., 0., 0.],
         [0., 0., 0.],
         [0., 0., 0.]],

        [[0., 0., 0.],
         [0., 0., 0.],
         [0., 0., 0.],
         [0., 0., 0.],
         [0., 0., 0.]],

        [[0., 0., 0.],
         [0., 0., 0.],
         [0., 0., 0.],
         [0., 0., 0.],
         [0., 0., 0.]],

        ...,

        [[0., 0., 0.],
         [0., 0., 0.],
         [0., 0., 0.],
         [0., 0., 0.],
         [0., 0., 0.]],

        [[0., 0., 0.],
         [0., 0., 0.],
         [0., 0., 0.],
         [0., 0., 0.],
         [0., 0., 0.]],

        [[0., 0., 0.],
         [0., 0., 0.],
         [0., 0., 0.],
         [0., 0., 0.],
         [0., 0., 0.]]], device='cuda:0', grad_fn=<CppNode<class ScatterMax>>)
```
this problem is also occur in "scatter_min" and "scatter_mul".

Here the "test_tensor.pth" is on below link (before you load it, you have to modify the file suffix name to ".pth"):
[test_tensor.txt](https://github.com/pytorch/pytorch/files/11781987/test_tensor.txt)

Here I create a simple test case:

```python


mu_ConnG = torch.Tensor([
    [[1e-3, 2, 3],
     [1, 5, 6]],

    [[4e-4, 8, 9],
     [10, 11, 12]],

    [[13, 14, 15],
     [18, 17, 16]],

    [[100, 8, 9],
     [10, 19, 12]],

    [[100, 8, 9],
     [99, 19, 12]],

    [[4583, 456, 9],
     [10, 19, 1]],
]).double().to("cuda")

batch = torch.LongTensor([0, 0, 1, 1, 2, 0]).to("cuda")
y1 = scatter(mu_ConnG, index=batch, dim=0,  reduce="max")
y2 = scatter_max(mu_ConnG, index=batch, dim=0)
```
I have found that "scatter" and "scatter_max" will return different result:

*scatter()*

```python

tensor([[[4583.,  456.,    9.],
         [  10.,   19.,   12.]],

        [[ 100.,   14.,   15.],
         [  18.,   19.,   16.]],

        [[ 100.,    8.,    9.],
         [  99.,   19.,   12.]]], device='cuda:0', dtype=torch.float64)
```

*scatter_max()*

```python
(tensor([[[0., 0., 0.],
         [0., 0., 0.]],

        [[0., 0., 0.],
         [0., 0., 0.]],

        [[0., 0., 0.],
         [0., 0., 0.]]], device='cuda:0', dtype=torch.float64)
```

I am sure "scatter()" return the correct result. I still do not know why occur this situation. 



### Versions

python                   3.9
torch                      2.0.1+cu118
torch-geometric    2.3.1
torch-scatter         2.1.1
torch-sparse         0.6.17



cc @albanD