prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Make default ingnored class to -100 in SDMGRLoss
  In most cases, class 0 should not be ignored.
  
  ref https://github.com/open-mmlab/mmocr/blob/main/mmocr/models/kie/losses/sdmgr_loss.py#L17
  
  </issue>
  <code>
  [start of mmocr/models/kie/losses/sdmgr_loss.py]
  1 import torch
  2 from torch import nn
  3 
  4 from mmdet.models.builder import LOSSES
  5 from mmdet.models.losses import accuracy
  6 
  7 
  8 @LOSSES.register_module()
  9 class SDMGRLoss(nn.Module):
  10     """The implementation the loss of key information extraction proposed in
  11     the paper: Spatial Dual-Modality Graph Reasoning for Key Information
  12     Extraction.
  13 
  14     https://arxiv.org/abs/2103.14470.
  15     """
  16 
  17     def __init__(self, node_weight=1.0, edge_weight=1.0, ignore=0):
  18         super().__init__()
  19         self.loss_node = nn.CrossEntropyLoss(ignore_index=ignore)
  20         self.loss_edge = nn.CrossEntropyLoss(ignore_index=-1)
  21         self.node_weight = node_weight
  22         self.edge_weight = edge_weight
  23         self.ignore = ignore
  24 
  25     def forward(self, node_preds, edge_preds, gts):
  26         node_gts, edge_gts = [], []
  27         for gt in gts:
  28             node_gts.append(gt[:, 0])
  29             edge_gts.append(gt[:, 1:].contiguous().view(-1))
  30         node_gts = torch.cat(node_gts).long()
  31         edge_gts = torch.cat(edge_gts).long()
  32 
  33         node_valids = torch.nonzero(node_gts != self.ignore).view(-1)
  34         edge_valids = torch.nonzero(edge_gts != -1).view(-1)
  35         return dict(
  36             loss_node=self.node_weight * self.loss_node(node_preds, node_gts),
  37             loss_edge=self.edge_weight * self.loss_edge(edge_preds, edge_gts),
  38             acc_node=accuracy(node_preds[node_valids], node_gts[node_valids]),
  39             acc_edge=accuracy(edge_preds[edge_valids], edge_gts[edge_valids]))
  40
  [end of mmocr/models/kie/losses/sdmgr_loss.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/mmocr/models/kie/losses/sdmgr_loss.py b/mmocr/models/kie/losses/sdmgr_loss.py
  --- a/mmocr/models/kie/losses/sdmgr_loss.py
  +++ b/mmocr/models/kie/losses/sdmgr_loss.py
  @@ -14,7 +14,7 @@
       https://arxiv.org/abs/2103.14470.
       """
   
  -    def __init__(self, node_weight=1.0, edge_weight=1.0, ignore=0):
  +    def __init__(self, node_weight=1.0, edge_weight=1.0, ignore=-100):
           super().__init__()
           self.loss_node = nn.CrossEntropyLoss(ignore_index=ignore)
           self.loss_edge = nn.CrossEntropyLoss(ignore_index=-1)
  
verification_info: {"golden_diff": "diff --git a/mmocr/models/kie/losses/sdmgr_loss.py b/mmocr/models/kie/losses/sdmgr_loss.py\n--- a/mmocr/models/kie/losses/sdmgr_loss.py\n+++ b/mmocr/models/kie/losses/sdmgr_loss.py\n@@ -14,7 +14,7 @@\n     https://arxiv.org/abs/2103.14470.\n     \"\"\"\n \n-    def __init__(self, node_weight=1.0, edge_weight=1.0, ignore=0):\n+    def __init__(self, node_weight=1.0, edge_weight=1.0, ignore=-100):\n         super().__init__()\n         self.loss_node = nn.CrossEntropyLoss(ignore_index=ignore)\n         self.loss_edge = nn.CrossEntropyLoss(ignore_index=-1)\n", "issue": "Make default ingnored class to -100 in SDMGRLoss\nIn most cases, class 0 should not be ignored.\r\n\r\nref https://github.com/open-mmlab/mmocr/blob/main/mmocr/models/kie/losses/sdmgr_loss.py#L17\n", "before_files": [{"content": "import torch\nfrom torch import nn\n\nfrom mmdet.models.builder import LOSSES\nfrom mmdet.models.losses import accuracy\n\n\n@LOSSES.register_module()\nclass SDMGRLoss(nn.Module):\n    \"\"\"The implementation the loss of key information extraction proposed in\n    the paper: Spatial Dual-Modality Graph Reasoning for Key Information\n    Extraction.\n\n    https://arxiv.org/abs/2103.14470.\n    \"\"\"\n\n    def __init__(self, node_weight=1.0, edge_weight=1.0, ignore=0):\n        super().__init__()\n        self.loss_node = nn.CrossEntropyLoss(ignore_index=ignore)\n        self.loss_edge = nn.CrossEntropyLoss(ignore_index=-1)\n        self.node_weight = node_weight\n        self.edge_weight = edge_weight\n        self.ignore = ignore\n\n    def forward(self, node_preds, edge_preds, gts):\n        node_gts, edge_gts = [], []\n        for gt in gts:\n            node_gts.append(gt[:, 0])\n            edge_gts.append(gt[:, 1:].contiguous().view(-1))\n        node_gts = torch.cat(node_gts).long()\n        edge_gts = torch.cat(edge_gts).long()\n\n        node_valids = torch.nonzero(node_gts != self.ignore).view(-1)\n        edge_valids = torch.nonzero(edge_gts != -1).view(-1)\n        return dict(\n            loss_node=self.node_weight * self.loss_node(node_preds, node_gts),\n            loss_edge=self.edge_weight * self.loss_edge(edge_preds, edge_gts),\n            acc_node=accuracy(node_preds[node_valids], node_gts[node_valids]),\n            acc_edge=accuracy(edge_preds[edge_valids], edge_gts[edge_valids]))\n", "path": "mmocr/models/kie/losses/sdmgr_loss.py"}]}