We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Mean Absolute Percentage Error (MAPE)
## 🚀 Feature

I'd like to implement the mean absolute percentage error [(MAPE)](https://en.wikipedia.org/wiki/Mean_absolute_percentage_error) in `ignite/metrics`.

It is a commonly used metric for regression problems and it would be really convenient to be able to use it directly with ignite evaluators.

For that, I would write a custom Metric class in a new file `mean_absolute_percentage_error.py` inheriting from the base `Metric` class in `ignite/metrics/metric.py`.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `ignite/contrib/metrics/regression/mean_absolute_relative_error.py`
Content:
```
1 from typing import Tuple
2 
3 import torch
4 
5 from ignite.contrib.metrics.regression._base import _BaseRegression
6 from ignite.exceptions import NotComputableError
7 from ignite.metrics.metric import reinit__is_reduced, sync_all_reduce
8 
9 
10 class MeanAbsoluteRelativeError(_BaseRegression):
11     r"""Calculate Mean Absolute Relative Error.
12 
13     .. math::
14         \text{MARE} = \frac{1}{n}\sum_{j=1}^n\frac{\left|A_j-P_j\right|}{\left|A_j\right|}
15 
16     where :math:`A_j` is the ground truth and :math:`P_j` is the predicted value.
17 
18     More details can be found in the reference `Botchkarev 2018`__.
19 
20     - ``update`` must receive output of the form ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``.
21     - `y` and `y_pred` must be of same shape `(N, )` or `(N, 1)`.
22 
23     __ https://arxiv.org/ftp/arxiv/papers/1809/1809.03006.pdf
24 
25     Parameters are inherited from ``Metric.__init__``.
26 
27     Args:
28         output_transform: a callable that is used to transform the
29             :class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the
30             form expected by the metric. This can be useful if, for example, you have a multi-output model and
31             you want to compute the metric with respect to one of the outputs.
32             By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``.
33         device: specifies which device updates are accumulated on. Setting the
34             metric's device to be the same as your ``update`` arguments ensures the ``update`` method is
35             non-blocking. By default, CPU.
36 
37     Examples:
38         To use with ``Engine`` and ``process_function``, simply attach the metric instance to the engine.
39         The output of the engine's ``process_function`` needs to be in format of
40         ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y, ...}``.
41 
42         .. include:: defaults.rst
43             :start-after: :orphan:
44 
45         .. testcode::
46 
47             metric = MeanAbsoluteRelativeError()
48             metric.attach(default_evaluator, 'mare')
49             y_true = torch.tensor([1., 2., 3., 4., 5.])
50             y_pred = y_true * 0.75
51             state = default_evaluator.run([[y_pred, y_true]])
52             print(state.metrics['mare'])
53 
54         .. testoutput::
55 
56             0.25...
57 
58     .. versionchanged:: 0.4.5
59         - Works with DDP.
60     """
61     _state_dict_all_req_keys = ("_sum_of_absolute_relative_errors", "_num_samples")
62 
63     @reinit__is_reduced
64     def reset(self) -> None:
65         self._sum_of_absolute_relative_errors = torch.tensor(0.0, device=self._device)
66         self._num_samples = 0
67 
68     def _update(self, output: Tuple[torch.Tensor, torch.Tensor]) -> None:
69         y_pred, y = output[0].detach(), output[1].detach()
70         if (y == 0).any():
71             raise NotComputableError("The ground truth has 0.")
72         absolute_error = torch.abs(y_pred - y.view_as(y_pred)) / torch.abs(y.view_as(y_pred))
73         self._sum_of_absolute_relative_errors += torch.sum(absolute_error).to(self._device)
74         self._num_samples += y.size()[0]
75 
76     @sync_all_reduce("_sum_of_absolute_relative_errors", "_num_samples")
77     def compute(self) -> float:
78         if self._num_samples == 0:
79             raise NotComputableError(
80                 "MeanAbsoluteRelativeError must have at least one sample before it can be computed."
81             )
82         return self._sum_of_absolute_relative_errors.item() / self._num_samples
83
```
--- 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/ignite/contrib/metrics/regression/mean_absolute_relative_error.py b/ignite/contrib/metrics/regression/mean_absolute_relative_error.py
--- a/ignite/contrib/metrics/regression/mean_absolute_relative_error.py
+++ b/ignite/contrib/metrics/regression/mean_absolute_relative_error.py
@@ -8,7 +8,7 @@
 
 
 class MeanAbsoluteRelativeError(_BaseRegression):
