We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
MultioutputWrapper does not reset cleanly
## 🐛 Bug

Calling `MultioutputWrapper.compute()` after `MultioutputWrapper.reset()` returns old metrics that should have been cleared by the reset. 

### To Reproduce

<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->

#### Code sample

```py
import torch
import torchmetrics

base_metric = torchmetrics.ConfusionMatrix(task="multiclass", num_classes=2)
cf = torchmetrics.MultioutputWrapper(base_metric, num_outputs=2)

cf(torch.tensor([[0,0]]), torch.tensor([[0,0]]))
print("First result: ", cf.compute())

cf.reset()

cf(torch.tensor([[1,1]]), torch.tensor([[0,0]]))
print("Second result: ", cf.compute())
```

Output:
```
First result:  [tensor([[1, 0], [0, 0]]), tensor([[1, 0], [0, 0]])]
Second result:  [tensor([[1, 0], [0, 0]]), tensor([[1, 0], [0, 0]])]
```
The old output is returned even after resetting and entering new data. If the fist metric computation is omitted, the second metric is as expected.

Importantly, this bug only occurs when using `forward()` to enter data, while `update()` works as expected.

### Expected behavior

The result of the second computation should be independent of the first. Furthermore, forward and update should produce the same state as specified in the docs.

### Environment

- torchmetrics 0.10.3, installed from pypi
- Python 3.8.9

### Attempts to fix

