We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
TypeError: global_add_pool() missing 1 required positional argument: 'batch'
### 🐛 Describe the bug

The documentation of `global_add_pool ` states that the batch parameter is optional, however I get this error ```TypeError: global_add_pool() missing 1 required positional argument: 'batch'``` when I don't pass a value for the batch. 

Here is a snippet of code to reproduce the bug:
```Python
import torch
from torch_geometric.nn import global_add_pool
x = torch.zeros(4,5)
z = global_add_pool(x)
```

I think the origin of the issue is the absence of a default value for the batch parameter in the definition of `global_add_pool`.
And the same bug happens when using `global_mean_pool` or `global_max_pool`.

### Environment

* PyG version: 2.0.5
* PyTorch version: 1.11.0
* OS:  Fedora release 35
* Python version: 3.9
* CUDA/cuDNN version: 11.3
* How you installed PyTorch and PyG (`conda`, `pip`, source): Poetry


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `torch_geometric/nn/glob/glob.py`
Content:
```
1 from typing import List, Optional, Union
2 
3 import torch
4 from torch import Tensor
5 from torch_scatter import scatter
6 
7 
8 def global_add_pool(x: Tensor, batch: Optional[Tensor],
9                     size: Optional[int] = None) -> Tensor:
10     r"""Returns batch-wise graph-level-outputs by adding node features
11     across the node dimension, so that for a single graph
12     :math:`\mathcal{G}_i` its output is computed by
13 
14     .. math::
15         \mathbf{r}_i = \sum_{n=1}^{N_i} \mathbf{x}_n
16 
17     Args:
18         x (Tensor): Node feature matrix
19             :math:`\mathbf{X} \in \mathbb{R}^{(N_1 + \ldots + N_B) \times F}`.
20         batch (LongTensor, optional): Batch vector
21             :math:`\mathbf{b} \in {\{ 0, \ldots, B-1\}}^N`, which assigns each
22             node to a specific example.
23         size (int, optional): Batch-size :math:`B`.
24             Automatically calculated if not given. (default: :obj:`None`)
25     """
26     if batch is None:
27         return x.sum(dim=0, keepdim=True)
28     size = int(batch.max().item() + 1) if size is None else size
29     return scatter(x, batch, dim=0, dim_size=size, reduce='add')
30 
31 
32 def global_mean_pool(x: Tensor, batch: Optional[Tensor],
33                      size: Optional[int] = None) -> Tensor:
34     r"""Returns batch-wise graph-level-outputs by averaging node features
35     across the node dimension, so that for a single graph
36     :math:`\mathcal{G}_i` its output is computed by
37 
38     .. math::
39         \mathbf{r}_i = \frac{1}{N_i} \sum_{n=1}^{N_i} \mathbf{x}_n
40 
41     Args:
42         x (Tensor): Node feature matrix
43             :math:`\mathbf{X} \in \mathbb{R}^{(N_1 + \ldots + N_B) \times F}`.
44         batch (LongTensor, optional): Batch vector
45             :math:`\mathbf{b} \in {\{ 0, \ldots, B-1\}}^N`, which assigns each
46             node to a specific example.
47         size (int, optional): Batch-size :math:`B`.
48             Automatically calculated if not given. (default: :obj:`None`)
49     """
50     if batch is None:
51         return x.mean(dim=0, keepdim=True)
52     size = int(batch.max().item() + 1) if size is None else size
53     return scatter(x, batch, dim=0, dim_size=size, reduce='mean')
54 
55 
56 def global_max_pool(x: Tensor, batch: Optional[Tensor],
57                     size: Optional[int] = None) -> Tensor:
58     r"""Returns batch-wise graph-level-outputs by taking the channel-wise
59     maximum across the node dimension, so that for a single graph
60     :math:`\mathcal{G}_i` its output is computed by
61 
62     .. math::
63         \mathbf{r}_i = \mathrm{max}_{n=1}^{N_i} \, \mathbf{x}_n
64 
65     Args:
66         x (Tensor): Node feature matrix
67             :math:`\mathbf{X} \in \mathbb{R}^{(N_1 + \ldots + N_B) \times F}`.
68         batch (LongTensor, optional): Batch vector
69             :math:`\mathbf{b} \in {\{ 0, \ldots, B-1\}}^N`, which assigns each
70             node to a specific example.
71         size (int, optional): Batch-size :math:`B`.
72             Automatically calculated if not given. (default: :obj:`None`)
73     """
74     if batch is None:
75         return x.max(dim=0, keepdim=True)[0]
76     size = int(batch.max().item() + 1) if size is None else size
77     return scatter(x, batch, dim=0, dim_size=size, reduce='max')
78 
79 
80 class GlobalPooling(torch.nn.Module):
81     r"""A global pooling module that wraps the usage of
82     :meth:`~torch_geometric.nn.glob.global_add_pool`,
83     :meth:`~torch_geometric.nn.glob.global_mean_pool` and
84     :meth:`~torch_geometric.nn.glob.global_max_pool` into a single module.
85 
86     Args:
87         aggr (string or List[str]): The aggregation scheme to use
88             (:obj:`"add"`, :obj:`"mean"`, :obj:`"max"`).
89             If given as a list, will make use of multiple aggregations in which
90             different outputs will get concatenated in the last dimension.
91     """
92     def __init__(self, aggr: Union[str, List[str]]):
93         super().__init__()
94 
95         self.aggrs = [aggr] if isinstance(aggr, str) else aggr
96 
97         assert len(self.aggrs) > 0
98         assert len(set(self.aggrs) | {'sum', 'add', 'mean', 'max'}) == 4
99 
100     def forward(self, x: Tensor, batch: Optional[Tensor],
101                 size: Optional[int] = None) -> Tensor:
102         """"""
103         xs: List[Tensor] = []
104 
105         for aggr in self.aggrs:
106             if aggr == 'sum' or aggr == 'add':
107                 xs.append(global_add_pool(x, batch, size))
108             elif aggr == 'mean':
109                 xs.append(global_mean_pool(x, batch, size))
110             elif aggr == 'max':
111                 xs.append(global_max_pool(x, batch, size))
112 
113         return xs[0] if len(xs) == 1 else torch.cat(xs, dim=-1)
114 
115     def __repr__(self) -> str:
116         aggr = self.aggrs[0] if len(self.aggrs) == 1 else self.aggrs
117         return f'{self.__class__.__name__}(aggr={aggr})'
118
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/torch_geometric/nn/glob/glob.py b/torch_geometric/nn/glob/glob.py
--- a/torch_geometric/nn/glob/glob.py
+++ b/torch_geometric/nn/glob/glob.py
@@ -24,9 +24,9 @@
             Automatically calculated if not given. (default: :obj:`None`)
     """
     if batch is None:
-        return x.sum(dim=0, keepdim=True)
+        return x.sum(dim=-2, keepdim=x.dim() == 2)
     size = int(batch.max().item() + 1) if size is None else size
-    return scatter(x, batch, dim=0, dim_size=size, reduce='add')
+    return scatter(x, batch, dim=-2, dim_size=size, reduce='add')
 
 
 def global_mean_pool(x: Tensor, batch: Optional[Tensor],
@@ -48,9 +48,9 @@
             Automatically calculated if not given. (default: :obj:`None`)
     """
     if batch is None:
-        return x.mean(dim=0, keepdim=True)
+        return x.mean(dim=-2, keepdim=x.dim() == 2)
     size = int(batch.max().item() + 1) if size is None else size
-    return scatter(x, batch, dim=0, dim_size=size, reduce='mean')
+    return scatter(x, batch, dim=-2, dim_size=size, reduce='mean')
 
 
 def global_max_pool(x: Tensor, batch: Optional[Tensor],
@@ -72,9 +72,9 @@
             Automatically calculated if not given. (default: :obj:`None`)
     """
     if batch is None:
-        return x.max(dim=0, keepdim=True)[0]
+        return x.max(dim=-2, keepdim=x.dim() == 2)[0]
     size = int(batch.max().item() + 1) if size is None else size
-    return scatter(x, batch, dim=0, dim_size=size, reduce='max')
+    return scatter(x, batch, dim=-2, dim_size=size, reduce='max')
 
 
 class GlobalPooling(torch.nn.Module):

{"golden_diff": "diff --git a/torch_geometric/nn/glob/glob.py b/torch_geometric/nn/glob/glob.py\n--- a/torch_geometric/nn/glob/glob.py\n+++ b/torch_geometric/nn/glob/glob.py\n@@ -24,9 +24,9 @@\n             Automatically calculated if not given. (default: :obj:`None`)\n     \"\"\"\n     if batch is None:\n-        return x.sum(dim=0, keepdim=True)\n+        return x.sum(dim=-2, keepdim=x.dim() == 2)\n     size = int(batch.max().item() + 1) if size is None else size\n-    return scatter(x, batch, dim=0, dim_size=size, reduce='add')\n+    return scatter(x, batch, dim=-2, dim_size=size, reduce='add')\n \n \n def global_mean_pool(x: Tensor, batch: Optional[Tensor],\n@@ -48,9 +48,9 @@\n             Automatically calculated if not given. (default: :obj:`None`)\n     \"\"\"\n     if batch is None:\n-        return x.mean(dim=0, keepdim=True)\n+        return x.mean(dim=-2, keepdim=x.dim() == 2)\n     size = int(batch.max().item() + 1) if size is None else size\n-    return scatter(x, batch, dim=0, dim_size=size, reduce='mean')\n+    return scatter(x, batch, dim=-2, dim_size=size, reduce='mean')\n \n \n def global_max_pool(x: Tensor, batch: Optional[Tensor],\n@@ -72,9 +72,9 @@\n             Automatically calculated if not given. (default: :obj:`None`)\n     \"\"\"\n     if batch is None:\n-        return x.max(dim=0, keepdim=True)[0]\n+        return x.max(dim=-2, keepdim=x.dim() == 2)[0]\n     size = int(batch.max().item() + 1) if size is None else size\n-    return scatter(x, batch, dim=0, dim_size=size, reduce='max')\n+    return scatter(x, batch, dim=-2, dim_size=size, reduce='max')\n \n \n class GlobalPooling(torch.nn.Module):\n", "issue": "TypeError: global_add_pool() missing 1 required positional argument: 'batch'\n### \ud83d\udc1b Describe the bug\n\nThe documentation of `global_add_pool ` states that the batch parameter is optional, however I get this error ```TypeError: global_add_pool() missing 1 required positional argument: 'batch'``` when I don't pass a value for the batch. \r\n\r\nHere is a snippet of code to reproduce the bug:\r\n```Python\r\nimport torch\r\nfrom torch_geometric.nn import global_add_pool\r\nx = torch.zeros(4,5)\r\nz = global_add_pool(x)\r\n```\r\n\r\nI think the origin of the issue is the absence of a default value for the batch parameter in the definition of `global_add_pool`.\r\nAnd the same bug happens when using `global_mean_pool` or `global_max_pool`.\n\n### Environment\n\n* PyG version: 2.0.5\r\n* PyTorch version: 1.11.0\r\n* OS:  Fedora release 35\r\n* Python version: 3.9\r\n* CUDA/cuDNN version: 11.3\r\n* How you installed PyTorch and PyG (`conda`, `pip`, source): Poetry\r\n\n", "before_files": [{"content": "from typing import List, Optional, Union\n\nimport torch\nfrom torch import Tensor\nfrom torch_scatter import scatter\n\n\ndef global_add_pool(x: Tensor, batch: Optional[Tensor],\n                    size: Optional[int] = None) -> Tensor:\n    r\"\"\"Returns batch-wise graph-level-outputs by adding node features\n    across the node dimension, so that for a single graph\n    :math:`\\mathcal{G}_i` its output is computed by\n\n    .. math::\n        \\mathbf{r}_i = \\sum_{n=1}^{N_i} \\mathbf{x}_n\n\n    Args:\n        x (Tensor): Node feature matrix\n            :math:`\\mathbf{X} \\in \\mathbb{R}^{(N_1 + \\ldots + N_B) \\times F}`.\n        batch (LongTensor, optional): Batch vector\n            :math:`\\mathbf{b} \\in {\\{ 0, \\ldots, B-1\\}}^N`, which assigns each\n            node to a specific example.\n        size (int, optional): Batch-size :math:`B`.\n            Automatically calculated if not given. (default: :obj:`None`)\n    \"\"\"\n    if batch is None:\n        return x.sum(dim=0, keepdim=True)\n    size = int(batch.max().item() + 1) if size is None else size\n    return scatter(x, batch, dim=0, dim_size=size, reduce='add')\n\n\ndef global_mean_pool(x: Tensor, batch: Optional[Tensor],\n                     size: Optional[int] = None) -> Tensor:\n    r\"\"\"Returns batch-wise graph-level-outputs by averaging node features\n    across the node dimension, so that for a single graph\n    :math:`\\mathcal{G}_i` its output is computed by\n\n    .. math::\n        \\mathbf{r}_i = \\frac{1}{N_i} \\sum_{n=1}^{N_i} \\mathbf{x}_n\n\n    Args:\n        x (Tensor): Node feature matrix\n            :math:`\\mathbf{X} \\in \\mathbb{R}^{(N_1 + \\ldots + N_B) \\times F}`.\n        batch (LongTensor, optional): Batch vector\n            :math:`\\mathbf{b} \\in {\\{ 0, \\ldots, B-1\\}}^N`, which assigns each\n            node to a specific example.\n        size (int, optional): Batch-size :math:`B`.\n            Automatically calculated if not given. (default: :obj:`None`)\n    \"\"\"\n    if batch is None:\n        return x.mean(dim=0, keepdim=True)\n    size = int(batch.max().item() + 1) if size is None else size\n    return scatter(x, batch, dim=0, dim_size=size, reduce='mean')\n\n\ndef global_max_pool(x: Tensor, batch: Optional[Tensor],\n                    size: Optional[int] = None) -> Tensor:\n    r\"\"\"Returns batch-wise graph-level-outputs by taking the channel-wise\n    maximum across the node dimension, so that for a single graph\n    :math:`\\mathcal{G}_i` its output is computed by\n\n    .. math::\n        \\mathbf{r}_i = \\mathrm{max}_{n=1}^{N_i} \\, \\mathbf{x}_n\n\n    Args:\n        x (Tensor): Node feature matrix\n            :math:`\\mathbf{X} \\in \\mathbb{R}^{(N_1 + \\ldots + N_B) \\times F}`.\n        batch (LongTensor, optional): Batch vector\n            :math:`\\mathbf{b} \\in {\\{ 0, \\ldots, B-1\\}}^N`, which assigns each\n            node to a specific example.\n        size (int, optional): Batch-size :math:`B`.\n            Automatically calculated if not given. (default: :obj:`None`)\n    \"\"\"\n    if batch is None:\n        return x.max(dim=0, keepdim=True)[0]\n    size = int(batch.max().item() + 1) if size is None else size\n    return scatter(x, batch, dim=0, dim_size=size, reduce='max')\n\n\nclass GlobalPooling(torch.nn.Module):\n    r\"\"\"A global pooling module that wraps the usage of\n    :meth:`~torch_geometric.nn.glob.global_add_pool`,\n    :meth:`~torch_geometric.nn.glob.global_mean_pool` and\n    :meth:`~torch_geometric.nn.glob.global_max_pool` into a single module.\n\n    Args:\n        aggr (string or List[str]): The aggregation scheme to use\n            (:obj:`\"add\"`, :obj:`\"mean\"`, :obj:`\"max\"`).\n            If given as a list, will make use of multiple aggregations in which\n            different outputs will get concatenated in the last dimension.\n    \"\"\"\n    def __init__(self, aggr: Union[str, List[str]]):\n        super().__init__()\n\n        self.aggrs = [aggr] if isinstance(aggr, str) else aggr\n\n        assert len(self.aggrs) > 0\n        assert len(set(self.aggrs) | {'sum', 'add', 'mean', 'max'}) == 4\n\n    def forward(self, x: Tensor, batch: Optional[Tensor],\n                size: Optional[int] = None) -> Tensor:\n        \"\"\"\"\"\"\n        xs: List[Tensor] = []\n\n        for aggr in self.aggrs:\n            if aggr == 'sum' or aggr == 'add':\n                xs.append(global_add_pool(x, batch, size))\n            elif aggr == 'mean':\n                xs.append(global_mean_pool(x, batch, size))\n            elif aggr == 'max':\n                xs.append(global_max_pool(x, batch, size))\n\n        return xs[0] if len(xs) == 1 else torch.cat(xs, dim=-1)\n\n    def __repr__(self) -> str:\n        aggr = self.aggrs[0] if len(self.aggrs) == 1 else self.aggrs\n        return f'{self.__class__.__name__}(aggr={aggr})'\n", "path": "torch_geometric/nn/glob/glob.py"}], "after_files": [{"content": "from typing import List, Optional, Union\n\nimport torch\nfrom torch import Tensor\nfrom torch_scatter import scatter\n\n\ndef global_add_pool(x: Tensor, batch: Optional[Tensor],\n                    size: Optional[int] = None) -> Tensor:\n    r\"\"\"Returns batch-wise graph-level-outputs by adding node features\n    across the node dimension, so that for a single graph\n    :math:`\\mathcal{G}_i` its output is computed by\n\n    .. math::\n        \\mathbf{r}_i = \\sum_{n=1}^{N_i} \\mathbf{x}_n\n\n    Args:\n        x (Tensor): Node feature matrix\n            :math:`\\mathbf{X} \\in \\mathbb{R}^{(N_1 + \\ldots + N_B) \\times F}`.\n        batch (LongTensor, optional): Batch vector\n            :math:`\\mathbf{b} \\in {\\{ 0, \\ldots, B-1\\}}^N`, which assigns each\n            node to a specific example.\n        size (int, optional): Batch-size :math:`B`.\n            Automatically calculated if not given. (default: :obj:`None`)\n    \"\"\"\n    if batch is None:\n        return x.sum(dim=-2, keepdim=x.dim() == 2)\n    size = int(batch.max().item() + 1) if size is None else size\n    return scatter(x, batch, dim=-2, dim_size=size, reduce='add')\n\n\ndef global_mean_pool(x: Tensor, batch: Optional[Tensor],\n                     size: Optional[int] = None) -> Tensor:\n    r\"\"\"Returns batch-wise graph-level-outputs by averaging node features\n    across the node dimension, so that for a single graph\n    :math:`\\mathcal{G}_i` its output is computed by\n\n    .. math::\n        \\mathbf{r}_i = \\frac{1}{N_i} \\sum_{n=1}^{N_i} \\mathbf{x}_n\n\n    Args:\n        x (Tensor): Node feature matrix\n            :math:`\\mathbf{X} \\in \\mathbb{R}^{(N_1 + \\ldots + N_B) \\times F}`.\n        batch (LongTensor, optional): Batch vector\n            :math:`\\mathbf{b} \\in {\\{ 0, \\ldots, B-1\\}}^N`, which assigns each\n            node to a specific example.\n        size (int, optional): Batch-size :math:`B`.\n            Automatically calculated if not given. (default: :obj:`None`)\n    \"\"\"\n    if batch is None:\n        return x.mean(dim=-2, keepdim=x.dim() == 2)\n    size = int(batch.max().item() + 1) if size is None else size\n    return scatter(x, batch, dim=-2, dim_size=size, reduce='mean')\n\n\ndef global_max_pool(x: Tensor, batch: Optional[Tensor],\n                    size: Optional[int] = None) -> Tensor:\n    r\"\"\"Returns batch-wise graph-level-outputs by taking the channel-wise\n    maximum across the node dimension, so that for a single graph\n    :math:`\\mathcal{G}_i` its output is computed by\n\n    .. math::\n        \\mathbf{r}_i = \\mathrm{max}_{n=1}^{N_i} \\, \\mathbf{x}_n\n\n    Args:\n        x (Tensor): Node feature matrix\n            :math:`\\mathbf{X} \\in \\mathbb{R}^{(N_1 + \\ldots + N_B) \\times F}`.\n        batch (LongTensor, optional): Batch vector\n            :math:`\\mathbf{b} \\in {\\{ 0, \\ldots, B-1\\}}^N`, which assigns each\n            node to a specific example.\n        size (int, optional): Batch-size :math:`B`.\n            Automatically calculated if not given. (default: :obj:`None`)\n    \"\"\"\n    if batch is None:\n        return x.max(dim=-2, keepdim=x.dim() == 2)[0]\n    size = int(batch.max().item() + 1) if size is None else size\n    return scatter(x, batch, dim=-2, dim_size=size, reduce='max')\n\n\nclass GlobalPooling(torch.nn.Module):\n    r\"\"\"A global pooling module that wraps the usage of\n    :meth:`~torch_geometric.nn.glob.global_add_pool`,\n    :meth:`~torch_geometric.nn.glob.global_mean_pool` and\n    :meth:`~torch_geometric.nn.glob.global_max_pool` into a single module.\n\n    Args:\n        aggr (string or List[str]): The aggregation scheme to use\n            (:obj:`\"add\"`, :obj:`\"mean\"`, :obj:`\"max\"`).\n            If given as a list, will make use of multiple aggregations in which\n            different outputs will get concatenated in the last dimension.\n    \"\"\"\n    def __init__(self, aggr: Union[str, List[str]]):\n        super().__init__()\n\n        self.aggrs = [aggr] if isinstance(aggr, str) else aggr\n\n        assert len(self.aggrs) > 0\n        assert len(set(self.aggrs) | {'sum', 'add', 'mean', 'max'}) == 4\n\n    def forward(self, x: Tensor, batch: Optional[Tensor],\n                size: Optional[int] = None) -> Tensor:\n        \"\"\"\"\"\"\n        xs: List[Tensor] = []\n\n        for aggr in self.aggrs:\n            if aggr == 'sum' or aggr == 'add':\n                xs.append(global_add_pool(x, batch, size))\n            elif aggr == 'mean':\n                xs.append(global_mean_pool(x, batch, size))\n            elif aggr == 'max':\n                xs.append(global_max_pool(x, batch, size))\n\n        return xs[0] if len(xs) == 1 else torch.cat(xs, dim=-1)\n\n    def __repr__(self) -> str:\n        aggr = self.aggrs[0] if len(self.aggrs) == 1 else self.aggrs\n        return f'{self.__class__.__name__}(aggr={aggr})'\n", "path": "torch_geometric/nn/glob/glob.py"}]}