Repository: pyg-team/pytorch_geometric

Issue:
Batch.from_data_list seems to give different batch results depending on attribute name
### 🐛 Describe the bug

Hi, when using the `torch_geometric.data.Batch` and `torch_geometric.data.Data` class to organize my graph information, I realized the following feature:
```python
import torch
import torch_geometric
from torch_geometric.data import Data, Batch

data_list = []
for i in range(3):
    data = Data(x=torch.randn(5, 3))
    data.image_index = torch.ones(5)
    data_list.append(data)
    
batch = Batch.from_data_list(data_list)
print(batch.image_index)
# Gives tensor([ 1.,  1.,  1.,  1.,  1.,  6.,  6.,  6.,  6.,  6., 11., 11., 11., 11., 11.])

data_list = []
for i in range(3):
    data = Data(x=torch.randn(5, 3))
    data.foo = torch.ones(5)
    data_list.append(data)
    
batch = Batch.from_data_list(data_list)
print(batch.foo)
# Gives tensor([1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.])
``` 

So it seems that one can get different "batched" results depending on the name of the attribute to which one stores the information. In fact, it seems one gets the former behavior when the string `index` is contained in the attribute name. Was this feature put in place by intention? FYI, I'm using verion `2.2.0`

### Environment

* PyG version: `2.2.0`
* PyTorch version: `1.13.1+cu116`
* OS: Linux
* Python version: `3.8.10`
* CUDA/cuDNN version: `cu116`
* How you installed PyTorch and PyG (`conda`, `pip`, source): `pip`
* Any other relevant information (*e.g.*, version of `torch-scatter`):



Discussion:
Yes, this is intended and is controlled by `Data.__cat_dim__`:
```python
>>> Data().__cat_dim__('image_index', torch.ones(5,3))
-1
>>> Data().__cat_dim__('foo', torch.ones(5,3))
0
```

Yes, you can either rename your attribute or override `__inc__`. 
I see, thanks for the clarification--but should this be standard practice? I tend to think of this as "unexpected behavior", especially given that it does not flag any warnings or messages when setting attributes names containing the string "index". I think either it should flag a warning or block users from setting attribute names containing the string "index"--instead of changing the contents silently. 
Yeah, this is a design decision we made pretty early on, and it is hard to change now. I definitely agree that this can feel like "magic". How would you like us to add a warning? There should at least exist a convenient way to turn this off it the behavior is indeed desired.
I see, in that case I agree that there's no ideal solution. Maybe a disclaimer on the documentation for `Batch` and `Data` would suffice?
Let me do this :)

Resolving patch:
diff --git a/torch_geometric/data/batch.py b/torch_geometric/data/batch.py
--- a/torch_geometric/data/batch.py
+++ b/torch_geometric/data/batch.py
@@ -60,6 +60,23 @@ class Batch(metaclass=DynamicInheritance):
     :class:`torch_geometric.data.HeteroData`.
     In addition, single graphs can be identified via the assignment vector
     :obj:`batch`, which maps each node to its respective graph identifier.
+
+    :pyg:`PyG` allows modification to the underlying batching procedure by
+    overwriting the :meth:`~Data.__inc__` and :meth:`~Data.__cat_dim__`
+    functionalities.
+    The :meth:`~Data.__inc__` method defines the incremental count between two
+    consecutive graph attributes.
+    By default, :pyg:`PyG` increments attributes by the number of nodes
+    whenever their attribute names contain the substring :obj:`index`
+    (for historical reasons), which comes in handy for attributes such as
+    :obj:`edge_index` or :obj:`node_index`.
+    However, note that this may lead to unexpected behavior for attributes
+    whose names contain the substring :obj:`index` but should not be
+    incremented.
+    To make sure, it is best practice to always double-check the output of
+    batching.
+    Furthermore, :meth:`~Data.__cat_dim__` defines in which dimension graph
+    tensors of the same attribute should be concatenated together.
     """
     @classmethod
     def from_data_list(cls, data_list: List[BaseData],


Test patch: