prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Remove `activation` argument from AveragePrecision and ROC_AUC
  I propose to remove `activation` argument from `AveragePrecision` and `ROC_AUC`:
  https://github.com/pytorch/ignite/blob/862ab0073e461a32bf5b53fa015f88c143ae9079/ignite/contrib/metrics/roc_auc.py#L23-L28
  to be coherent with `Accuracy` et friends and the usage of `output_transform` to apply the binarization/activation :
  https://github.com/pytorch/ignite/blob/862ab0073e461a32bf5b53fa015f88c143ae9079/ignite/metrics/accuracy.py#L81-L93
  
  
  
  </issue>
  <code>
  [start of ignite/contrib/metrics/roc_auc.py]
  1 from functools import partial
  2 from ignite.metrics import EpochMetric
  3 
  4 
  5 def roc_auc_compute_fn(y_preds, y_targets, activation=None):
  6     try:
  7         from sklearn.metrics import roc_auc_score
  8     except ImportError:
  9         raise RuntimeError("This contrib module requires sklearn to be installed.")
  10 
  11     y_true = y_targets.numpy()
  12     if activation is not None:
  13         y_preds = activation(y_preds)
  14     y_pred = y_preds.numpy()
  15     return roc_auc_score(y_true, y_pred)
  16 
  17 
  18 class ROC_AUC(EpochMetric):
  19     """Computes Area Under the Receiver Operating Characteristic Curve (ROC AUC)
  20     accumulating predictions and the ground-truth during an epoch and applying
  21     `sklearn.metrics.roc_auc_score <http://scikit-learn.org/stable/modules/generated/
  22     sklearn.metrics.roc_auc_score.html#sklearn.metrics.roc_auc_score>`_ .
  23 
  24     Args:
  25         activation (callable, optional): optional function to apply on prediction tensors,
  26             e.g. `activation=torch.sigmoid` to transform logits.
  27         output_transform (callable, optional): a callable that is used to transform the
  28             :class:`~ignite.engine.Engine`'s `process_function`'s output into the
  29             form expected by the metric. This can be useful if, for example, you have a multi-output model and
  30             you want to compute the metric with respect to one of the outputs.
  31 
  32     """
  33     def __init__(self, activation=None, output_transform=lambda x: x):
  34         super(ROC_AUC, self).__init__(partial(roc_auc_compute_fn, activation=activation),
  35                                       output_transform=output_transform)
  36
  [end of ignite/contrib/metrics/roc_auc.py]
  [start of ignite/contrib/metrics/average_precision.py]
  1 from functools import partial
  2 from ignite.metrics import EpochMetric
  3 
  4 
  5 def average_precision_compute_fn(y_preds, y_targets, activation=None):
  6     try:
  7         from sklearn.metrics import average_precision_score
  8     except ImportError:
  9         raise RuntimeError("This contrib module requires sklearn to be installed.")
  10 
  11     y_true = y_targets.numpy()
  12     if activation is not None:
  13         y_preds = activation(y_preds)
  14     y_pred = y_preds.numpy()
  15     return average_precision_score(y_true, y_pred)
  16 
  17 
  18 class AveragePrecision(EpochMetric):
  19     """Computes Average Precision accumulating predictions and the ground-truth during an epoch
  20     and applying `sklearn.metrics.average_precision_score <http://scikit-learn.org/stable/modules/generated/
  21     sklearn.metrics.average_precision_score.html#sklearn.metrics.average_precision_score>`_ .
  22 
  23     Args:
  24         activation (callable, optional): optional function to apply on prediction tensors,
  25             e.g. `activation=torch.sigmoid` to transform logits.
  26         output_transform (callable, optional): a callable that is used to transform the
  27             :class:`~ignite.engine.Engine`'s `process_function`'s output into the
  28             form expected by the metric. This can be useful if, for example, you have a multi-output model and
  29             you want to compute the metric with respect to one of the outputs.
  30 
  31     """
  32     def __init__(self, activation=None, output_transform=lambda x: x):
  33         super(AveragePrecision, self).__init__(partial(average_precision_compute_fn, activation=activation),
  34                                                output_transform=output_transform)
  35
  [end of ignite/contrib/metrics/average_precision.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/ignite/contrib/metrics/average_precision.py b/ignite/contrib/metrics/average_precision.py
  --- a/ignite/contrib/metrics/average_precision.py
  +++ b/ignite/contrib/metrics/average_precision.py
  @@ -1,16 +1,13 @@
  -from functools import partial
   from ignite.metrics import EpochMetric
   
   
  -def average_precision_compute_fn(y_preds, y_targets, activation=None):
  +def average_precision_compute_fn(y_preds, y_targets):
       try:
           from sklearn.metrics import average_precision_score
       except ImportError:
           raise RuntimeError("This contrib module requires sklearn to be installed.")
   
       y_true = y_targets.numpy()
  -    if activation is not None:
  -        y_preds = activation(y_preds)
       y_pred = y_preds.numpy()
       return average_precision_score(y_true, y_pred)
   
  @@ -21,14 +18,23 @@
       sklearn.metrics.average_precision_score.html#sklearn.metrics.average_precision_score>`_ .
   
       Args:
  -        activation (callable, optional): optional function to apply on prediction tensors,
  -            e.g. `activation=torch.sigmoid` to transform logits.
           output_transform (callable, optional): a callable that is used to transform the
               :class:`~ignite.engine.Engine`'s `process_function`'s output into the
               form expected by the metric. This can be useful if, for example, you have a multi-output model and
               you want to compute the metric with respect to one of the outputs.
   
  +    AveragePrecision expects y to be comprised of 0's and 1's. y_pred must either be probability estimates or
  +    confidence values. To apply an activation to y_pred, use output_transform as shown below:
  +
  +    .. code-block:: python
  +
  +        def activated_output_transform(output):
  +            y_pred, y = output
  +            y_pred = torch.softmax(y_pred)
  +            return y_pred, y
  +
  +        avg_precision = AveragePrecision(activated_output_transform)
  +
       """
       def __init__(self, activation=None, output_transform=lambda x: x):
  -        super(AveragePrecision, self).__init__(partial(average_precision_compute_fn, activation=activation),
  -                                               output_transform=output_transform)
  +        super(AveragePrecision, self).__init__(average_precision_compute_fn, output_transform=output_transform)
  diff --git a/ignite/contrib/metrics/roc_auc.py b/ignite/contrib/metrics/roc_auc.py
  --- a/ignite/contrib/metrics/roc_auc.py
  +++ b/ignite/contrib/metrics/roc_auc.py
  @@ -1,16 +1,13 @@
  -from functools import partial
   from ignite.metrics import EpochMetric
   
   
  -def roc_auc_compute_fn(y_preds, y_targets, activation=None):
  +def roc_auc_compute_fn(y_preds, y_targets):
       try:
           from sklearn.metrics import roc_auc_score
       except ImportError:
           raise RuntimeError("This contrib module requires sklearn to be installed.")
   
       y_true = y_targets.numpy()
  -    if activation is not None:
  -        y_preds = activation(y_preds)
       y_pred = y_preds.numpy()
       return roc_auc_score(y_true, y_pred)
   
  @@ -22,14 +19,23 @@
       sklearn.metrics.roc_auc_score.html#sklearn.metrics.roc_auc_score>`_ .
   
       Args:
  -        activation (callable, optional): optional function to apply on prediction tensors,
  -            e.g. `activation=torch.sigmoid` to transform logits.
           output_transform (callable, optional): a callable that is used to transform the
               :class:`~ignite.engine.Engine`'s `process_function`'s output into the
               form expected by the metric. This can be useful if, for example, you have a multi-output model and
               you want to compute the metric with respect to one of the outputs.
   
  +    ROC_AUC expects y to be comprised of 0's and 1's. y_pred must either be probability estimates or confidence
  +    values. To apply an activation to y_pred, use output_transform as shown below:
  +
  +    .. code-block:: python
  +
  +        def activated_output_transform(output):
  +            y_pred, y = output
  +            y_pred = torch.sigmoid(y_pred)
  +            return y_pred, y
  +
  +        roc_auc = ROC_AUC(activated_output_transform)
  +
       """
  -    def __init__(self, activation=None, output_transform=lambda x: x):
  -        super(ROC_AUC, self).__init__(partial(roc_auc_compute_fn, activation=activation),
  -                                      output_transform=output_transform)
  +    def __init__(self, output_transform=lambda x: x):
  +        super(ROC_AUC, self).__init__(roc_auc_compute_fn, output_transform=output_transform)
  
verification_info: {"golden_diff": "diff --git a/ignite/contrib/metrics/average_precision.py b/ignite/contrib/metrics/average_precision.py\n--- a/ignite/contrib/metrics/average_precision.py\n+++ b/ignite/contrib/metrics/average_precision.py\n@@ -1,16 +1,13 @@\n-from functools import partial\n from ignite.metrics import EpochMetric\n \n \n-def average_precision_compute_fn(y_preds, y_targets, activation=None):\n+def average_precision_compute_fn(y_preds, y_targets):\n     try:\n         from sklearn.metrics import average_precision_score\n     except ImportError:\n         raise RuntimeError(\"This contrib module requires sklearn to be installed.\")\n \n     y_true = y_targets.numpy()\n-    if activation is not None:\n-        y_preds = activation(y_preds)\n     y_pred = y_preds.numpy()\n     return average_precision_score(y_true, y_pred)\n \n@@ -21,14 +18,23 @@\n     sklearn.metrics.average_precision_score.html#sklearn.metrics.average_precision_score>`_ .\n \n     Args:\n-        activation (callable, optional): optional function to apply on prediction tensors,\n-            e.g. `activation=torch.sigmoid` to transform logits.\n         output_transform (callable, optional): a callable that is used to transform the\n             :class:`~ignite.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 \n+    AveragePrecision expects y to be comprised of 0's and 1's. y_pred must either be probability estimates or\n+    confidence values. To apply an activation to y_pred, use output_transform as shown below:\n+\n+    .. code-block:: python\n+\n+        def activated_output_transform(output):\n+            y_pred, y = output\n+            y_pred = torch.softmax(y_pred)\n+            return y_pred, y\n+\n+        avg_precision = AveragePrecision(activated_output_transform)\n+\n     \"\"\"\n     def __init__(self, activation=None, output_transform=lambda x: x):\n-        super(AveragePrecision, self).__init__(partial(average_precision_compute_fn, activation=activation),\n-                                               output_transform=output_transform)\n+        super(AveragePrecision, self).__init__(average_precision_compute_fn, output_transform=output_transform)\ndiff --git a/ignite/contrib/metrics/roc_auc.py b/ignite/contrib/metrics/roc_auc.py\n--- a/ignite/contrib/metrics/roc_auc.py\n+++ b/ignite/contrib/metrics/roc_auc.py\n@@ -1,16 +1,13 @@\n-from functools import partial\n from ignite.metrics import EpochMetric\n \n \n-def roc_auc_compute_fn(y_preds, y_targets, activation=None):\n+def roc_auc_compute_fn(y_preds, y_targets):\n     try:\n         from sklearn.metrics import roc_auc_score\n     except ImportError:\n         raise RuntimeError(\"This contrib module requires sklearn to be installed.\")\n \n     y_true = y_targets.numpy()\n-    if activation is not None:\n-        y_preds = activation(y_preds)\n     y_pred = y_preds.numpy()\n     return roc_auc_score(y_true, y_pred)\n \n@@ -22,14 +19,23 @@\n     sklearn.metrics.roc_auc_score.html#sklearn.metrics.roc_auc_score>`_ .\n \n     Args:\n-        activation (callable, optional): optional function to apply on prediction tensors,\n-            e.g. `activation=torch.sigmoid` to transform logits.\n         output_transform (callable, optional): a callable that is used to transform the\n             :class:`~ignite.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 \n+    ROC_AUC expects y to be comprised of 0's and 1's. y_pred must either be probability estimates or confidence\n+    values. To apply an activation to y_pred, use output_transform as shown below:\n+\n+    .. code-block:: python\n+\n+        def activated_output_transform(output):\n+            y_pred, y = output\n+            y_pred = torch.sigmoid(y_pred)\n+            return y_pred, y\n+\n+        roc_auc = ROC_AUC(activated_output_transform)\n+\n     \"\"\"\n-    def __init__(self, activation=None, output_transform=lambda x: x):\n-        super(ROC_AUC, self).__init__(partial(roc_auc_compute_fn, activation=activation),\n-                                      output_transform=output_transform)\n+    def __init__(self, output_transform=lambda x: x):\n+        super(ROC_AUC, self).__init__(roc_auc_compute_fn, output_transform=output_transform)\n", "issue": "Remove `activation` argument from AveragePrecision and ROC_AUC\nI propose to remove `activation` argument from `AveragePrecision` and `ROC_AUC`:\r\nhttps://github.com/pytorch/ignite/blob/862ab0073e461a32bf5b53fa015f88c143ae9079/ignite/contrib/metrics/roc_auc.py#L23-L28\r\nto be coherent with `Accuracy` et friends and the usage of `output_transform` to apply the binarization/activation :\r\nhttps://github.com/pytorch/ignite/blob/862ab0073e461a32bf5b53fa015f88c143ae9079/ignite/metrics/accuracy.py#L81-L93\r\n\r\n\n", "before_files": [{"content": "from functools import partial\nfrom ignite.metrics import EpochMetric\n\n\ndef roc_auc_compute_fn(y_preds, y_targets, activation=None):\n    try:\n        from sklearn.metrics import roc_auc_score\n    except ImportError:\n        raise RuntimeError(\"This contrib module requires sklearn to be installed.\")\n\n    y_true = y_targets.numpy()\n    if activation is not None:\n        y_preds = activation(y_preds)\n    y_pred = y_preds.numpy()\n    return roc_auc_score(y_true, y_pred)\n\n\nclass ROC_AUC(EpochMetric):\n    \"\"\"Computes Area Under the Receiver Operating Characteristic Curve (ROC AUC)\n    accumulating predictions and the ground-truth during an epoch and applying\n    `sklearn.metrics.roc_auc_score <http://scikit-learn.org/stable/modules/generated/\n    sklearn.metrics.roc_auc_score.html#sklearn.metrics.roc_auc_score>`_ .\n\n    Args:\n        activation (callable, optional): optional function to apply on prediction tensors,\n            e.g. `activation=torch.sigmoid` to transform logits.\n        output_transform (callable, optional): a callable that is used to transform the\n            :class:`~ignite.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\n    \"\"\"\n    def __init__(self, activation=None, output_transform=lambda x: x):\n        super(ROC_AUC, self).__init__(partial(roc_auc_compute_fn, activation=activation),\n                                      output_transform=output_transform)\n", "path": "ignite/contrib/metrics/roc_auc.py"}, {"content": "from functools import partial\nfrom ignite.metrics import EpochMetric\n\n\ndef average_precision_compute_fn(y_preds, y_targets, activation=None):\n    try:\n        from sklearn.metrics import average_precision_score\n    except ImportError:\n        raise RuntimeError(\"This contrib module requires sklearn to be installed.\")\n\n    y_true = y_targets.numpy()\n    if activation is not None:\n        y_preds = activation(y_preds)\n    y_pred = y_preds.numpy()\n    return average_precision_score(y_true, y_pred)\n\n\nclass AveragePrecision(EpochMetric):\n    \"\"\"Computes Average Precision accumulating predictions and the ground-truth during an epoch\n    and applying `sklearn.metrics.average_precision_score <http://scikit-learn.org/stable/modules/generated/\n    sklearn.metrics.average_precision_score.html#sklearn.metrics.average_precision_score>`_ .\n\n    Args:\n        activation (callable, optional): optional function to apply on prediction tensors,\n            e.g. `activation=torch.sigmoid` to transform logits.\n        output_transform (callable, optional): a callable that is used to transform the\n            :class:`~ignite.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\n    \"\"\"\n    def __init__(self, activation=None, output_transform=lambda x: x):\n        super(AveragePrecision, self).__init__(partial(average_precision_compute_fn, activation=activation),\n                                               output_transform=output_transform)\n", "path": "ignite/contrib/metrics/average_precision.py"}]}