prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Docstring of Canberra metric warning
  Following this comment 
  
  
  > @sdesrozis could you please investigate why there is a warning here : https://travis-ci.org/github/pytorch/ignite/jobs/730492404#L2924 
  thanks !
  > Doc link is apparently badly rendered : https://pytorch.org/ignite/master/contrib/metrics.html#ignite.contrib.metrics.regression.CanberraMetric
  > _Originally posted by @vfdev-5 in https://github.com/pytorch/ignite/pull/1314#issuecomment-699506241_
  
  Namespace are shared so reference should be unique
  
  
  </issue>
  <code>
  [start of ignite/contrib/metrics/regression/canberra_metric.py]
  1 from typing import Callable, Union
  2 
  3 import torch
  4 
  5 from ignite.contrib.metrics.regression._base import _BaseRegression
  6 from ignite.metrics.metric import reinit__is_reduced, sync_all_reduce
  7 
  8 
  9 class CanberraMetric(_BaseRegression):
  10     r"""
  11     Calculates the Canberra Metric.
  12 
  13     :math:`\text{CM} = \sum_{j=1}^n\frac{|A_j - P_j|}{|A_j| + |P_j|}`
  14 
  15     where, :math:`A_j` is the ground truth and :math:`P_j` is the predicted value.
  16 
  17     More details can be found in `Botchkarev 2018`_ or `scikit-learn distance metrics`_
  18 
  19     - ``update`` must receive output of the form ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``.
  20     - `y` and `y_pred` must be of same shape `(N, )` or `(N, 1)`.
  21 
  22     .. _Botchkarev 2018: https://arxiv.org/abs/1809.03006
  23     .. _scikit-learn distance metrics:
  24         https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.DistanceMetric.html
  25 
  26     """
  27 
  28     def __init__(
  29         self, output_transform: Callable = lambda x: x, device: Union[str, torch.device] = torch.device("cpu")
  30     ):
  31         self._sum_of_errors = None
  32         super(CanberraMetric, self).__init__(output_transform, device)
  33 
  34     @reinit__is_reduced
  35     def reset(self):
  36         self._sum_of_errors = torch.tensor(0.0, device=self._device)
  37 
  38     def _update(self, output):
  39         y_pred, y = output
  40         errors = torch.abs(y - y_pred) / (torch.abs(y_pred) + torch.abs(y))
  41         self._sum_of_errors += torch.sum(errors).to(self._device)
  42 
  43     @sync_all_reduce("_sum_of_errors")
  44     def compute(self):
  45         return self._sum_of_errors.item()
  46
  [end of ignite/contrib/metrics/regression/canberra_metric.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/regression/canberra_metric.py b/ignite/contrib/metrics/regression/canberra_metric.py
  --- a/ignite/contrib/metrics/regression/canberra_metric.py
  +++ b/ignite/contrib/metrics/regression/canberra_metric.py
  @@ -19,7 +19,6 @@
       - ``update`` must receive output of the form ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``.
       - `y` and `y_pred` must be of same shape `(N, )` or `(N, 1)`.
   
  -    .. _Botchkarev 2018: https://arxiv.org/abs/1809.03006
       .. _scikit-learn distance metrics:
           https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.DistanceMetric.html
  
verification_info: {"golden_diff": "diff --git a/ignite/contrib/metrics/regression/canberra_metric.py b/ignite/contrib/metrics/regression/canberra_metric.py\n--- a/ignite/contrib/metrics/regression/canberra_metric.py\n+++ b/ignite/contrib/metrics/regression/canberra_metric.py\n@@ -19,7 +19,6 @@\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-    .. _Botchkarev 2018: https://arxiv.org/abs/1809.03006\n     .. _scikit-learn distance metrics:\n         https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.DistanceMetric.html\n", "issue": "Docstring of Canberra metric warning\nFollowing this comment \r\n\r\n\r\n> @sdesrozis could you please investigate why there is a warning here : https://travis-ci.org/github/pytorch/ignite/jobs/730492404#L2924 \r\nthanks !\r\n> Doc link is apparently badly rendered : https://pytorch.org/ignite/master/contrib/metrics.html#ignite.contrib.metrics.regression.CanberraMetric\r\n> _Originally posted by @vfdev-5 in https://github.com/pytorch/ignite/pull/1314#issuecomment-699506241_\r\n\r\nNamespace are shared so reference should be unique\r\n\n", "before_files": [{"content": "from typing import Callable, Union\n\nimport torch\n\nfrom ignite.contrib.metrics.regression._base import _BaseRegression\nfrom ignite.metrics.metric import reinit__is_reduced, sync_all_reduce\n\n\nclass CanberraMetric(_BaseRegression):\n    r\"\"\"\n    Calculates the Canberra Metric.\n\n    :math:`\\text{CM} = \\sum_{j=1}^n\\frac{|A_j - P_j|}{|A_j| + |P_j|}`\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 `Botchkarev 2018`_ or `scikit-learn distance metrics`_\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    .. _Botchkarev 2018: https://arxiv.org/abs/1809.03006\n    .. _scikit-learn distance metrics:\n        https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.DistanceMetric.html\n\n    \"\"\"\n\n    def __init__(\n        self, output_transform: Callable = lambda x: x, device: Union[str, torch.device] = torch.device(\"cpu\")\n    ):\n        self._sum_of_errors = None\n        super(CanberraMetric, self).__init__(output_transform, device)\n\n    @reinit__is_reduced\n    def reset(self):\n        self._sum_of_errors = torch.tensor(0.0, device=self._device)\n\n    def _update(self, output):\n        y_pred, y = output\n        errors = torch.abs(y - y_pred) / (torch.abs(y_pred) + torch.abs(y))\n        self._sum_of_errors += torch.sum(errors).to(self._device)\n\n    @sync_all_reduce(\"_sum_of_errors\")\n    def compute(self):\n        return self._sum_of_errors.item()\n", "path": "ignite/contrib/metrics/regression/canberra_metric.py"}]}