prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Backslash not showing in equation for Tversky Loss
  ## 📚 Documentation
  
  The backslashs in the denominator of the Tversky loss equation is not rendered correctly with MathJax. As shown in this screenshot it only inserts a little space between P and G and thus does not correctly render the equation.
  
  ![tversky_doc](https://user-images.githubusercontent.com/7403236/83774582-28e2c480-a686-11ea-8fd3-dbc509719885.png)
  
  
  <!-- A clear and concise description of what content in https://kornia.readthedocs.io is an issue. If this has to do with the general https://kornia.org website, please file an issue at https://github.com/kornia/kornia.github.io/issues/new/choose instead. If this has to do with https://kornia.org/tutorials, please file an issue at https://github.com/kornia/tutorials/issues/new -->
  
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `kornia/losses/tversky.py`
  Content:
  ```
  1 from typing import Optional
  2 
  3 import torch
  4 import torch.nn as nn
  5 import torch.nn.functional as F
  6 
  7 from kornia.utils import one_hot
  8 
  9 # based on:
  10 # https://github.com/kevinzakka/pytorch-goodies/blob/master/losses.py
  11 
  12 
  13 def tversky_loss(input: torch.Tensor, target: torch.Tensor,
  14                  alpha: float, beta: float, eps: float = 1e-8) -> torch.Tensor:
  15     r"""Function that computes Tversky loss.
  16 
  17     See :class:`~kornia.losses.TverskyLoss` for details.
  18     """
  19     if not torch.is_tensor(input):
  20         raise TypeError("Input type is not a torch.Tensor. Got {}"
  21                         .format(type(input)))
  22 
  23     if not len(input.shape) == 4:
  24         raise ValueError("Invalid input shape, we expect BxNxHxW. Got: {}"
  25                          .format(input.shape))
  26 
  27     if not input.shape[-2:] == target.shape[-2:]:
  28         raise ValueError("input and target shapes must be the same. Got: {} and {}"
  29                          .format(input.shape, input.shape))
  30 
  31     if not input.device == target.device:
  32         raise ValueError(
  33             "input and target must be in the same device. Got: {} and {}" .format(
  34                 input.device, target.device))
  35 
  36     # compute softmax over the classes axis
  37     input_soft: torch.Tensor = F.softmax(input, dim=1)
  38 
  39     # create the labels one hot tensor
  40     target_one_hot: torch.Tensor = one_hot(
  41         target, num_classes=input.shape[1],
  42         device=input.device, dtype=input.dtype)
  43 
  44     # compute the actual dice score
  45     dims = (1, 2, 3)
  46     intersection = torch.sum(input_soft * target_one_hot, dims)
  47     fps = torch.sum(input_soft * (-target_one_hot + 1.), dims)
  48     fns = torch.sum((-input_soft + 1.) * target_one_hot, dims)
  49 
  50     numerator = intersection
  51     denominator = intersection + alpha * fps + beta * fns
  52     tversky_loss = numerator / (denominator + eps)
  53     return torch.mean(-tversky_loss + 1.)
  54 
  55 
  56 class TverskyLoss(nn.Module):
  57     r"""Criterion that computes Tversky Coeficient loss.
  58 
  59     According to [1], we compute the Tversky Coefficient as follows:
  60 
  61     .. math::
  62 
  63         \text{S}(P, G, \alpha; \beta) =
  64           \frac{|PG|}{|PG| + \alpha |P \ G| + \beta |G \ P|}
  65 
  66     where:
  67        - :math:`P` and :math:`G` are the predicted and ground truth binary
  68          labels.
  69        - :math:`\alpha` and :math:`\beta` control the magnitude of the
  70          penalties for FPs and FNs, respectively.
  71 
  72     Notes:
  73        - :math:`\alpha = \beta = 0.5` => dice coeff
  74        - :math:`\alpha = \beta = 1` => tanimoto coeff
  75        - :math:`\alpha + \beta = 1` => F beta coeff
  76 
  77     Shape:
  78         - Input: :math:`(N, C, H, W)` where C = number of classes.
  79         - Target: :math:`(N, H, W)` where each value is
  80           :math:`0 ≤ targets[i] ≤ C−1`.
  81 
  82     Examples:
  83         >>> N = 5  # num_classes
  84         >>> loss = kornia.losses.TverskyLoss(alpha=0.5, beta=0.5)
  85         >>> input = torch.randn(1, N, 3, 5, requires_grad=True)
  86         >>> target = torch.empty(1, 3, 5, dtype=torch.long).random_(N)
  87         >>> output = loss(input, target)
  88         >>> output.backward()
  89 
  90     References:
  91         [1]: https://arxiv.org/abs/1706.05721
  92     """
  93 
  94     def __init__(self, alpha: float, beta: float, eps: float = 1e-8) -> None:
  95         super(TverskyLoss, self).__init__()
  96         self.alpha: float = alpha
  97         self.beta: float = beta
  98         self.eps: float = eps
  99 
  100     def forward(  # type: ignore
  101             self,
  102             input: torch.Tensor,
  103             target: torch.Tensor) -> torch.Tensor:
  104         return tversky_loss(input, target, self.alpha, self.beta, self.eps)
  105
  ```
  --- 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/kornia/losses/tversky.py b/kornia/losses/tversky.py
  --- a/kornia/losses/tversky.py
  +++ b/kornia/losses/tversky.py
  @@ -61,7 +61,7 @@
       .. math::
   
           \text{S}(P, G, \alpha; \beta) =
  -          \frac{|PG|}{|PG| + \alpha |P \ G| + \beta |G \ P|}
  +          \frac{|PG|}{|PG| + \alpha |P \setminus G| + \beta |G \setminus P|}
   
       where:
          - :math:`P` and :math:`G` are the predicted and ground truth binary
  
verification_info: {"golden_diff": "diff --git a/kornia/losses/tversky.py b/kornia/losses/tversky.py\n--- a/kornia/losses/tversky.py\n+++ b/kornia/losses/tversky.py\n@@ -61,7 +61,7 @@\n     .. math::\n \n         \\text{S}(P, G, \\alpha; \\beta) =\n-          \\frac{|PG|}{|PG| + \\alpha |P \\ G| + \\beta |G \\ P|}\n+          \\frac{|PG|}{|PG| + \\alpha |P \\setminus G| + \\beta |G \\setminus P|}\n \n     where:\n        - :math:`P` and :math:`G` are the predicted and ground truth binary\n", "issue": "Backslash not showing in equation for Tversky Loss\n## \ud83d\udcda Documentation\r\n\r\nThe backslashs in the denominator of the Tversky loss equation is not rendered correctly with MathJax. As shown in this screenshot it only inserts a little space between P and G and thus does not correctly render the equation.\r\n\r\n![tversky_doc](https://user-images.githubusercontent.com/7403236/83774582-28e2c480-a686-11ea-8fd3-dbc509719885.png)\r\n\r\n\r\n<!-- A clear and concise description of what content in https://kornia.readthedocs.io is an issue. If this has to do with the general https://kornia.org website, please file an issue at https://github.com/kornia/kornia.github.io/issues/new/choose instead. If this has to do with https://kornia.org/tutorials, please file an issue at https://github.com/kornia/tutorials/issues/new -->\r\n\r\n\n", "before_files": [{"content": "from typing import Optional\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nfrom kornia.utils import one_hot\n\n# based on:\n# https://github.com/kevinzakka/pytorch-goodies/blob/master/losses.py\n\n\ndef tversky_loss(input: torch.Tensor, target: torch.Tensor,\n                 alpha: float, beta: float, eps: float = 1e-8) -> torch.Tensor:\n    r\"\"\"Function that computes Tversky loss.\n\n    See :class:`~kornia.losses.TverskyLoss` for details.\n    \"\"\"\n    if not torch.is_tensor(input):\n        raise TypeError(\"Input type is not a torch.Tensor. Got {}\"\n                        .format(type(input)))\n\n    if not len(input.shape) == 4:\n        raise ValueError(\"Invalid input shape, we expect BxNxHxW. Got: {}\"\n                         .format(input.shape))\n\n    if not input.shape[-2:] == target.shape[-2:]:\n        raise ValueError(\"input and target shapes must be the same. Got: {} and {}\"\n                         .format(input.shape, input.shape))\n\n    if not input.device == target.device:\n        raise ValueError(\n            \"input and target must be in the same device. Got: {} and {}\" .format(\n                input.device, target.device))\n\n    # compute softmax over the classes axis\n    input_soft: torch.Tensor = F.softmax(input, dim=1)\n\n    # create the labels one hot tensor\n    target_one_hot: torch.Tensor = one_hot(\n        target, num_classes=input.shape[1],\n        device=input.device, dtype=input.dtype)\n\n    # compute the actual dice score\n    dims = (1, 2, 3)\n    intersection = torch.sum(input_soft * target_one_hot, dims)\n    fps = torch.sum(input_soft * (-target_one_hot + 1.), dims)\n    fns = torch.sum((-input_soft + 1.) * target_one_hot, dims)\n\n    numerator = intersection\n    denominator = intersection + alpha * fps + beta * fns\n    tversky_loss = numerator / (denominator + eps)\n    return torch.mean(-tversky_loss + 1.)\n\n\nclass TverskyLoss(nn.Module):\n    r\"\"\"Criterion that computes Tversky Coeficient loss.\n\n    According to [1], we compute the Tversky Coefficient as follows:\n\n    .. math::\n\n        \\text{S}(P, G, \\alpha; \\beta) =\n          \\frac{|PG|}{|PG| + \\alpha |P \\ G| + \\beta |G \\ P|}\n\n    where:\n       - :math:`P` and :math:`G` are the predicted and ground truth binary\n         labels.\n       - :math:`\\alpha` and :math:`\\beta` control the magnitude of the\n         penalties for FPs and FNs, respectively.\n\n    Notes:\n       - :math:`\\alpha = \\beta = 0.5` => dice coeff\n       - :math:`\\alpha = \\beta = 1` => tanimoto coeff\n       - :math:`\\alpha + \\beta = 1` => F beta coeff\n\n    Shape:\n        - Input: :math:`(N, C, H, W)` where C = number of classes.\n        - Target: :math:`(N, H, W)` where each value is\n          :math:`0 \u2264 targets[i] \u2264 C\u22121`.\n\n    Examples:\n        >>> N = 5  # num_classes\n        >>> loss = kornia.losses.TverskyLoss(alpha=0.5, beta=0.5)\n        >>> input = torch.randn(1, N, 3, 5, requires_grad=True)\n        >>> target = torch.empty(1, 3, 5, dtype=torch.long).random_(N)\n        >>> output = loss(input, target)\n        >>> output.backward()\n\n    References:\n        [1]: https://arxiv.org/abs/1706.05721\n    \"\"\"\n\n    def __init__(self, alpha: float, beta: float, eps: float = 1e-8) -> None:\n        super(TverskyLoss, self).__init__()\n        self.alpha: float = alpha\n        self.beta: float = beta\n        self.eps: float = eps\n\n    def forward(  # type: ignore\n            self,\n            input: torch.Tensor,\n            target: torch.Tensor) -> torch.Tensor:\n        return tversky_loss(input, target, self.alpha, self.beta, self.eps)\n", "path": "kornia/losses/tversky.py"}], "after_files": [{"content": "from typing import Optional\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nfrom kornia.utils import one_hot\n\n# based on:\n# https://github.com/kevinzakka/pytorch-goodies/blob/master/losses.py\n\n\ndef tversky_loss(input: torch.Tensor, target: torch.Tensor,\n                 alpha: float, beta: float, eps: float = 1e-8) -> torch.Tensor:\n    r\"\"\"Function that computes Tversky loss.\n\n    See :class:`~kornia.losses.TverskyLoss` for details.\n    \"\"\"\n    if not torch.is_tensor(input):\n        raise TypeError(\"Input type is not a torch.Tensor. Got {}\"\n                        .format(type(input)))\n\n    if not len(input.shape) == 4:\n        raise ValueError(\"Invalid input shape, we expect BxNxHxW. Got: {}\"\n                         .format(input.shape))\n\n    if not input.shape[-2:] == target.shape[-2:]:\n        raise ValueError(\"input and target shapes must be the same. Got: {} and {}\"\n                         .format(input.shape, input.shape))\n\n    if not input.device == target.device:\n        raise ValueError(\n            \"input and target must be in the same device. Got: {} and {}\" .format(\n                input.device, target.device))\n\n    # compute softmax over the classes axis\n    input_soft: torch.Tensor = F.softmax(input, dim=1)\n\n    # create the labels one hot tensor\n    target_one_hot: torch.Tensor = one_hot(\n        target, num_classes=input.shape[1],\n        device=input.device, dtype=input.dtype)\n\n    # compute the actual dice score\n    dims = (1, 2, 3)\n    intersection = torch.sum(input_soft * target_one_hot, dims)\n    fps = torch.sum(input_soft * (-target_one_hot + 1.), dims)\n    fns = torch.sum((-input_soft + 1.) * target_one_hot, dims)\n\n    numerator = intersection\n    denominator = intersection + alpha * fps + beta * fns\n    tversky_loss = numerator / (denominator + eps)\n    return torch.mean(-tversky_loss + 1.)\n\n\nclass TverskyLoss(nn.Module):\n    r\"\"\"Criterion that computes Tversky Coeficient loss.\n\n    According to [1], we compute the Tversky Coefficient as follows:\n\n    .. math::\n\n        \\text{S}(P, G, \\alpha; \\beta) =\n          \\frac{|PG|}{|PG| + \\alpha |P \\setminus G| + \\beta |G \\setminus P|}\n\n    where:\n       - :math:`P` and :math:`G` are the predicted and ground truth binary\n         labels.\n       - :math:`\\alpha` and :math:`\\beta` control the magnitude of the\n         penalties for FPs and FNs, respectively.\n\n    Notes:\n       - :math:`\\alpha = \\beta = 0.5` => dice coeff\n       - :math:`\\alpha = \\beta = 1` => tanimoto coeff\n       - :math:`\\alpha + \\beta = 1` => F beta coeff\n\n    Shape:\n        - Input: :math:`(N, C, H, W)` where C = number of classes.\n        - Target: :math:`(N, H, W)` where each value is\n          :math:`0 \u2264 targets[i] \u2264 C\u22121`.\n\n    Examples:\n        >>> N = 5  # num_classes\n        >>> loss = kornia.losses.TverskyLoss(alpha=0.5, beta=0.5)\n        >>> input = torch.randn(1, N, 3, 5, requires_grad=True)\n        >>> target = torch.empty(1, 3, 5, dtype=torch.long).random_(N)\n        >>> output = loss(input, target)\n        >>> output.backward()\n\n    References:\n        [1]: https://arxiv.org/abs/1706.05721\n    \"\"\"\n\n    def __init__(self, alpha: float, beta: float, eps: float = 1e-8) -> None:\n        super(TverskyLoss, self).__init__()\n        self.alpha: float = alpha\n        self.beta: float = beta\n        self.eps: float = eps\n\n    def forward(  # type: ignore\n            self,\n            input: torch.Tensor,\n            target: torch.Tensor) -> torch.Tensor:\n        return tversky_loss(input, target, self.alpha, self.beta, self.eps)\n", "path": "kornia/losses/tversky.py"}]}