We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[CI] Doc test is failing
We have somehow doctest ci job failing right now. The failure happens with the following code snippet from our docs: 
- https://pytorch.org/ignite/generated/ignite.contrib.metrics.PrecisionRecallCurve.html

```
 **********************************************************************
File "../../ignite/contrib/metrics/precision_recall_curve.py", line ?, in default
Failed example:
    y_pred = torch.tensor([0.0474, 0.5987, 0.7109, 0.9997])
    y_true = torch.tensor([0, 0, 1, 1])
    prec_recall_curve = PrecisionRecallCurve()
    prec_recall_curve.attach(default_evaluator, 'prec_recall_curve')
    state = default_evaluator.run([[y_pred, y_true]])

    print("Precision", [round(i, 4) for i in state.metrics['prec_recall_curve'][0].tolist()])
    print("Recall", [round(i, 4) for i in state.metrics['prec_recall_curve'][1].tolist()])
    print("Thresholds", [round(i, 4) for i in state.metrics['prec_recall_curve'][2].tolist()])
Expected:
    Precision [1.0, 1.0, 1.0]
    Recall [1.0, 0.5, 0.0]
    Thresholds [0.7109, 0.9997]
Got:
    Precision [0.5, 0.6667, 1.0, 1.0, 1.0]
    Recall [1.0, 1.0, 1.0, 0.5, 0.0]
    Thresholds [0.0474, 0.5987, 0.7109, 0.9997]
```
- https://github.com/pytorch/ignite/actions/runs/4099985910/jobs/7074343114

### How to help with this issue

You need to do some detective work:
- Reproduce the issue locally
- Try to figure out which result is correct: "Expected" or "Got"
- Try to figure out why it started to happen: maybe sklearn version updated ? Previously, for example Jan 18, doctest was passing: https://github.com/pytorch/ignite/actions/runs/3894024421/jobs/6647420435
- Report here your findings and propose a way to solve the issue


