prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Code formatting issue with latest flake8
  
  https://github.com/pytorch/ignite/runs/7781175697?check_suite_focus=true#step:11:84
  
  ```
  Collecting flake8
    Downloading flake8-5.0.4-py2.py3-none-any.whl (61 kB)
  
  + flake8 ignite tests examples --config setup.cfg
  ignite/metrics/psnr.py:12:121: E501 line too long (121 > 120 characters)
  ```
  
  --- 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/metrics/psnr.py`
  Content:
  ```
  1 from typing import Callable, Sequence, Union
  2 
  3 import torch
  4 
  5 from ignite.exceptions import NotComputableError
  6 from ignite.metrics.metric import Metric, reinit__is_reduced, sync_all_reduce
  7 
  8 __all__ = ["PSNR"]
  9 
  10 
  11 class PSNR(Metric):
  12     r"""Computes average `Peak signal-to-noise ratio (PSNR) <https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio>`_.
  13 
  14     .. math::
  15         \text{PSNR}(I, J) = 10 * \log_{10}\left(\frac{ MAX_{I}^2 }{ \text{ MSE } }\right)
  16 
  17     where :math:`\text{MSE}` is `mean squared error <https://en.wikipedia.org/wiki/Mean_squared_error>`_.
  18 
  19     - `y_pred` and `y` **must** have (batch_size, ...) shape.
  20     - `y_pred` and `y` **must** have same dtype and same shape.
  21 
  22     Args:
  23         data_range: The data range of the target image (distance between minimum
  24             and maximum possible values).
  25             For other data types, please set the data range, otherwise an exception will be raised.
  26         output_transform: A callable that is used to transform the Engine’s
  27             process_function’s output into the form expected by the metric.
  28         device: specifies which device updates are accumulated on.
  29             Setting the metric’s device to be the same as your update arguments ensures
  30             the update method is non-blocking. By default, CPU.
  31 
  32     Examples:
  33         To use with ``Engine`` and ``process_function``, simply attach the metric instance to the engine.
  34         The output of the engine's ``process_function`` needs to be in format of
  35         ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y, ...}``.
  36 
  37         For more information on how metric works with :class:`~ignite.engine.engine.Engine`, visit :ref:`attach-engine`.
  38 
  39         .. include:: defaults.rst
  40             :start-after: :orphan:
  41 
  42         .. testcode::
  43 
  44             psnr = PSNR(data_range=1.0)
  45             psnr.attach(default_evaluator, 'psnr')
  46             preds = torch.rand([4, 3, 16, 16])
  47             target = preds * 0.75
  48             state = default_evaluator.run([[preds, target]])
  49             print(state.metrics['psnr'])
  50 
  51         .. testoutput::
  52 
  53             16.8671405...
  54 
  55         This metric by default accepts Grayscale or RGB images. But if you have YCbCr or YUV images, only
  56         Y channel is needed for computing PSNR. And, this can be done with ``output_transform``. For instance,
  57 
  58         .. testcode::
  59 
  60             def get_y_channel(output):
  61                 y_pred, y = output
  62                 # y_pred and y are (B, 3, H, W) and YCbCr or YUV images
  63                 # let's select y channel
  64                 return y_pred[:, 0, ...], y[:, 0, ...]
  65 
  66             psnr = PSNR(data_range=219, output_transform=get_y_channel)
  67             psnr.attach(default_evaluator, 'psnr')
  68             preds = 219 * torch.rand([4, 3, 16, 16])
  69             target = preds * 0.75
  70             state = default_evaluator.run([[preds, target]])
  71             print(state.metrics['psnr'])
  72 
  73         .. testoutput::
  74 
  75             16.7027966...
  76 
  77     .. versionadded:: 0.4.3
  78     """
  79 
  80     def __init__(
  81         self,
  82         data_range: Union[int, float],
  83         output_transform: Callable = lambda x: x,
  84         device: Union[str, torch.device] = torch.device("cpu"),
  85     ):
  86         super().__init__(output_transform=output_transform, device=device)
  87         self.data_range = data_range
  88 
  89     def _check_shape_dtype(self, output: Sequence[torch.Tensor]) -> None:
  90         y_pred, y = output
  91         if y_pred.dtype != y.dtype:
  92             raise TypeError(
  93                 f"Expected y_pred and y to have the same data type. Got y_pred: {y_pred.dtype} and y: {y.dtype}."
  94             )
  95 
  96         if y_pred.shape != y.shape:
  97             raise ValueError(
  98                 f"Expected y_pred and y to have the same shape. Got y_pred: {y_pred.shape} and y: {y.shape}."
  99             )
  100 
  101     @reinit__is_reduced
  102     def reset(self) -> None:
  103         self._sum_of_batchwise_psnr = torch.tensor(0.0, dtype=torch.float64, device=self._device)
  104         self._num_examples = 0
  105 
  106     @reinit__is_reduced
  107     def update(self, output: Sequence[torch.Tensor]) -> None:
  108         self._check_shape_dtype(output)
  109         y_pred, y = output[0].detach(), output[1].detach()
  110 
  111         dim = tuple(range(1, y.ndim))
  112         mse_error = torch.pow(y_pred.double() - y.view_as(y_pred).double(), 2).mean(dim=dim)
  113         self._sum_of_batchwise_psnr += torch.sum(10.0 * torch.log10(self.data_range ** 2 / (mse_error + 1e-10))).to(
  114             device=self._device
  115         )
  116         self._num_examples += y.shape[0]
  117 
  118     @sync_all_reduce("_sum_of_batchwise_psnr", "_num_examples")
  119     def compute(self) -> torch.Tensor:
  120         if self._num_examples == 0:
  121             raise NotComputableError("PSNR must have at least one example before it can be computed.")
  122         return self._sum_of_batchwise_psnr / self._num_examples
  123
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/ignite/metrics/psnr.py b/ignite/metrics/psnr.py
  --- a/ignite/metrics/psnr.py
  +++ b/ignite/metrics/psnr.py
  @@ -9,7 +9,8 @@
   
   
   class PSNR(Metric):
  -    r"""Computes average `Peak signal-to-noise ratio (PSNR) <https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio>`_.
  +    r"""Computes average
  +    `Peak signal-to-noise ratio (PSNR) <https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio>`_.
   
       .. math::
           \text{PSNR}(I, J) = 10 * \log_{10}\left(\frac{ MAX_{I}^2 }{ \text{ MSE } }\right)
  @@ -34,7 +35,8 @@
           The output of the engine's ``process_function`` needs to be in format of
           ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y, ...}``.
   
  -        For more information on how metric works with :class:`~ignite.engine.engine.Engine`, visit :ref:`attach-engine`.
  +        For more information on how metric works with :class:`~ignite.engine.engine.Engine`,
  +        visit :ref:`attach-engine`.
   
           .. include:: defaults.rst
               :start-after: :orphan:
  