Adding `super().reset()` (as done in e.g. the minmax wrapper) at the top of the reset method seems to fix the bug. 
https://github.com/Lightning-AI/metrics/blob/7b505ff1a3b88181bef2b0cdfa21ec593dcda3ff/src/torchmetrics/wrappers/multioutput.py#L133

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/torchmetrics/wrappers/multioutput.py`
Content:
```
1 from copy import deepcopy
2 from typing import Any, List, Tuple
3 
4 import torch
5 from torch import Tensor
6 from torch.nn import ModuleList
7 
8 from torchmetrics import Metric
9 from torchmetrics.utilities import apply_to_collection
10 
11 
12 def _get_nan_indices(*tensors: Tensor) -> Tensor:
13     """Get indices of rows along dim 0 which have NaN values."""
14     if len(tensors) == 0:
15         raise ValueError("Must pass at least one tensor as argument")
16     sentinel = tensors[0]
17     nan_idxs = torch.zeros(len(sentinel), dtype=torch.bool, device=sentinel.device)
18     for tensor in tensors:
19         permuted_tensor = tensor.flatten(start_dim=1)
20         nan_idxs |= torch.any(torch.isnan(permuted_tensor), dim=1)
21     return nan_idxs
22 
23 
24 class MultioutputWrapper(Metric):
25     """Wrap a base metric to enable it to support multiple outputs.
26 
27     Several torchmetrics metrics, such as :class:`torchmetrics.regression.spearman.SpearmanCorrcoef` lack support for
28     multioutput mode. This class wraps such metrics to support computing one metric per output.
29     Unlike specific torchmetric metrics, it doesn't support any aggregation across outputs.
30     This means if you set ``num_outputs`` to 2, ``.compute()`` will return a Tensor of dimension
31     ``(2, ...)`` where ``...`` represents the dimensions the metric returns when not wrapped.
32 
33     In addition to enabling multioutput support for metrics that lack it, this class also supports, albeit in a crude
34     fashion, dealing with missing labels (or other data). When ``remove_nans`` is passed, the class will remove the
35     intersection of NaN containing "rows" upon each update for each output. For example, suppose a user uses
36     `MultioutputWrapper` to wrap :class:`torchmetrics.regression.r2.R2Score` with 2 outputs, one of which occasionally
37     has missing labels for classes like ``R2Score`` is that this class supports removing ``NaN`` values
38     (parameter ``remove_nans``) on a per-output basis. When ``remove_nans`` is passed the wrapper will remove all rows
39 
40     Args:
41         base_metric: Metric being wrapped.
42         num_outputs: Expected dimensionality of the output dimension.
43             This parameter is used to determine the number of distinct metrics we need to track.
44         output_dim:
45             Dimension on which output is expected. Note that while this provides some flexibility, the output dimension
46             must be the same for all inputs to update. This applies even for metrics such as `Accuracy` where the labels
47             can have a different number of dimensions than the predictions. This can be worked around if the output
48             dimension can be set to -1 for both, even if -1 corresponds to different dimensions in different inputs.
49         remove_nans:
50             Whether to remove the intersection of rows containing NaNs from the values passed through to each underlying
51             metric. Proper operation requires all tensors passed to update to have dimension ``(N, ...)`` where N
52             represents the length of the batch or dataset being passed in.
53         squeeze_outputs:
54             If ``True``, will squeeze the 1-item dimensions left after ``index_select`` is applied.
55             This is sometimes unnecessary but harmless for metrics such as `R2Score` but useful
56             for certain classification metrics that can't handle additional 1-item dimensions.
57 
58     Example:
59 
60          >>> # Mimic R2Score in `multioutput`, `raw_values` mode:
61          >>> import torch
62          >>> from torchmetrics import MultioutputWrapper, R2Score
63          >>> target = torch.tensor([[0.5, 1], [-1, 1], [7, -6]])
64          >>> preds = torch.tensor([[0, 2], [-1, 2], [8, -5]])
65          >>> r2score = MultioutputWrapper(R2Score(), 2)
66          >>> r2score(preds, target)
67          [tensor(0.9654), tensor(0.9082)]
68     """
69 
70     is_differentiable = False
71 
72     def __init__(
73         self,
74         base_metric: Metric,
75         num_outputs: int,
76         output_dim: int = -1,
77         remove_nans: bool = True,
78         squeeze_outputs: bool = True,
79     ):
80         super().__init__()
81         self.metrics = ModuleList([deepcopy(base_metric) for _ in range(num_outputs)])
82         self.output_dim = output_dim
83         self.remove_nans = remove_nans
84         self.squeeze_outputs = squeeze_outputs
85 
86     def _get_args_kwargs_by_output(self, *args: Tensor, **kwargs: Tensor) -> List[Tuple[Tensor, Tensor]]:
87         """Get args and kwargs reshaped to be output-specific and (maybe) having NaNs stripped out."""
88         args_kwargs_by_output = []
89         for i in range(len(self.metrics)):
90             selected_args = apply_to_collection(
91                 args, Tensor, torch.index_select, dim=self.output_dim, index=torch.tensor(i, device=self.device)
92             )
93             selected_kwargs = apply_to_collection(
94                 kwargs, Tensor, torch.index_select, dim=self.output_dim, index=torch.tensor(i, device=self.device)
95             )
96             if self.remove_nans:
97                 args_kwargs = selected_args + tuple(selected_kwargs.values())
98                 nan_idxs = _get_nan_indices(*args_kwargs)
99                 selected_args = [arg[~nan_idxs] for arg in selected_args]
100                 selected_kwargs = {k: v[~nan_idxs] for k, v in selected_kwargs.items()}
101 
102             if self.squeeze_outputs:
103                 selected_args = [arg.squeeze(self.output_dim) for arg in selected_args]
104             args_kwargs_by_output.append((selected_args, selected_kwargs))
105         return args_kwargs_by_output
106 
107     def update(self, *args: Any, **kwargs: Any) -> None:
108         """Update each underlying metric with the corresponding output."""
109         reshaped_args_kwargs = self._get_args_kwargs_by_output(*args, **kwargs)
110         for metric, (selected_args, selected_kwargs) in zip(self.metrics, reshaped_args_kwargs):
111             metric.update(*selected_args, **selected_kwargs)
112 
113     def compute(self) -> List[Tensor]:
114         """Compute metrics."""
115         return [m.compute() for m in self.metrics]
116 
117     @torch.jit.unused
118     def forward(self, *args: Any, **kwargs: Any) -> Any:
119         """Call underlying forward methods and aggregate the results if they're non-null.
120 
121         We override this method to ensure that state variables get copied over on the underlying metrics.
122         """
123         results = []
124         reshaped_args_kwargs = self._get_args_kwargs_by_output(*args, **kwargs)
125         for metric, (selected_args, selected_kwargs) in zip(self.metrics, reshaped_args_kwargs):
126             results.append(metric(*selected_args, **selected_kwargs))
127         if results[0] is None:
128             return None
129         return results
130 
131     def reset(self) -> None:
132         """Reset all underlying metrics."""
133         for metric in self.metrics:
134             metric.reset()
135
```
--- 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/src/torchmetrics/wrappers/multioutput.py b/src/torchmetrics/wrappers/multioutput.py
--- a/src/torchmetrics/wrappers/multioutput.py
+++ b/src/torchmetrics/wrappers/multioutput.py
@@ -1,5 +1,5 @@
 from copy import deepcopy
-from typing import Any, List, Tuple
+from typing import Any, Callable, List, Tuple
 
 import torch
 from torch import Tensor
@@ -132,3 +132,12 @@
         """Reset all underlying metrics."""
         for metric in self.metrics:
             metric.reset()
+        super().reset()
+
+    def _wrap_update(self, update: Callable) -> Callable:
+        """Overwrite to do nothing."""
+        return update
+
+    def _wrap_compute(self, compute: Callable) -> Callable:
+        """Overwrite to do nothing."""
+        return compute

{"golden_diff": "diff --git a/src/torchmetrics/wrappers/multioutput.py b/src/torchmetrics/wrappers/multioutput.py\n--- a/src/torchmetrics/wrappers/multioutput.py\n+++ b/src/torchmetrics/wrappers/multioutput.py\n@@ -1,5 +1,5 @@\n from copy import deepcopy\n-from typing import Any, List, Tuple\n+from typing import Any, Callable, List, Tuple\n \n import torch\n from torch import Tensor\n@@ -132,3 +132,12 @@\n         \"\"\"Reset all underlying metrics.\"\"\"\n         for metric in self.metrics:\n             metric.reset()\n+        super().reset()\n+\n+    def _wrap_update(self, update: Callable) -> Callable:\n+        \"\"\"Overwrite to do nothing.\"\"\"\n+        return update\n+\n+    def _wrap_compute(self, compute: Callable) -> Callable:\n+        \"\"\"Overwrite to do nothing.\"\"\"\n+        return compute\n", "issue": "MultioutputWrapper does not reset cleanly\n## \ud83d\udc1b Bug\r\n\r\nCalling `MultioutputWrapper.compute()` after `MultioutputWrapper.reset()` returns old metrics that should have been cleared by the reset. \r\n\r\n### To Reproduce\r\n\r\n<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->\r\n\r\n#### Code sample\r\n\r\n```py\r\nimport torch\r\nimport torchmetrics\r\n\r\nbase_metric = torchmetrics.ConfusionMatrix(task=\"multiclass\", num_classes=2)\r\ncf = torchmetrics.MultioutputWrapper(base_metric, num_outputs=2)\r\n\r\ncf(torch.tensor([[0,0]]), torch.tensor([[0,0]]))\r\nprint(\"First result: \", cf.compute())\r\n\r\ncf.reset()\r\n\r\ncf(torch.tensor([[1,1]]), torch.tensor([[0,0]]))\r\nprint(\"Second result: \", cf.compute())\r\n```\r\n\r\nOutput:\r\n```\r\nFirst result:  [tensor([[1, 0], [0, 0]]), tensor([[1, 0], [0, 0]])]\r\nSecond result:  [tensor([[1, 0], [0, 0]]), tensor([[1, 0], [0, 0]])]\r\n```\r\nThe old output is returned even after resetting and entering new data. If the fist metric computation is omitted, the second metric is as expected.\r\n\r\nImportantly, this bug only occurs when using `forward()` to enter data, while `update()` works as expected.\r\n\r\n### Expected behavior\r\n\r\nThe result of the second computation should be independent of the first. Furthermore, forward and update should produce the same state as specified in the docs.\r\n\r\n### Environment\r\n\r\n- torchmetrics 0.10.3, installed from pypi\r\n- Python 3.8.9\r\n\r\n### Attempts to fix\r\n\r\nAdding `super().reset()` (as done in e.g. the minmax wrapper) at the top of the reset method seems to fix the bug. \r\nhttps://github.com/Lightning-AI/metrics/blob/7b505ff1a3b88181bef2b0cdfa21ec593dcda3ff/src/torchmetrics/wrappers/multioutput.py#L133\n", "before_files": [{"content": "from copy import deepcopy\nfrom typing import Any, List, Tuple\n\nimport torch\nfrom torch import Tensor\nfrom torch.nn import ModuleList\n\nfrom torchmetrics import Metric\nfrom torchmetrics.utilities import apply_to_collection\n\n\ndef _get_nan_indices(*tensors: Tensor) -> Tensor:\n    \"\"\"Get indices of rows along dim 0 which have NaN values.\"\"\"\n    if len(tensors) == 0:\n        raise ValueError(\"Must pass at least one tensor as argument\")\n    sentinel = tensors[0]\n    nan_idxs = torch.zeros(len(sentinel), dtype=torch.bool, device=sentinel.device)\n    for tensor in tensors:\n        permuted_tensor = tensor.flatten(start_dim=1)\n        nan_idxs |= torch.any(torch.isnan(permuted_tensor), dim=1)\n    return nan_idxs\n\n\nclass MultioutputWrapper(Metric):\n    \"\"\"Wrap a base metric to enable it to support multiple outputs.\n\n    Several torchmetrics metrics, such as :class:`torchmetrics.regression.spearman.SpearmanCorrcoef` lack support for\n    multioutput mode. This class wraps such metrics to support computing one metric per output.\n    Unlike specific torchmetric metrics, it doesn't support any aggregation across outputs.\n    This means if you set ``num_outputs`` to 2, ``.compute()`` will return a Tensor of dimension\n    ``(2, ...)`` where ``...`` represents the dimensions the metric returns when not wrapped.\n\n    In addition to enabling multioutput support for metrics that lack it, this class also supports, albeit in a crude\n    fashion, dealing with missing labels (or other data). When ``remove_nans`` is passed, the class will remove the\n    intersection of NaN containing \"rows\" upon each update for each output. For example, suppose a user uses\n    `MultioutputWrapper` to wrap :class:`torchmetrics.regression.r2.R2Score` with 2 outputs, one of which occasionally\n    has missing labels for classes like ``R2Score`` is that this class supports removing ``NaN`` values\n    (parameter ``remove_nans``) on a per-output basis. When ``remove_nans`` is passed the wrapper will remove all rows\n\n    Args:\n        base_metric: Metric being wrapped.\n        num_outputs: Expected dimensionality of the output dimension.\n            This parameter is used to determine the number of distinct metrics we need to track.\n        output_dim:\n            Dimension on which output is expected. Note that while this provides some flexibility, the output dimension\n            must be the same for all inputs to update. This applies even for metrics such as `Accuracy` where the labels\n            can have a different number of dimensions than the predictions. This can be worked around if the output\n            dimension can be set to -1 for both, even if -1 corresponds to different dimensions in different inputs.\n        remove_nans:\n            Whether to remove the intersection of rows containing NaNs from the values passed through to each underlying\n            metric. Proper operation requires all tensors passed to update to have dimension ``(N, ...)`` where N\n            represents the length of the batch or dataset being passed in.\n        squeeze_outputs:\n            If ``True``, will squeeze the 1-item dimensions left after ``index_select`` is applied.\n            This is sometimes unnecessary but harmless for metrics such as `R2Score` but useful\n            for certain classification metrics that can't handle additional 1-item dimensions.\n\n    Example:\n\n         >>> # Mimic R2Score in `multioutput`, `raw_values` mode:\n         >>> import torch\n         >>> from torchmetrics import MultioutputWrapper, R2Score\n         >>> target = torch.tensor([[0.5, 1], [-1, 1], [7, -6]])\n         >>> preds = torch.tensor([[0, 2], [-1, 2], [8, -5]])\n         >>> r2score = MultioutputWrapper(R2Score(), 2)\n         >>> r2score(preds, target)\n         [tensor(0.9654), tensor(0.9082)]\n    \"\"\"\n\n    is_differentiable = False\n\n    def __init__(\n        self,\n        base_metric: Metric,\n        num_outputs: int,\n        output_dim: int = -1,\n        remove_nans: bool = True,\n        squeeze_outputs: bool = True,\n    ):\n        super().__init__()\n        self.metrics = ModuleList([deepcopy(base_metric) for _ in range(num_outputs)])\n        self.output_dim = output_dim\n        self.remove_nans = remove_nans\n        self.squeeze_outputs = squeeze_outputs\n\n    def _get_args_kwargs_by_output(self, *args: Tensor, **kwargs: Tensor) -> List[Tuple[Tensor, Tensor]]:\n        \"\"\"Get args and kwargs reshaped to be output-specific and (maybe) having NaNs stripped out.\"\"\"\n        args_kwargs_by_output = []\n        for i in range(len(self.metrics)):\n            selected_args = apply_to_collection(\n                args, Tensor, torch.index_select, dim=self.output_dim, index=torch.tensor(i, device=self.device)\n            )\n            selected_kwargs = apply_to_collection(\n                kwargs, Tensor, torch.index_select, dim=self.output_dim, index=torch.tensor(i, device=self.device)\n            )\n            if self.remove_nans:\n                args_kwargs = selected_args + tuple(selected_kwargs.values())\n                nan_idxs = _get_nan_indices(*args_kwargs)\n                selected_args = [arg[~nan_idxs] for arg in selected_args]\n                selected_kwargs = {k: v[~nan_idxs] for k, v in selected_kwargs.items()}\n\n            if self.squeeze_outputs:\n                selected_args = [arg.squeeze(self.output_dim) for arg in selected_args]\n            args_kwargs_by_output.append((selected_args, selected_kwargs))\n        return args_kwargs_by_output\n\n    def update(self, *args: Any, **kwargs: Any) -> None:\n        \"\"\"Update each underlying metric with the corresponding output.\"\"\"\n        reshaped_args_kwargs = self._get_args_kwargs_by_output(*args, **kwargs)\n        for metric, (selected_args, selected_kwargs) in zip(self.metrics, reshaped_args_kwargs):\n            metric.update(*selected_args, **selected_kwargs)\n\n    def compute(self) -> List[Tensor]:\n        \"\"\"Compute metrics.\"\"\"\n        return [m.compute() for m in self.metrics]\n\n    @torch.jit.unused\n    def forward(self, *args: Any, **kwargs: Any) -> Any:\n        \"\"\"Call underlying forward methods and aggregate the results if they're non-null.\n\n        We override this method to ensure that state variables get copied over on the underlying metrics.\n        \"\"\"\n        results = []\n        reshaped_args_kwargs = self._get_args_kwargs_by_output(*args, **kwargs)\n        for metric, (selected_args, selected_kwargs) in zip(self.metrics, reshaped_args_kwargs):\n            results.append(metric(*selected_args, **selected_kwargs))\n        if results[0] is None:\n            return None\n        return results\n\n    def reset(self) -> None:\n        \"\"\"Reset all underlying metrics.\"\"\"\n        for metric in self.metrics:\n            metric.reset()\n", "path": "src/torchmetrics/wrappers/multioutput.py"}], "after_files": [{"content": "from copy import deepcopy\nfrom typing import Any, Callable, List, Tuple\n\nimport torch\nfrom torch import Tensor\nfrom torch.nn import ModuleList\n\nfrom torchmetrics import Metric\nfrom torchmetrics.utilities import apply_to_collection\n\n\ndef _get_nan_indices(*tensors: Tensor) -> Tensor:\n    \"\"\"Get indices of rows along dim 0 which have NaN values.\"\"\"\n    if len(tensors) == 0:\n        raise ValueError(\"Must pass at least one tensor as argument\")\n    sentinel = tensors[0]\n    nan_idxs = torch.zeros(len(sentinel), dtype=torch.bool, device=sentinel.device)\n    for tensor in tensors:\n        permuted_tensor = tensor.flatten(start_dim=1)\n        nan_idxs |= torch.any(torch.isnan(permuted_tensor), dim=1)\n    return nan_idxs\n\n\nclass MultioutputWrapper(Metric):\n    \"\"\"Wrap a base metric to enable it to support multiple outputs.\n\n    Several torchmetrics metrics, such as :class:`torchmetrics.regression.spearman.SpearmanCorrcoef` lack support for\n    multioutput mode. This class wraps such metrics to support computing one metric per output.\n    Unlike specific torchmetric metrics, it doesn't support any aggregation across outputs.\n    This means if you set ``num_outputs`` to 2, ``.compute()`` will return a Tensor of dimension\n    ``(2, ...)`` where ``...`` represents the dimensions the metric returns when not wrapped.\n\n    In addition to enabling multioutput support for metrics that lack it, this class also supports, albeit in a crude\n    fashion, dealing with missing labels (or other data). When ``remove_nans`` is passed, the class will remove the\n    intersection of NaN containing \"rows\" upon each update for each output. For example, suppose a user uses\n    `MultioutputWrapper` to wrap :class:`torchmetrics.regression.r2.R2Score` with 2 outputs, one of which occasionally\n    has missing labels for classes like ``R2Score`` is that this class supports removing ``NaN`` values\n    (parameter ``remove_nans``) on a per-output basis. When ``remove_nans`` is passed the wrapper will remove all rows\n\n    Args:\n        base_metric: Metric being wrapped.\n        num_outputs: Expected dimensionality of the output dimension.\n            This parameter is used to determine the number of distinct metrics we need to track.\n        output_dim:\n            Dimension on which output is expected. Note that while this provides some flexibility, the output dimension\n            must be the same for all inputs to update. This applies even for metrics such as `Accuracy` where the labels\n            can have a different number of dimensions than the predictions. This can be worked around if the output\n            dimension can be set to -1 for both, even if -1 corresponds to different dimensions in different inputs.\n        remove_nans:\n            Whether to remove the intersection of rows containing NaNs from the values passed through to each underlying\n            metric. Proper operation requires all tensors passed to update to have dimension ``(N, ...)`` where N\n            represents the length of the batch or dataset being passed in.\n        squeeze_outputs:\n            If ``True``, will squeeze the 1-item dimensions left after ``index_select`` is applied.\n            This is sometimes unnecessary but harmless for metrics such as `R2Score` but useful\n            for certain classification metrics that can't handle additional 1-item dimensions.\n\n    Example:\n\n         >>> # Mimic R2Score in `multioutput`, `raw_values` mode:\n         >>> import torch\n         >>> from torchmetrics import MultioutputWrapper, R2Score\n         >>> target = torch.tensor([[0.5, 1], [-1, 1], [7, -6]])\n         >>> preds = torch.tensor([[0, 2], [-1, 2], [8, -5]])\n         >>> r2score = MultioutputWrapper(R2Score(), 2)\n         >>> r2score(preds, target)\n         [tensor(0.9654), tensor(0.9082)]\n    \"\"\"\n\n    is_differentiable = False\n\n    def __init__(\n        self,\n        base_metric: Metric,\n        num_outputs: int,\n        output_dim: int = -1,\n        remove_nans: bool = True,\n        squeeze_outputs: bool = True,\n    ):\n        super().__init__()\n        self.metrics = ModuleList([deepcopy(base_metric) for _ in range(num_outputs)])\n        self.output_dim = output_dim\n        self.remove_nans = remove_nans\n        self.squeeze_outputs = squeeze_outputs\n\n    def _get_args_kwargs_by_output(self, *args: Tensor, **kwargs: Tensor) -> List[Tuple[Tensor, Tensor]]:\n        \"\"\"Get args and kwargs reshaped to be output-specific and (maybe) having NaNs stripped out.\"\"\"\n        args_kwargs_by_output = []\n        for i in range(len(self.metrics)):\n            selected_args = apply_to_collection(\n                args, Tensor, torch.index_select, dim=self.output_dim, index=torch.tensor(i, device=self.device)\n            )\n            selected_kwargs = apply_to_collection(\n                kwargs, Tensor, torch.index_select, dim=self.output_dim, index=torch.tensor(i, device=self.device)\n            )\n            if self.remove_nans:\n                args_kwargs = selected_args + tuple(selected_kwargs.values())\n                nan_idxs = _get_nan_indices(*args_kwargs)\n                selected_args = [arg[~nan_idxs] for arg in selected_args]\n                selected_kwargs = {k: v[~nan_idxs] for k, v in selected_kwargs.items()}\n\n            if self.squeeze_outputs:\n                selected_args = [arg.squeeze(self.output_dim) for arg in selected_args]\n            args_kwargs_by_output.append((selected_args, selected_kwargs))\n        return args_kwargs_by_output\n\n    def update(self, *args: Any, **kwargs: Any) -> None:\n        \"\"\"Update each underlying metric with the corresponding output.\"\"\"\n        reshaped_args_kwargs = self._get_args_kwargs_by_output(*args, **kwargs)\n        for metric, (selected_args, selected_kwargs) in zip(self.metrics, reshaped_args_kwargs):\n            metric.update(*selected_args, **selected_kwargs)\n\n    def compute(self) -> List[Tensor]:\n        \"\"\"Compute metrics.\"\"\"\n        return [m.compute() for m in self.metrics]\n\n    @torch.jit.unused\n    def forward(self, *args: Any, **kwargs: Any) -> Any:\n        \"\"\"Call underlying forward methods and aggregate the results if they're non-null.\n\n        We override this method to ensure that state variables get copied over on the underlying metrics.\n        \"\"\"\n        results = []\n        reshaped_args_kwargs = self._get_args_kwargs_by_output(*args, **kwargs)\n        for metric, (selected_args, selected_kwargs) in zip(self.metrics, reshaped_args_kwargs):\n            results.append(metric(*selected_args, **selected_kwargs))\n        if results[0] is None:\n            return None\n        return results\n\n    def reset(self) -> None:\n        \"\"\"Reset all underlying metrics.\"\"\"\n        for metric in self.metrics:\n            metric.reset()\n        super().reset()\n\n    def _wrap_update(self, update: Callable) -> Callable:\n        \"\"\"Overwrite to do nothing.\"\"\"\n        return update\n\n    def _wrap_compute(self, compute: Callable) -> Callable:\n        \"\"\"Overwrite to do nothing.\"\"\"\n        return compute\n", "path": "src/torchmetrics/wrappers/multioutput.py"}]}