We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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'
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `mmdet/models/detectors/detr.py`
Content:
```
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 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()

```

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

{"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"}], "after_files": [{"content": "import warnings\n\nimport 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 `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    # 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"}]}