verification_info: {"golden_diff": "diff --git a/ignite/metrics/psnr.py b/ignite/metrics/psnr.py\n--- a/ignite/metrics/psnr.py\n+++ b/ignite/metrics/psnr.py\n@@ -9,7 +9,8 @@\n \n \n class PSNR(Metric):\n-    r\"\"\"Computes average `Peak signal-to-noise ratio (PSNR) <https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio>`_.\n+    r\"\"\"Computes average\n+    `Peak signal-to-noise ratio (PSNR) <https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio>`_.\n \n     .. math::\n         \\text{PSNR}(I, J) = 10 * \\log_{10}\\left(\\frac{ MAX_{I}^2 }{ \\text{ MSE } }\\right)\n@@ -34,7 +35,8 @@\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-        For more information on how metric works with :class:`~ignite.engine.engine.Engine`, visit :ref:`attach-engine`.\n+        For more information on how metric works with :class:`~ignite.engine.engine.Engine`,\n+        visit :ref:`attach-engine`.\n \n         .. include:: defaults.rst\n             :start-after: :orphan:\n", "issue": "Code formatting issue with latest flake8\n\r\nhttps://github.com/pytorch/ignite/runs/7781175697?check_suite_focus=true#step:11:84\r\n\r\n```\r\nCollecting flake8\r\n  Downloading flake8-5.0.4-py2.py3-none-any.whl (61 kB)\r\n\r\n+ flake8 ignite tests examples --config setup.cfg\r\nignite/metrics/psnr.py:12:121: E501 line too long (121 > 120 characters)\r\n```\n", "before_files": [{"content": "from typing import Callable, Sequence, Union\n\nimport torch\n\nfrom ignite.exceptions import NotComputableError\nfrom ignite.metrics.metric import Metric, reinit__is_reduced, sync_all_reduce\n\n__all__ = [\"PSNR\"]\n\n\nclass PSNR(Metric):\n    r\"\"\"Computes average `Peak signal-to-noise ratio (PSNR) <https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio>`_.\n\n    .. math::\n        \\text{PSNR}(I, J) = 10 * \\log_{10}\\left(\\frac{ MAX_{I}^2 }{ \\text{ MSE } }\\right)\n\n    where :math:`\\text{MSE}` is `mean squared error <https://en.wikipedia.org/wiki/Mean_squared_error>`_.\n\n    - `y_pred` and `y` **must** have (batch_size, ...) shape.\n    - `y_pred` and `y` **must** have same dtype and same shape.\n\n    Args:\n        data_range: The data range of the target image (distance between minimum\n            and maximum possible values).\n            For other data types, please set the data range, otherwise an exception will be raised.\n        output_transform: A callable that is used to transform the Engine\u2019s\n            process_function\u2019s output into the form expected by the metric.\n        device: specifies which device updates are accumulated on.\n            Setting the metric\u2019s device to be the same as your update arguments ensures\n            the update method is 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        For more information on how metric works with :class:`~ignite.engine.engine.Engine`, visit :ref:`attach-engine`.\n\n        .. include:: defaults.rst\n            :start-after: :orphan:\n\n        .. testcode::\n\n            psnr = PSNR(data_range=1.0)\n            psnr.attach(default_evaluator, 'psnr')\n            preds = torch.rand([4, 3, 16, 16])\n            target = preds * 0.75\n            state = default_evaluator.run([[preds, target]])\n            print(state.metrics['psnr'])\n\n        .. testoutput::\n\n            16.8671405...\n\n        This metric by default accepts Grayscale or RGB images. But if you have YCbCr or YUV images, only\n        Y channel is needed for computing PSNR. And, this can be done with ``output_transform``. For instance,\n\n        .. testcode::\n\n            def get_y_channel(output):\n                y_pred, y = output\n                # y_pred and y are (B, 3, H, W) and YCbCr or YUV images\n                # let's select y channel\n                return y_pred[:, 0, ...], y[:, 0, ...]\n\n            psnr = PSNR(data_range=219, output_transform=get_y_channel)\n            psnr.attach(default_evaluator, 'psnr')\n            preds = 219 * torch.rand([4, 3, 16, 16])\n            target = preds * 0.75\n            state = default_evaluator.run([[preds, target]])\n            print(state.metrics['psnr'])\n\n        .. testoutput::\n\n            16.7027966...\n\n    .. versionadded:: 0.4.3\n    \"\"\"\n\n    def __init__(\n        self,\n        data_range: Union[int, float],\n        output_transform: Callable = lambda x: x,\n        device: Union[str, torch.device] = torch.device(\"cpu\"),\n    ):\n        super().__init__(output_transform=output_transform, device=device)\n        self.data_range = data_range\n\n    def _check_shape_dtype(self, output: Sequence[torch.Tensor]) -> None:\n        y_pred, y = output\n        if y_pred.dtype != y.dtype:\n            raise TypeError(\n                f\"Expected y_pred and y to have the same data type. Got y_pred: {y_pred.dtype} and y: {y.dtype}.\"\n            )\n\n        if y_pred.shape != y.shape:\n            raise ValueError(\n                f\"Expected y_pred and y to have the same shape. Got y_pred: {y_pred.shape} and y: {y.shape}.\"\n            )\n\n    @reinit__is_reduced\n    def reset(self) -> None:\n        self._sum_of_batchwise_psnr = torch.tensor(0.0, dtype=torch.float64, device=self._device)\n        self._num_examples = 0\n\n    @reinit__is_reduced\n    def update(self, output: Sequence[torch.Tensor]) -> None:\n        self._check_shape_dtype(output)\n        y_pred, y = output[0].detach(), output[1].detach()\n\n        dim = tuple(range(1, y.ndim))\n        mse_error = torch.pow(y_pred.double() - y.view_as(y_pred).double(), 2).mean(dim=dim)\n        self._sum_of_batchwise_psnr += torch.sum(10.0 * torch.log10(self.data_range ** 2 / (mse_error + 1e-10))).to(\n            device=self._device\n        )\n        self._num_examples += y.shape[0]\n\n    @sync_all_reduce(\"_sum_of_batchwise_psnr\", \"_num_examples\")\n    def compute(self) -> torch.Tensor:\n        if self._num_examples == 0:\n            raise NotComputableError(\"PSNR must have at least one example before it can be computed.\")\n        return self._sum_of_batchwise_psnr / self._num_examples\n", "path": "ignite/metrics/psnr.py"}], "after_files": [{"content": "from typing import Callable, Sequence, Union\n\nimport torch\n\nfrom ignite.exceptions import NotComputableError\nfrom ignite.metrics.metric import Metric, reinit__is_reduced, sync_all_reduce\n\n__all__ = [\"PSNR\"]\n\n\nclass PSNR(Metric):\n    r\"\"\"Computes average\n    `Peak signal-to-noise ratio (PSNR) <https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio>`_.\n\n    .. math::\n        \\text{PSNR}(I, J) = 10 * \\log_{10}\\left(\\frac{ MAX_{I}^2 }{ \\text{ MSE } }\\right)\n\n    where :math:`\\text{MSE}` is `mean squared error <https://en.wikipedia.org/wiki/Mean_squared_error>`_.\n\n    - `y_pred` and `y` **must** have (batch_size, ...) shape.\n    - `y_pred` and `y` **must** have same dtype and same shape.\n\n    Args:\n        data_range: The data range of the target image (distance between minimum\n            and maximum possible values).\n            For other data types, please set the data range, otherwise an exception will be raised.\n        output_transform: A callable that is used to transform the Engine\u2019s\n            process_function\u2019s output into the form expected by the metric.\n        device: specifies which device updates are accumulated on.\n            Setting the metric\u2019s device to be the same as your update arguments ensures\n            the update method is 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        For more information on how metric works with :class:`~ignite.engine.engine.Engine`,\n        visit :ref:`attach-engine`.\n\n        .. include:: defaults.rst\n            :start-after: :orphan:\n\n        .. testcode::\n\n            psnr = PSNR(data_range=1.0)\n            psnr.attach(default_evaluator, 'psnr')\n            preds = torch.rand([4, 3, 16, 16])\n            target = preds * 0.75\n            state = default_evaluator.run([[preds, target]])\n            print(state.metrics['psnr'])\n\n        .. testoutput::\n\n            16.8671405...\n\n        This metric by default accepts Grayscale or RGB images. But if you have YCbCr or YUV images, only\n        Y channel is needed for computing PSNR. And, this can be done with ``output_transform``. For instance,\n\n        .. testcode::\n\n            def get_y_channel(output):\n                y_pred, y = output\n                # y_pred and y are (B, 3, H, W) and YCbCr or YUV images\n                # let's select y channel\n                return y_pred[:, 0, ...], y[:, 0, ...]\n\n            psnr = PSNR(data_range=219, output_transform=get_y_channel)\n            psnr.attach(default_evaluator, 'psnr')\n            preds = 219 * torch.rand([4, 3, 16, 16])\n            target = preds * 0.75\n            state = default_evaluator.run([[preds, target]])\n            print(state.metrics['psnr'])\n\n        .. testoutput::\n\n            16.7027966...\n\n    .. versionadded:: 0.4.3\n    \"\"\"\n\n    def __init__(\n        self,\n        data_range: Union[int, float],\n        output_transform: Callable = lambda x: x,\n        device: Union[str, torch.device] = torch.device(\"cpu\"),\n    ):\n        super().__init__(output_transform=output_transform, device=device)\n        self.data_range = data_range\n\n    def _check_shape_dtype(self, output: Sequence[torch.Tensor]) -> None:\n        y_pred, y = output\n        if y_pred.dtype != y.dtype:\n            raise TypeError(\n                f\"Expected y_pred and y to have the same data type. Got y_pred: {y_pred.dtype} and y: {y.dtype}.\"\n            )\n\n        if y_pred.shape != y.shape:\n            raise ValueError(\n                f\"Expected y_pred and y to have the same shape. Got y_pred: {y_pred.shape} and y: {y.shape}.\"\n            )\n\n    @reinit__is_reduced\n    def reset(self) -> None:\n        self._sum_of_batchwise_psnr = torch.tensor(0.0, dtype=torch.float64, device=self._device)\n        self._num_examples = 0\n\n    @reinit__is_reduced\n    def update(self, output: Sequence[torch.Tensor]) -> None:\n        self._check_shape_dtype(output)\n        y_pred, y = output[0].detach(), output[1].detach()\n\n        dim = tuple(range(1, y.ndim))\n        mse_error = torch.pow(y_pred.double() - y.view_as(y_pred).double(), 2).mean(dim=dim)\n        self._sum_of_batchwise_psnr += torch.sum(10.0 * torch.log10(self.data_range ** 2 / (mse_error + 1e-10))).to(\n            device=self._device\n        )\n        self._num_examples += y.shape[0]\n\n    @sync_all_reduce(\"_sum_of_batchwise_psnr\", \"_num_examples\")\n    def compute(self) -> torch.Tensor:\n        if self._num_examples == 0:\n            raise NotComputableError(\"PSNR must have at least one example before it can be computed.\")\n        return self._sum_of_batchwise_psnr / self._num_examples\n", "path": "ignite/metrics/psnr.py"}]}