-    r"""Calculate Mean Absolute Relative Error.
+    r"""Calculate Mean Absolute Relative Error (MARE), also known as Mean Absolute Percentage Error (MAPE).
 
     .. math::
         \text{MARE} = \frac{1}{n}\sum_{j=1}^n\frac{\left|A_j-P_j\right|}{\left|A_j\right|}

{"golden_diff": "diff --git a/ignite/contrib/metrics/regression/mean_absolute_relative_error.py b/ignite/contrib/metrics/regression/mean_absolute_relative_error.py\n--- a/ignite/contrib/metrics/regression/mean_absolute_relative_error.py\n+++ b/ignite/contrib/metrics/regression/mean_absolute_relative_error.py\n@@ -8,7 +8,7 @@\n \n \n class MeanAbsoluteRelativeError(_BaseRegression):\n-    r\"\"\"Calculate Mean Absolute Relative Error.\n+    r\"\"\"Calculate Mean Absolute Relative Error (MARE), also known as Mean Absolute Percentage Error (MAPE).\n \n     .. math::\n         \\text{MARE} = \\frac{1}{n}\\sum_{j=1}^n\\frac{\\left|A_j-P_j\\right|}{\\left|A_j\\right|}\n", "issue": "Mean Absolute Percentage Error (MAPE)\n## \ud83d\ude80 Feature\r\n\r\nI'd like to implement the mean absolute percentage error [(MAPE)](https://en.wikipedia.org/wiki/Mean_absolute_percentage_error) in `ignite/metrics`.\r\n\r\nIt is a commonly used metric for regression problems and it would be really convenient to be able to use it directly with ignite evaluators.\r\n\r\nFor that, I would write a custom Metric class in a new file `mean_absolute_percentage_error.py` inheriting from the base `Metric` class in `ignite/metrics/metric.py`.\r\n\n", "before_files": [{"content": "from typing import Tuple\n\nimport torch\n\nfrom ignite.contrib.metrics.regression._base import _BaseRegression\nfrom ignite.exceptions import NotComputableError\nfrom ignite.metrics.metric import reinit__is_reduced, sync_all_reduce\n\n\nclass MeanAbsoluteRelativeError(_BaseRegression):\n    r\"\"\"Calculate Mean Absolute Relative Error.\n\n    .. math::\n        \\text{MARE} = \\frac{1}{n}\\sum_{j=1}^n\\frac{\\left|A_j-P_j\\right|}{\\left|A_j\\right|}\n\n    where :math:`A_j` is the ground truth and :math:`P_j` is the predicted value.\n\n    More details can be found in the reference `Botchkarev 2018`__.\n\n    - ``update`` must receive output of the form ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``.\n    - `y` and `y_pred` must be of same shape `(N, )` or `(N, 1)`.\n\n    __ https://arxiv.org/ftp/arxiv/papers/1809/1809.03006.pdf\n\n    Parameters are inherited from ``Metric.__init__``.\n\n    Args:\n        output_transform: a callable that is used to transform the\n            :class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the\n            form expected by the metric. This can be useful if, for example, you have a multi-output model and\n            you want to compute the metric with respect to one of the outputs.\n            By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``.\n        device: specifies which device updates are accumulated on. Setting the\n            metric's device to be the same as your ``update`` arguments ensures the ``update`` method is\n            non-blocking. By default, CPU.\n\n    Examples:\n        To use with ``Engine`` and ``process_function``, simply attach the metric instance to the engine.\n        The output of the engine's ``process_function`` needs to be in format of\n        ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y, ...}``.\n\n        .. include:: defaults.rst\n            :start-after: :orphan:\n\n        .. testcode::\n\n            metric = MeanAbsoluteRelativeError()\n            metric.attach(default_evaluator, 'mare')\n            y_true = torch.tensor([1., 2., 3., 4., 5.])\n            y_pred = y_true * 0.75\n            state = default_evaluator.run([[y_pred, y_true]])\n            print(state.metrics['mare'])\n\n        .. testoutput::\n\n            0.25...\n\n    .. versionchanged:: 0.4.5\n        - Works with DDP.\n    \"\"\"\n    _state_dict_all_req_keys = (\"_sum_of_absolute_relative_errors\", \"_num_samples\")\n\n    @reinit__is_reduced\n    def reset(self) -> None:\n        self._sum_of_absolute_relative_errors = torch.tensor(0.0, device=self._device)\n        self._num_samples = 0\n\n    def _update(self, output: Tuple[torch.Tensor, torch.Tensor]) -> None:\n        y_pred, y = output[0].detach(), output[1].detach()\n        if (y == 0).any():\n            raise NotComputableError(\"The ground truth has 0.\")\n        absolute_error = torch.abs(y_pred - y.view_as(y_pred)) / torch.abs(y.view_as(y_pred))\n        self._sum_of_absolute_relative_errors += torch.sum(absolute_error).to(self._device)\n        self._num_samples += y.size()[0]\n\n    @sync_all_reduce(\"_sum_of_absolute_relative_errors\", \"_num_samples\")\n    def compute(self) -> float:\n        if self._num_samples == 0:\n            raise NotComputableError(\n                \"MeanAbsoluteRelativeError must have at least one sample before it can be computed.\"\n            )\n        return self._sum_of_absolute_relative_errors.item() / self._num_samples\n", "path": "ignite/contrib/metrics/regression/mean_absolute_relative_error.py"}], "after_files": [{"content": "from typing import Tuple\n\nimport torch\n\nfrom ignite.contrib.metrics.regression._base import _BaseRegression\nfrom ignite.exceptions import NotComputableError\nfrom ignite.metrics.metric import reinit__is_reduced, sync_all_reduce\n\n\nclass MeanAbsoluteRelativeError(_BaseRegression):\n    r\"\"\"Calculate Mean Absolute Relative Error (MARE), also known as Mean Absolute Percentage Error (MAPE).\n\n    .. math::\n        \\text{MARE} = \\frac{1}{n}\\sum_{j=1}^n\\frac{\\left|A_j-P_j\\right|}{\\left|A_j\\right|}\n\n    where :math:`A_j` is the ground truth and :math:`P_j` is the predicted value.\n\n    More details can be found in the reference `Botchkarev 2018`__.\n\n    - ``update`` must receive output of the form ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``.\n    - `y` and `y_pred` must be of same shape `(N, )` or `(N, 1)`.\n\n    __ https://arxiv.org/ftp/arxiv/papers/1809/1809.03006.pdf\n\n    Parameters are inherited from ``Metric.__init__``.\n\n    Args:\n        output_transform: a callable that is used to transform the\n            :class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the\n            form expected by the metric. This can be useful if, for example, you have a multi-output model and\n            you want to compute the metric with respect to one of the outputs.\n            By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``.\n        device: specifies which device updates are accumulated on. Setting the\n            metric's device to be the same as your ``update`` arguments ensures the ``update`` method is\n            non-blocking. By default, CPU.\n\n    Examples:\n        To use with ``Engine`` and ``process_function``, simply attach the metric instance to the engine.\n        The output of the engine's ``process_function`` needs to be in format of\n        ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y, ...}``.\n\n        .. include:: defaults.rst\n            :start-after: :orphan:\n\n        .. testcode::\n\n            metric = MeanAbsoluteRelativeError()\n            metric.attach(default_evaluator, 'mare')\n            y_true = torch.tensor([1., 2., 3., 4., 5.])\n            y_pred = y_true * 0.75\n            state = default_evaluator.run([[y_pred, y_true]])\n            print(state.metrics['mare'])\n\n        .. testoutput::\n\n            0.25...\n\n    .. versionchanged:: 0.4.5\n        - Works with DDP.\n    \"\"\"\n    _state_dict_all_req_keys = (\"_sum_of_absolute_relative_errors\", \"_num_samples\")\n\n    @reinit__is_reduced\n    def reset(self) -> None:\n        self._sum_of_absolute_relative_errors = torch.tensor(0.0, device=self._device)\n        self._num_samples = 0\n\n    def _update(self, output: Tuple[torch.Tensor, torch.Tensor]) -> None:\n        y_pred, y = output[0].detach(), output[1].detach()\n        if (y == 0).any():\n            raise NotComputableError(\"The ground truth has 0.\")\n        absolute_error = torch.abs(y_pred - y.view_as(y_pred)) / torch.abs(y.view_as(y_pred))\n        self._sum_of_absolute_relative_errors += torch.sum(absolute_error).to(self._device)\n        self._num_samples += y.size()[0]\n\n    @sync_all_reduce(\"_sum_of_absolute_relative_errors\", \"_num_samples\")\n    def compute(self) -> float:\n        if self._num_samples == 0:\n            raise NotComputableError(\n                \"MeanAbsoluteRelativeError must have at least one sample before it can be computed.\"\n            )\n        return self._sum_of_absolute_relative_errors.item() / self._num_samples\n", "path": "ignite/contrib/metrics/regression/mean_absolute_relative_error.py"}]}