prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Error get params DETR/ Deformable DETR
  Despite my attempts to modify, also just testing with the basic config detr file. 
  Maybe this issue has already been raised?
  mmdet==2.13.0
  mmcv=1.3.3
  
  ```python
  python tools/analysis_tools/get_flops.py configs/detr/detr_r50_8x2_150e_coco.py
  ```
  
  ```python
  /home/bluav/mmdetection/mmdet/models/backbones/resnet.py:400: UserWarning: DeprecationWarning: pretrained is a deprecated, please use "init_cfg" instead
    warnings.warn('DeprecationWarning: pretrained is a deprecated, '
  Warning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!
  Warning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!
  Warning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!
  Warning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!
  Warning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!
  Warning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!
  Warning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!
  Warning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!
  Warning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!
  Warning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!
  Warning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!
  Warning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!
  Warning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!
  Traceback (most recent call last):
    File "tools/analysis_tools/get_flops.py", line 81, in <module>
      main()
    File "tools/analysis_tools/get_flops.py", line 71, in main
      flops, params = get_model_complexity_info(model, input_shape)
    File "/home/bluav/.conda/envs/open-mmlab/lib/python3.7/site-packages/mmcv/cnn/utils/flops_counter.py", line 104, in get_model_complexity_info
      _ = flops_model(batch)
    File "/home/bluav/.conda/envs/open-mmlab/lib/python3.7/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
      result = self.forward(*input, **kwargs)
    File "/home/bluav/mmdetection/mmdet/models/detectors/single_stage.py", line 48, in forward_dummy
      outs = self.bbox_head(x)
    File "/home/bluav/.conda/envs/open-mmlab/lib/python3.7/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
      result = self.forward(*input, **kwargs)
  TypeError: forward() missing 1 required positional argument: 'img_metas'
  ```
  
  
  </issue>
  <code>
  [start of mmdet/models/detectors/detr.py]
  1 import torch
  2 
  3 from ..builder import DETECTORS
  4 from .single_stage import SingleStageDetector
  5 
  6 
  7 @DETECTORS.register_module()
  8 class DETR(SingleStageDetector):
  9     r"""Implementation of `DETR: End-to-End Object Detection with
  10     Transformers <https://arxiv.org/pdf/2005.12872>`_"""
  11 
  12     def __init__(self,
  13                  backbone,
  14                  bbox_head,
  15                  train_cfg=None,
  16                  test_cfg=None,
  17                  pretrained=None,
  18                  init_cfg=None):
  19         super(DETR, self).__init__(backbone, None, bbox_head, train_cfg,
  20                                    test_cfg, pretrained, init_cfg)
  21 
  22     # over-write `onnx_export` because:
  23     # (1) the forward of bbox_head requires img_metas
  24     # (2) the different behavior (e.g. construction of `masks`) between
  25     # torch and ONNX model, during the forward of bbox_head
  26     def onnx_export(self, img, img_metas):
  27         """Test function for exporting to ONNX, without test time augmentation.
  28 
  29         Args:
  30             img (torch.Tensor): input images.
  31             img_metas (list[dict]): List of image information.
  32 
  33         Returns:
  34             tuple[Tensor, Tensor]: dets of shape [N, num_det, 5]
  35                 and class labels of shape [N, num_det].
  36         """
  37         x = self.extract_feat(img)
  38         # forward of this head requires img_metas
  39         outs = self.bbox_head.forward_onnx(x, img_metas)
  40         # get shape as tensor
  41         img_shape = torch._shape_as_tensor(img)[2:]
  42         img_metas[0]['img_shape_for_onnx'] = img_shape
  43 
  44         det_bboxes, det_labels = self.bbox_head.onnx_export(*outs, img_metas)
  45 
  46         return det_bboxes, det_labels
  47
  [end of mmdet/models/detectors/detr.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/mmdet/models/detectors/detr.py b/mmdet/models/detectors/detr.py
  --- a/mmdet/models/detectors/detr.py
  +++ b/mmdet/models/detectors/detr.py
  @@ -1,3 +1,5 @@
  +import warnings
  +
   import torch
   
   from ..builder import DETECTORS
  @@ -19,6 +21,27 @@
           super(DETR, self).__init__(backbone, None, bbox_head, train_cfg,
                                      test_cfg, pretrained, init_cfg)
   
  +    # over-write `forward_dummy` because:
  +    # the forward of bbox_head requires img_metas
  +    def forward_dummy(self, img):
  +        """Used for computing network flops.
  +
  +        See `mmdetection/tools/analysis_tools/get_flops.py`
  +        """
  +        warnings.warn('Warning! MultiheadAttention in DETR does not '
  +                      'support flops computation! Do not use the '
  +                      'results in your papers!')
  +
  +        batch_size, _, height, width = img.shape
  +        dummy_img_metas = [
  +            dict(
  +                batch_input_shape=(height, width),
  +                img_shape=(height, width, 3)) for _ in range(batch_size)
  +        ]
  +        x = self.extract_feat(img)
  +        outs = self.bbox_head(x, dummy_img_metas)
  +        return outs
  +
       # over-write `onnx_export` because:
       # (1) the forward of bbox_head requires img_metas
       # (2) the different behavior (e.g. construction of `masks`) between
  
verification_info: {"golden_diff": "diff --git a/mmdet/models/detectors/detr.py b/mmdet/models/detectors/detr.py\n--- a/mmdet/models/detectors/detr.py\n+++ b/mmdet/models/detectors/detr.py\n@@ -1,3 +1,5 @@\n+import warnings\n+\n import torch\n \n from ..builder import DETECTORS\n@@ -19,6 +21,27 @@\n         super(DETR, self).__init__(backbone, None, bbox_head, train_cfg,\n                                    test_cfg, pretrained, init_cfg)\n \n+    # over-write `forward_dummy` because:\n+    # the forward of bbox_head requires img_metas\n+    def forward_dummy(self, img):\n+        \"\"\"Used for computing network flops.\n+\n+        See `mmdetection/tools/analysis_tools/get_flops.py`\n+        \"\"\"\n+        warnings.warn('Warning! MultiheadAttention in DETR does not '\n+                      'support flops computation! Do not use the '\n+                      'results in your papers!')\n+\n+        batch_size, _, height, width = img.shape\n+        dummy_img_metas = [\n+            dict(\n+                batch_input_shape=(height, width),\n+                img_shape=(height, width, 3)) for _ in range(batch_size)\n+        ]\n+        x = self.extract_feat(img)\n+        outs = self.bbox_head(x, dummy_img_metas)\n+        return outs\n+\n     # over-write `onnx_export` because:\n     # (1) the forward of bbox_head requires img_metas\n     # (2) the different behavior (e.g. construction of `masks`) between\n", "issue": "Error get params DETR/ Deformable DETR\nDespite my attempts to modify, also just testing with the basic config detr file. \r\nMaybe this issue has already been raised?\r\nmmdet==2.13.0\r\nmmcv=1.3.3\r\n\r\n```python\r\npython tools/analysis_tools/get_flops.py configs/detr/detr_r50_8x2_150e_coco.py\r\n```\r\n\r\n```python\r\n/home/bluav/mmdetection/mmdet/models/backbones/resnet.py:400: UserWarning: DeprecationWarning: pretrained is a deprecated, please use \"init_cfg\" instead\r\n  warnings.warn('DeprecationWarning: pretrained is a deprecated, '\r\nWarning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!\r\nWarning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!\r\nWarning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!\r\nWarning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!\r\nWarning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!\r\nWarning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!\r\nWarning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!\r\nWarning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!\r\nWarning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!\r\nWarning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!\r\nWarning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!\r\nWarning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!\r\nWarning: variables __flops__ or __params__ are already defined for the moduleReLU ptflops can affect your code!\r\nTraceback (most recent call last):\r\n  File \"tools/analysis_tools/get_flops.py\", line 81, in <module>\r\n    main()\r\n  File \"tools/analysis_tools/get_flops.py\", line 71, in main\r\n    flops, params = get_model_complexity_info(model, input_shape)\r\n  File \"/home/bluav/.conda/envs/open-mmlab/lib/python3.7/site-packages/mmcv/cnn/utils/flops_counter.py\", line 104, in get_model_complexity_info\r\n    _ = flops_model(batch)\r\n  File \"/home/bluav/.conda/envs/open-mmlab/lib/python3.7/site-packages/torch/nn/modules/module.py\", line 889, in _call_impl\r\n    result = self.forward(*input, **kwargs)\r\n  File \"/home/bluav/mmdetection/mmdet/models/detectors/single_stage.py\", line 48, in forward_dummy\r\n    outs = self.bbox_head(x)\r\n  File \"/home/bluav/.conda/envs/open-mmlab/lib/python3.7/site-packages/torch/nn/modules/module.py\", line 889, in _call_impl\r\n    result = self.forward(*input, **kwargs)\r\nTypeError: forward() missing 1 required positional argument: 'img_metas'\r\n```\r\n\n", "before_files": [{"content": "import torch\n\nfrom ..builder import DETECTORS\nfrom .single_stage import SingleStageDetector\n\n\n@DETECTORS.register_module()\nclass DETR(SingleStageDetector):\n    r\"\"\"Implementation of `DETR: End-to-End Object Detection with\n    Transformers <https://arxiv.org/pdf/2005.12872>`_\"\"\"\n\n    def __init__(self,\n                 backbone,\n                 bbox_head,\n                 train_cfg=None,\n                 test_cfg=None,\n                 pretrained=None,\n                 init_cfg=None):\n        super(DETR, self).__init__(backbone, None, bbox_head, train_cfg,\n                                   test_cfg, pretrained, init_cfg)\n\n    # over-write `onnx_export` because:\n    # (1) the forward of bbox_head requires img_metas\n    # (2) the different behavior (e.g. construction of `masks`) between\n    # torch and ONNX model, during the forward of bbox_head\n    def onnx_export(self, img, img_metas):\n        \"\"\"Test function for exporting to ONNX, without test time augmentation.\n\n        Args:\n            img (torch.Tensor): input images.\n            img_metas (list[dict]): List of image information.\n\n        Returns:\n            tuple[Tensor, Tensor]: dets of shape [N, num_det, 5]\n                and class labels of shape [N, num_det].\n        \"\"\"\n        x = self.extract_feat(img)\n        # forward of this head requires img_metas\n        outs = self.bbox_head.forward_onnx(x, img_metas)\n        # get shape as tensor\n        img_shape = torch._shape_as_tensor(img)[2:]\n        img_metas[0]['img_shape_for_onnx'] = img_shape\n\n        det_bboxes, det_labels = self.bbox_head.onnx_export(*outs, img_metas)\n\n        return det_bboxes, det_labels\n", "path": "mmdet/models/detectors/detr.py"}]}