--- 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/precision_recall_curve.py`
Content:
```
1 from typing import Any, Callable, cast, Tuple, Union
2 
3 import torch
4 
5 import ignite.distributed as idist
6 from ignite.exceptions import NotComputableError
7 from ignite.metrics import EpochMetric
8 
9 
10 def precision_recall_curve_compute_fn(y_preds: torch.Tensor, y_targets: torch.Tensor) -> Tuple[Any, Any, Any]:
11     try:
12         from sklearn.metrics import precision_recall_curve
13     except ImportError:
14         raise ModuleNotFoundError("This contrib module requires scikit-learn to be installed.")
15 
16     y_true = y_targets.cpu().numpy()
17     y_pred = y_preds.cpu().numpy()
18     return precision_recall_curve(y_true, y_pred)
19 
20 
21 class PrecisionRecallCurve(EpochMetric):
22     """Compute precision-recall pairs for different probability thresholds for binary classification task
23     by accumulating predictions and the ground-truth during an epoch and applying
24     `sklearn.metrics.precision_recall_curve <https://scikit-learn.org/stable/modules/generated/
25     sklearn.metrics.precision_recall_curve.html#sklearn.metrics.precision_recall_curve>`_ .
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         check_compute_fn: Default False. If True, `precision_recall_curve
33             <https://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_recall_curve.html
34             #sklearn.metrics.precision_recall_curve>`_ is run on the first batch of data to ensure there are
35             no issues. User will be warned in case there are any issues computing the function.
36 
37     Note:
38         PrecisionRecallCurve expects y to be comprised of 0's and 1's. y_pred must either be probability estimates
39         or confidence values. To apply an activation to y_pred, use output_transform as shown below:
40 
41         .. code-block:: python
42 
43             def sigmoid_output_transform(output):
44                 y_pred, y = output
45                 y_pred = torch.sigmoid(y_pred)
46                 return y_pred, y
47             avg_precision = PrecisionRecallCurve(sigmoid_output_transform)
48 
49     Examples:
50 
51         .. include:: defaults.rst
52             :start-after: :orphan:
53 
54         .. testcode::
55 
56             y_pred = torch.tensor([0.0474, 0.5987, 0.7109, 0.9997])
57             y_true = torch.tensor([0, 0, 1, 1])
58             prec_recall_curve = PrecisionRecallCurve()
59             prec_recall_curve.attach(default_evaluator, 'prec_recall_curve')
60             state = default_evaluator.run([[y_pred, y_true]])
61 
62             print("Precision", [round(i, 4) for i in state.metrics['prec_recall_curve'][0].tolist()])
63             print("Recall", [round(i, 4) for i in state.metrics['prec_recall_curve'][1].tolist()])
64             print("Thresholds", [round(i, 4) for i in state.metrics['prec_recall_curve'][2].tolist()])
65 
66         .. testoutput::
67 
68             Precision [1.0, 1.0, 1.0]
69             Recall [1.0, 0.5, 0.0]
70             Thresholds [0.7109, 0.9997]
71 
72     """
73 
74     def __init__(
75         self,
76         output_transform: Callable = lambda x: x,
77         check_compute_fn: bool = False,
78         device: Union[str, torch.device] = torch.device("cpu"),
79     ) -> None:
80         super(PrecisionRecallCurve, self).__init__(
81             precision_recall_curve_compute_fn,
82             output_transform=output_transform,
83             check_compute_fn=check_compute_fn,
84             device=device,
85         )
86 
87     def compute(self) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
88         if len(self._predictions) < 1 or len(self._targets) < 1:
89             raise NotComputableError("PrecisionRecallCurve must have at least one example before it can be computed.")
90 
91         _prediction_tensor = torch.cat(self._predictions, dim=0)
92         _target_tensor = torch.cat(self._targets, dim=0)
93 
94         ws = idist.get_world_size()
95         if ws > 1 and not self._is_reduced:
96             # All gather across all processes
97             _prediction_tensor = cast(torch.Tensor, idist.all_gather(_prediction_tensor))
98             _target_tensor = cast(torch.Tensor, idist.all_gather(_target_tensor))
99         self._is_reduced = True
100 
101         if idist.get_rank() == 0:
102             # Run compute_fn on zero rank only
103             precision, recall, thresholds = self.compute_fn(_prediction_tensor, _target_tensor)
104             precision = torch.tensor(precision)
105             recall = torch.tensor(recall)
106             # thresholds can have negative strides, not compatible with torch tensors
107             # https://discuss.pytorch.org/t/negative-strides-in-tensor-error/134287/2
108             thresholds = torch.tensor(thresholds.copy())
109         else:
110             precision, recall, thresholds = None, None, None
111 
112         if ws > 1:
113             # broadcast result to all processes
114             precision = idist.broadcast(precision, src=0, safe_mode=True)
115             recall = idist.broadcast(recall, src=0, safe_mode=True)
116             thresholds = idist.broadcast(thresholds, src=0, safe_mode=True)
117 
118         return precision, recall, thresholds
119
```
--- 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/precision_recall_curve.py b/ignite/contrib/metrics/precision_recall_curve.py
--- a/ignite/contrib/metrics/precision_recall_curve.py
+++ b/ignite/contrib/metrics/precision_recall_curve.py
@@ -65,9 +65,9 @@
 
         .. testoutput::
 
-            Precision [1.0, 1.0, 1.0]
-            Recall [1.0, 0.5, 0.0]
-            Thresholds [0.7109, 0.9997]
+            Precision [0.5, 0.6667, 1.0, 1.0, 1.0]
+            Recall [1.0, 1.0, 1.0, 0.5, 0.0]
+            Thresholds [0.0474, 0.5987, 0.7109, 0.9997]
 
     """

{"golden_diff": "diff --git a/ignite/contrib/metrics/precision_recall_curve.py b/ignite/contrib/metrics/precision_recall_curve.py\n--- a/ignite/contrib/metrics/precision_recall_curve.py\n+++ b/ignite/contrib/metrics/precision_recall_curve.py\n@@ -65,9 +65,9 @@\n \n         .. testoutput::\n \n-            Precision [1.0, 1.0, 1.0]\n-            Recall [1.0, 0.5, 0.0]\n-            Thresholds [0.7109, 0.9997]\n+            Precision [0.5, 0.6667, 1.0, 1.0, 1.0]\n+            Recall [1.0, 1.0, 1.0, 0.5, 0.0]\n+            Thresholds [0.0474, 0.5987, 0.7109, 0.9997]\n \n     \"\"\"\n", "issue": "[CI] Doc test is failing\nWe have somehow doctest ci job failing right now. The failure happens with the following code snippet from our docs: \r\n- https://pytorch.org/ignite/generated/ignite.contrib.metrics.PrecisionRecallCurve.html\r\n\r\n```\r\n **********************************************************************\r\nFile \"../../ignite/contrib/metrics/precision_recall_curve.py\", line ?, in default\r\nFailed example:\r\n    y_pred = torch.tensor([0.0474, 0.5987, 0.7109, 0.9997])\r\n    y_true = torch.tensor([0, 0, 1, 1])\r\n    prec_recall_curve = PrecisionRecallCurve()\r\n    prec_recall_curve.attach(default_evaluator, 'prec_recall_curve')\r\n    state = default_evaluator.run([[y_pred, y_true]])\r\n\r\n    print(\"Precision\", [round(i, 4) for i in state.metrics['prec_recall_curve'][0].tolist()])\r\n    print(\"Recall\", [round(i, 4) for i in state.metrics['prec_recall_curve'][1].tolist()])\r\n    print(\"Thresholds\", [round(i, 4) for i in state.metrics['prec_recall_curve'][2].tolist()])\r\nExpected:\r\n    Precision [1.0, 1.0, 1.0]\r\n    Recall [1.0, 0.5, 0.0]\r\n    Thresholds [0.7109, 0.9997]\r\nGot:\r\n    Precision [0.5, 0.6667, 1.0, 1.0, 1.0]\r\n    Recall [1.0, 1.0, 1.0, 0.5, 0.0]\r\n    Thresholds [0.0474, 0.5987, 0.7109, 0.9997]\r\n```\r\n- https://github.com/pytorch/ignite/actions/runs/4099985910/jobs/7074343114\r\n\r\n### How to help with this issue\r\n\r\nYou need to do some detective work:\r\n- Reproduce the issue locally\r\n- Try to figure out which result is correct: \"Expected\" or \"Got\"\r\n- Try to figure out why it started to happen: maybe sklearn version updated ? Previously, for example Jan 18, doctest was passing: https://github.com/pytorch/ignite/actions/runs/3894024421/jobs/6647420435\r\n- Report here your findings and propose a way to solve the issue\r\n\n", "before_files": [{"content": "from typing import Any, Callable, cast, Tuple, Union\n\nimport torch\n\nimport ignite.distributed as idist\nfrom ignite.exceptions import NotComputableError\nfrom ignite.metrics import EpochMetric\n\n\ndef precision_recall_curve_compute_fn(y_preds: torch.Tensor, y_targets: torch.Tensor) -> Tuple[Any, Any, Any]:\n    try:\n        from sklearn.metrics import precision_recall_curve\n    except ImportError:\n        raise ModuleNotFoundError(\"This contrib module requires scikit-learn to be installed.\")\n\n    y_true = y_targets.cpu().numpy()\n    y_pred = y_preds.cpu().numpy()\n    return precision_recall_curve(y_true, y_pred)\n\n\nclass PrecisionRecallCurve(EpochMetric):\n    \"\"\"Compute precision-recall pairs for different probability thresholds for binary classification task\n    by accumulating predictions and the ground-truth during an epoch and applying\n    `sklearn.metrics.precision_recall_curve <https://scikit-learn.org/stable/modules/generated/\n    sklearn.metrics.precision_recall_curve.html#sklearn.metrics.precision_recall_curve>`_ .\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        check_compute_fn: Default False. If True, `precision_recall_curve\n            <https://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_recall_curve.html\n            #sklearn.metrics.precision_recall_curve>`_ is run on the first batch of data to ensure there are\n            no issues. User will be warned in case there are any issues computing the function.\n\n    Note:\n        PrecisionRecallCurve expects y to be comprised of 0's and 1's. y_pred must either be probability estimates\n        or confidence values. To apply an activation to y_pred, use output_transform as shown below:\n\n        .. code-block:: python\n\n            def sigmoid_output_transform(output):\n                y_pred, y = output\n                y_pred = torch.sigmoid(y_pred)\n                return y_pred, y\n            avg_precision = PrecisionRecallCurve(sigmoid_output_transform)\n\n    Examples:\n\n        .. include:: defaults.rst\n            :start-after: :orphan:\n\n        .. testcode::\n\n            y_pred = torch.tensor([0.0474, 0.5987, 0.7109, 0.9997])\n            y_true = torch.tensor([0, 0, 1, 1])\n            prec_recall_curve = PrecisionRecallCurve()\n            prec_recall_curve.attach(default_evaluator, 'prec_recall_curve')\n            state = default_evaluator.run([[y_pred, y_true]])\n\n            print(\"Precision\", [round(i, 4) for i in state.metrics['prec_recall_curve'][0].tolist()])\n            print(\"Recall\", [round(i, 4) for i in state.metrics['prec_recall_curve'][1].tolist()])\n            print(\"Thresholds\", [round(i, 4) for i in state.metrics['prec_recall_curve'][2].tolist()])\n\n        .. testoutput::\n\n            Precision [1.0, 1.0, 1.0]\n            Recall [1.0, 0.5, 0.0]\n            Thresholds [0.7109, 0.9997]\n\n    \"\"\"\n\n    def __init__(\n        self,\n        output_transform: Callable = lambda x: x,\n        check_compute_fn: bool = False,\n        device: Union[str, torch.device] = torch.device(\"cpu\"),\n    ) -> None:\n        super(PrecisionRecallCurve, self).__init__(\n            precision_recall_curve_compute_fn,\n            output_transform=output_transform,\n            check_compute_fn=check_compute_fn,\n            device=device,\n        )\n\n    def compute(self) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:\n        if len(self._predictions) < 1 or len(self._targets) < 1:\n            raise NotComputableError(\"PrecisionRecallCurve must have at least one example before it can be computed.\")\n\n        _prediction_tensor = torch.cat(self._predictions, dim=0)\n        _target_tensor = torch.cat(self._targets, dim=0)\n\n        ws = idist.get_world_size()\n        if ws > 1 and not self._is_reduced:\n            # All gather across all processes\n            _prediction_tensor = cast(torch.Tensor, idist.all_gather(_prediction_tensor))\n            _target_tensor = cast(torch.Tensor, idist.all_gather(_target_tensor))\n        self._is_reduced = True\n\n        if idist.get_rank() == 0:\n            # Run compute_fn on zero rank only\n            precision, recall, thresholds = self.compute_fn(_prediction_tensor, _target_tensor)\n            precision = torch.tensor(precision)\n            recall = torch.tensor(recall)\n            # thresholds can have negative strides, not compatible with torch tensors\n            # https://discuss.pytorch.org/t/negative-strides-in-tensor-error/134287/2\n            thresholds = torch.tensor(thresholds.copy())\n        else:\n            precision, recall, thresholds = None, None, None\n\n        if ws > 1:\n            # broadcast result to all processes\n            precision = idist.broadcast(precision, src=0, safe_mode=True)\n            recall = idist.broadcast(recall, src=0, safe_mode=True)\n            thresholds = idist.broadcast(thresholds, src=0, safe_mode=True)\n\n        return precision, recall, thresholds\n", "path": "ignite/contrib/metrics/precision_recall_curve.py"}], "after_files": [{"content": "from typing import Any, Callable, cast, Tuple, Union\n\nimport torch\n\nimport ignite.distributed as idist\nfrom ignite.exceptions import NotComputableError\nfrom ignite.metrics import EpochMetric\n\n\ndef precision_recall_curve_compute_fn(y_preds: torch.Tensor, y_targets: torch.Tensor) -> Tuple[Any, Any, Any]:\n    try:\n        from sklearn.metrics import precision_recall_curve\n    except ImportError:\n        raise ModuleNotFoundError(\"This contrib module requires scikit-learn to be installed.\")\n\n    y_true = y_targets.cpu().numpy()\n    y_pred = y_preds.cpu().numpy()\n    return precision_recall_curve(y_true, y_pred)\n\n\nclass PrecisionRecallCurve(EpochMetric):\n    \"\"\"Compute precision-recall pairs for different probability thresholds for binary classification task\n    by accumulating predictions and the ground-truth during an epoch and applying\n    `sklearn.metrics.precision_recall_curve <https://scikit-learn.org/stable/modules/generated/\n    sklearn.metrics.precision_recall_curve.html#sklearn.metrics.precision_recall_curve>`_ .\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        check_compute_fn: Default False. If True, `precision_recall_curve\n            <https://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_recall_curve.html\n            #sklearn.metrics.precision_recall_curve>`_ is run on the first batch of data to ensure there are\n            no issues. User will be warned in case there are any issues computing the function.\n\n    Note:\n        PrecisionRecallCurve expects y to be comprised of 0's and 1's. y_pred must either be probability estimates\n        or confidence values. To apply an activation to y_pred, use output_transform as shown below:\n\n        .. code-block:: python\n\n            def sigmoid_output_transform(output):\n                y_pred, y = output\n                y_pred = torch.sigmoid(y_pred)\n                return y_pred, y\n            avg_precision = PrecisionRecallCurve(sigmoid_output_transform)\n\n    Examples:\n\n        .. include:: defaults.rst\n            :start-after: :orphan:\n\n        .. testcode::\n\n            y_pred = torch.tensor([0.0474, 0.5987, 0.7109, 0.9997])\n            y_true = torch.tensor([0, 0, 1, 1])\n            prec_recall_curve = PrecisionRecallCurve()\n            prec_recall_curve.attach(default_evaluator, 'prec_recall_curve')\n            state = default_evaluator.run([[y_pred, y_true]])\n\n            print(\"Precision\", [round(i, 4) for i in state.metrics['prec_recall_curve'][0].tolist()])\n            print(\"Recall\", [round(i, 4) for i in state.metrics['prec_recall_curve'][1].tolist()])\n            print(\"Thresholds\", [round(i, 4) for i in state.metrics['prec_recall_curve'][2].tolist()])\n\n        .. testoutput::\n\n            Precision [0.5, 0.6667, 1.0, 1.0, 1.0]\n            Recall [1.0, 1.0, 1.0, 0.5, 0.0]\n            Thresholds [0.0474, 0.5987, 0.7109, 0.9997]\n\n    \"\"\"\n\n    def __init__(\n        self,\n        output_transform: Callable = lambda x: x,\n        check_compute_fn: bool = False,\n        device: Union[str, torch.device] = torch.device(\"cpu\"),\n    ) -> None:\n        super(PrecisionRecallCurve, self).__init__(\n            precision_recall_curve_compute_fn,\n            output_transform=output_transform,\n            check_compute_fn=check_compute_fn,\n            device=device,\n        )\n\n    def compute(self) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:\n        if len(self._predictions) < 1 or len(self._targets) < 1:\n            raise NotComputableError(\"PrecisionRecallCurve must have at least one example before it can be computed.\")\n\n        _prediction_tensor = torch.cat(self._predictions, dim=0)\n        _target_tensor = torch.cat(self._targets, dim=0)\n\n        ws = idist.get_world_size()\n        if ws > 1 and not self._is_reduced:\n            # All gather across all processes\n            _prediction_tensor = cast(torch.Tensor, idist.all_gather(_prediction_tensor))\n            _target_tensor = cast(torch.Tensor, idist.all_gather(_target_tensor))\n        self._is_reduced = True\n\n        if idist.get_rank() == 0:\n            # Run compute_fn on zero rank only\n            precision, recall, thresholds = self.compute_fn(_prediction_tensor, _target_tensor)\n            precision = torch.tensor(precision)\n            recall = torch.tensor(recall)\n            # thresholds can have negative strides, not compatible with torch tensors\n            # https://discuss.pytorch.org/t/negative-strides-in-tensor-error/134287/2\n            thresholds = torch.tensor(thresholds.copy())\n        else:\n            precision, recall, thresholds = None, None, None\n\n        if ws > 1:\n            # broadcast result to all processes\n            precision = idist.broadcast(precision, src=0, safe_mode=True)\n            recall = idist.broadcast(recall, src=0, safe_mode=True)\n            thresholds = idist.broadcast(thresholds, src=0, safe_mode=True)\n\n        return precision, recall, thresholds\n", "path": "ignite/contrib/metrics/precision_recall_curve.py"}]}