We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[Bug] The precision are not aligned between val during train and test 
### Branch

master branch (0.24 or other 0.x version)

### Describe the bug

The precision of val in the train is 73, and the precision of test 76, they are not aligned



### Environment

A100 or NPU

### Other information

_No response_

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `mmcls/models/heads/multi_label_head.py`
Content:
```
1 # Copyright (c) OpenMMLab. All rights reserved.
2 import torch
3 
4 from ..builder import HEADS, build_loss
5 from ..utils import is_tracing
6 from .base_head import BaseHead
7 
8 
9 @HEADS.register_module()
10 class MultiLabelClsHead(BaseHead):
11     """Classification head for multilabel task.
12 
13     Args:
14         loss (dict): Config of classification loss.
15     """
16 
17     def __init__(self,
18                  loss=dict(
19                      type='CrossEntropyLoss',
20                      use_sigmoid=True,
21                      reduction='mean',
22                      loss_weight=1.0),
23                  init_cfg=None):
24         super(MultiLabelClsHead, self).__init__(init_cfg=init_cfg)
25 
26         assert isinstance(loss, dict)
27 
28         self.compute_loss = build_loss(loss)
29 
30     def loss(self, cls_score, gt_label):
31         gt_label = gt_label.type_as(cls_score)
32         num_samples = len(cls_score)
33         losses = dict()
34 
35         # map difficult examples to positive ones
36         _gt_label = torch.abs(gt_label)
37         # compute loss
38         loss = self.compute_loss(cls_score, _gt_label, avg_factor=num_samples)
39         losses['loss'] = loss
40         return losses
41 
42     def forward_train(self, cls_score, gt_label, **kwargs):
43         if isinstance(cls_score, tuple):
44             cls_score = cls_score[-1]
45         gt_label = gt_label.type_as(cls_score)
46         losses = self.loss(cls_score, gt_label, **kwargs)
47         return losses
48 
49     def pre_logits(self, x):
50         if isinstance(x, tuple):
51             x = x[-1]
52 
53         from mmcls.utils import get_root_logger
54         logger = get_root_logger()
55         logger.warning(
56             'The input of MultiLabelClsHead should be already logits. '
57             'Please modify the backbone if you want to get pre-logits feature.'
58         )
59         return x
60 
61     def simple_test(self, x, sigmoid=True, post_process=True):
62         """Inference without augmentation.
63 
64         Args:
65             cls_score (tuple[Tensor]): The input classification score logits.
66                 Multi-stage inputs are acceptable but only the last stage will
67                 be used to classify. The shape of every item should be
68                 ``(num_samples, num_classes)``.
69             sigmoid (bool): Whether to sigmoid the classification score.
70             post_process (bool): Whether to do post processing the
71                 inference results. It will convert the output to a list.
72 
73         Returns:
74             Tensor | list: The inference results.
75 
76                 - If no post processing, the output is a tensor with shape
77                   ``(num_samples, num_classes)``.
78                 - If post processing, the output is a multi-dimentional list of
79                   float and the dimensions are ``(num_samples, num_classes)``.
80         """
81         if isinstance(x, tuple):
82             x = x[-1]
83 
84         if sigmoid:
85             pred = torch.sigmoid(x) if x is not None else None
86         else:
87             pred = x
88 
89         if post_process:
90             return self.post_process(pred)
91         else:
92             return pred
93 
94     def post_process(self, pred):
95         on_trace = is_tracing()
96         if torch.onnx.is_in_onnx_export() or on_trace:
97             return pred
98         pred = list(pred.detach().cpu().numpy())
99         return pred
100
```

Path: `mmcls/models/heads/multi_label_linear_head.py`
Content:
```
1 # Copyright (c) OpenMMLab. All rights reserved.
2 import torch
3 import torch.nn as nn
4 
5 from ..builder import HEADS
6 from .multi_label_head import MultiLabelClsHead
7 
8 
9 @HEADS.register_module()
10 class MultiLabelLinearClsHead(MultiLabelClsHead):
11     """Linear classification head for multilabel task.
12 
13     Args:
14         num_classes (int): Number of categories.
15         in_channels (int): Number of channels in the input feature map.
16         loss (dict): Config of classification loss.
17         init_cfg (dict | optional): The extra init config of layers.
18             Defaults to use dict(type='Normal', layer='Linear', std=0.01).
19     """
20 
21     def __init__(self,
22                  num_classes,
23                  in_channels,
24                  loss=dict(
25                      type='CrossEntropyLoss',
26                      use_sigmoid=True,
27                      reduction='mean',
28                      loss_weight=1.0),
29                  init_cfg=dict(type='Normal', layer='Linear', std=0.01)):
30         super(MultiLabelLinearClsHead, self).__init__(
31             loss=loss, init_cfg=init_cfg)
32 
33         if num_classes <= 0:
34             raise ValueError(
35                 f'num_classes={num_classes} must be a positive integer')
36 
37         self.in_channels = in_channels
38         self.num_classes = num_classes
39 
40         self.fc = nn.Linear(self.in_channels, self.num_classes)
41 
42     def pre_logits(self, x):
43         if isinstance(x, tuple):
44             x = x[-1]
45         return x
46 
47     def forward_train(self, x, gt_label, **kwargs):
48         x = self.pre_logits(x)
49         gt_label = gt_label.type_as(x)
50         cls_score = self.fc(x)
51         losses = self.loss(cls_score, gt_label, **kwargs)
52         return losses
53 
54     def simple_test(self, x, sigmoid=True, post_process=True):
55         """Inference without augmentation.
56 
57         Args:
58             x (tuple[Tensor]): The input features.
59                 Multi-stage inputs are acceptable but only the last stage will
60                 be used to classify. The shape of every item should be
61                 ``(num_samples, in_channels)``.
62             sigmoid (bool): Whether to sigmoid the classification score.
63             post_process (bool): Whether to do post processing the
64                 inference results. It will convert the output to a list.
65 
66         Returns:
67             Tensor | list: The inference results.
68 
69                 - If no post processing, the output is a tensor with shape
70                   ``(num_samples, num_classes)``.
71                 - If post processing, the output is a multi-dimentional list of
72                   float and the dimensions are ``(num_samples, num_classes)``.
73         """
74         x = self.pre_logits(x)
75         cls_score = self.fc(x)
76 
77         if sigmoid:
78             pred = torch.sigmoid(cls_score) if cls_score is not None else None
79         else:
80             pred = cls_score
81 
82         if post_process:
83             return self.post_process(pred)
84         else:
85             return pred
86
```
--- 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/mmcls/models/heads/multi_label_head.py b/mmcls/models/heads/multi_label_head.py
--- a/mmcls/models/heads/multi_label_head.py
+++ b/mmcls/models/heads/multi_label_head.py
@@ -82,7 +82,8 @@
             x = x[-1]
 
         if sigmoid:
-            pred = torch.sigmoid(x) if x is not None else None
+            # Convert to full precision because sigmoid is sensitive.
+            pred = torch.sigmoid(x.float()) if x is not None else None
         else:
             pred = x
 
diff --git a/mmcls/models/heads/multi_label_linear_head.py b/mmcls/models/heads/multi_label_linear_head.py
--- a/mmcls/models/heads/multi_label_linear_head.py
+++ b/mmcls/models/heads/multi_label_linear_head.py
@@ -75,7 +75,9 @@
         cls_score = self.fc(x)
 
         if sigmoid:
-            pred = torch.sigmoid(cls_score) if cls_score is not None else None
+            # Convert to full precision because sigmoid is sensitive.
+            pred = torch.sigmoid(
+                cls_score.float()) if cls_score is not None else None
         else:
             pred = cls_score

{"golden_diff": "diff --git a/mmcls/models/heads/multi_label_head.py b/mmcls/models/heads/multi_label_head.py\n--- a/mmcls/models/heads/multi_label_head.py\n+++ b/mmcls/models/heads/multi_label_head.py\n@@ -82,7 +82,8 @@\n             x = x[-1]\n \n         if sigmoid:\n-            pred = torch.sigmoid(x) if x is not None else None\n+            # Convert to full precision because sigmoid is sensitive.\n+            pred = torch.sigmoid(x.float()) if x is not None else None\n         else:\n             pred = x\n \ndiff --git a/mmcls/models/heads/multi_label_linear_head.py b/mmcls/models/heads/multi_label_linear_head.py\n--- a/mmcls/models/heads/multi_label_linear_head.py\n+++ b/mmcls/models/heads/multi_label_linear_head.py\n@@ -75,7 +75,9 @@\n         cls_score = self.fc(x)\n \n         if sigmoid:\n-            pred = torch.sigmoid(cls_score) if cls_score is not None else None\n+            # Convert to full precision because sigmoid is sensitive.\n+            pred = torch.sigmoid(\n+                cls_score.float()) if cls_score is not None else None\n         else:\n             pred = cls_score\n", "issue": "[Bug] The precision are not aligned between val during train and test \n### Branch\n\nmaster branch (0.24 or other 0.x version)\n\n### Describe the bug\n\nThe precision of val in the train is 73, and the precision of test 76, they are not aligned\r\n\r\n\n\n### Environment\n\nA100 or NPU\n\n### Other information\n\n_No response_\n", "before_files": [{"content": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\n\nfrom ..builder import HEADS, build_loss\nfrom ..utils import is_tracing\nfrom .base_head import BaseHead\n\n\n@HEADS.register_module()\nclass MultiLabelClsHead(BaseHead):\n    \"\"\"Classification head for multilabel task.\n\n    Args:\n        loss (dict): Config of classification loss.\n    \"\"\"\n\n    def __init__(self,\n                 loss=dict(\n                     type='CrossEntropyLoss',\n                     use_sigmoid=True,\n                     reduction='mean',\n                     loss_weight=1.0),\n                 init_cfg=None):\n        super(MultiLabelClsHead, self).__init__(init_cfg=init_cfg)\n\n        assert isinstance(loss, dict)\n\n        self.compute_loss = build_loss(loss)\n\n    def loss(self, cls_score, gt_label):\n        gt_label = gt_label.type_as(cls_score)\n        num_samples = len(cls_score)\n        losses = dict()\n\n        # map difficult examples to positive ones\n        _gt_label = torch.abs(gt_label)\n        # compute loss\n        loss = self.compute_loss(cls_score, _gt_label, avg_factor=num_samples)\n        losses['loss'] = loss\n        return losses\n\n    def forward_train(self, cls_score, gt_label, **kwargs):\n        if isinstance(cls_score, tuple):\n            cls_score = cls_score[-1]\n        gt_label = gt_label.type_as(cls_score)\n        losses = self.loss(cls_score, gt_label, **kwargs)\n        return losses\n\n    def pre_logits(self, x):\n        if isinstance(x, tuple):\n            x = x[-1]\n\n        from mmcls.utils import get_root_logger\n        logger = get_root_logger()\n        logger.warning(\n            'The input of MultiLabelClsHead should be already logits. '\n            'Please modify the backbone if you want to get pre-logits feature.'\n        )\n        return x\n\n    def simple_test(self, x, sigmoid=True, post_process=True):\n        \"\"\"Inference without augmentation.\n\n        Args:\n            cls_score (tuple[Tensor]): The input classification score logits.\n                Multi-stage inputs are acceptable but only the last stage will\n                be used to classify. The shape of every item should be\n                ``(num_samples, num_classes)``.\n            sigmoid (bool): Whether to sigmoid the classification score.\n            post_process (bool): Whether to do post processing the\n                inference results. It will convert the output to a list.\n\n        Returns:\n            Tensor | list: The inference results.\n\n                - If no post processing, the output is a tensor with shape\n                  ``(num_samples, num_classes)``.\n                - If post processing, the output is a multi-dimentional list of\n                  float and the dimensions are ``(num_samples, num_classes)``.\n        \"\"\"\n        if isinstance(x, tuple):\n            x = x[-1]\n\n        if sigmoid:\n            pred = torch.sigmoid(x) if x is not None else None\n        else:\n            pred = x\n\n        if post_process:\n            return self.post_process(pred)\n        else:\n            return pred\n\n    def post_process(self, pred):\n        on_trace = is_tracing()\n        if torch.onnx.is_in_onnx_export() or on_trace:\n            return pred\n        pred = list(pred.detach().cpu().numpy())\n        return pred\n", "path": "mmcls/models/heads/multi_label_head.py"}, {"content": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\nimport torch.nn as nn\n\nfrom ..builder import HEADS\nfrom .multi_label_head import MultiLabelClsHead\n\n\n@HEADS.register_module()\nclass MultiLabelLinearClsHead(MultiLabelClsHead):\n    \"\"\"Linear classification head for multilabel task.\n\n    Args:\n        num_classes (int): Number of categories.\n        in_channels (int): Number of channels in the input feature map.\n        loss (dict): Config of classification loss.\n        init_cfg (dict | optional): The extra init config of layers.\n            Defaults to use dict(type='Normal', layer='Linear', std=0.01).\n    \"\"\"\n\n    def __init__(self,\n                 num_classes,\n                 in_channels,\n                 loss=dict(\n                     type='CrossEntropyLoss',\n                     use_sigmoid=True,\n                     reduction='mean',\n                     loss_weight=1.0),\n                 init_cfg=dict(type='Normal', layer='Linear', std=0.01)):\n        super(MultiLabelLinearClsHead, self).__init__(\n            loss=loss, init_cfg=init_cfg)\n\n        if num_classes <= 0:\n            raise ValueError(\n                f'num_classes={num_classes} must be a positive integer')\n\n        self.in_channels = in_channels\n        self.num_classes = num_classes\n\n        self.fc = nn.Linear(self.in_channels, self.num_classes)\n\n    def pre_logits(self, x):\n        if isinstance(x, tuple):\n            x = x[-1]\n        return x\n\n    def forward_train(self, x, gt_label, **kwargs):\n        x = self.pre_logits(x)\n        gt_label = gt_label.type_as(x)\n        cls_score = self.fc(x)\n        losses = self.loss(cls_score, gt_label, **kwargs)\n        return losses\n\n    def simple_test(self, x, sigmoid=True, post_process=True):\n        \"\"\"Inference without augmentation.\n\n        Args:\n            x (tuple[Tensor]): The input features.\n                Multi-stage inputs are acceptable but only the last stage will\n                be used to classify. The shape of every item should be\n                ``(num_samples, in_channels)``.\n            sigmoid (bool): Whether to sigmoid the classification score.\n            post_process (bool): Whether to do post processing the\n                inference results. It will convert the output to a list.\n\n        Returns:\n            Tensor | list: The inference results.\n\n                - If no post processing, the output is a tensor with shape\n                  ``(num_samples, num_classes)``.\n                - If post processing, the output is a multi-dimentional list of\n                  float and the dimensions are ``(num_samples, num_classes)``.\n        \"\"\"\n        x = self.pre_logits(x)\n        cls_score = self.fc(x)\n\n        if sigmoid:\n            pred = torch.sigmoid(cls_score) if cls_score is not None else None\n        else:\n            pred = cls_score\n\n        if post_process:\n            return self.post_process(pred)\n        else:\n            return pred\n", "path": "mmcls/models/heads/multi_label_linear_head.py"}], "after_files": [{"content": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\n\nfrom ..builder import HEADS, build_loss\nfrom ..utils import is_tracing\nfrom .base_head import BaseHead\n\n\n@HEADS.register_module()\nclass MultiLabelClsHead(BaseHead):\n    \"\"\"Classification head for multilabel task.\n\n    Args:\n        loss (dict): Config of classification loss.\n    \"\"\"\n\n    def __init__(self,\n                 loss=dict(\n                     type='CrossEntropyLoss',\n                     use_sigmoid=True,\n                     reduction='mean',\n                     loss_weight=1.0),\n                 init_cfg=None):\n        super(MultiLabelClsHead, self).__init__(init_cfg=init_cfg)\n\n        assert isinstance(loss, dict)\n\n        self.compute_loss = build_loss(loss)\n\n    def loss(self, cls_score, gt_label):\n        gt_label = gt_label.type_as(cls_score)\n        num_samples = len(cls_score)\n        losses = dict()\n\n        # map difficult examples to positive ones\n        _gt_label = torch.abs(gt_label)\n        # compute loss\n        loss = self.compute_loss(cls_score, _gt_label, avg_factor=num_samples)\n        losses['loss'] = loss\n        return losses\n\n    def forward_train(self, cls_score, gt_label, **kwargs):\n        if isinstance(cls_score, tuple):\n            cls_score = cls_score[-1]\n        gt_label = gt_label.type_as(cls_score)\n        losses = self.loss(cls_score, gt_label, **kwargs)\n        return losses\n\n    def pre_logits(self, x):\n        if isinstance(x, tuple):\n            x = x[-1]\n\n        from mmcls.utils import get_root_logger\n        logger = get_root_logger()\n        logger.warning(\n            'The input of MultiLabelClsHead should be already logits. '\n            'Please modify the backbone if you want to get pre-logits feature.'\n        )\n        return x\n\n    def simple_test(self, x, sigmoid=True, post_process=True):\n        \"\"\"Inference without augmentation.\n\n        Args:\n            cls_score (tuple[Tensor]): The input classification score logits.\n                Multi-stage inputs are acceptable but only the last stage will\n                be used to classify. The shape of every item should be\n                ``(num_samples, num_classes)``.\n            sigmoid (bool): Whether to sigmoid the classification score.\n            post_process (bool): Whether to do post processing the\n                inference results. It will convert the output to a list.\n\n        Returns:\n            Tensor | list: The inference results.\n\n                - If no post processing, the output is a tensor with shape\n                  ``(num_samples, num_classes)``.\n                - If post processing, the output is a multi-dimentional list of\n                  float and the dimensions are ``(num_samples, num_classes)``.\n        \"\"\"\n        if isinstance(x, tuple):\n            x = x[-1]\n\n        if sigmoid:\n            # Convert to full precision because sigmoid is sensitive.\n            pred = torch.sigmoid(x.float()) if x is not None else None\n        else:\n            pred = x\n\n        if post_process:\n            return self.post_process(pred)\n        else:\n            return pred\n\n    def post_process(self, pred):\n        on_trace = is_tracing()\n        if torch.onnx.is_in_onnx_export() or on_trace:\n            return pred\n        pred = list(pred.detach().cpu().numpy())\n        return pred\n", "path": "mmcls/models/heads/multi_label_head.py"}, {"content": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\nimport torch.nn as nn\n\nfrom ..builder import HEADS\nfrom .multi_label_head import MultiLabelClsHead\n\n\n@HEADS.register_module()\nclass MultiLabelLinearClsHead(MultiLabelClsHead):\n    \"\"\"Linear classification head for multilabel task.\n\n    Args:\n        num_classes (int): Number of categories.\n        in_channels (int): Number of channels in the input feature map.\n        loss (dict): Config of classification loss.\n        init_cfg (dict | optional): The extra init config of layers.\n            Defaults to use dict(type='Normal', layer='Linear', std=0.01).\n    \"\"\"\n\n    def __init__(self,\n                 num_classes,\n                 in_channels,\n                 loss=dict(\n                     type='CrossEntropyLoss',\n                     use_sigmoid=True,\n                     reduction='mean',\n                     loss_weight=1.0),\n                 init_cfg=dict(type='Normal', layer='Linear', std=0.01)):\n        super(MultiLabelLinearClsHead, self).__init__(\n            loss=loss, init_cfg=init_cfg)\n\n        if num_classes <= 0:\n            raise ValueError(\n                f'num_classes={num_classes} must be a positive integer')\n\n        self.in_channels = in_channels\n        self.num_classes = num_classes\n\n        self.fc = nn.Linear(self.in_channels, self.num_classes)\n\n    def pre_logits(self, x):\n        if isinstance(x, tuple):\n            x = x[-1]\n        return x\n\n    def forward_train(self, x, gt_label, **kwargs):\n        x = self.pre_logits(x)\n        gt_label = gt_label.type_as(x)\n        cls_score = self.fc(x)\n        losses = self.loss(cls_score, gt_label, **kwargs)\n        return losses\n\n    def simple_test(self, x, sigmoid=True, post_process=True):\n        \"\"\"Inference without augmentation.\n\n        Args:\n            x (tuple[Tensor]): The input features.\n                Multi-stage inputs are acceptable but only the last stage will\n                be used to classify. The shape of every item should be\n                ``(num_samples, in_channels)``.\n            sigmoid (bool): Whether to sigmoid the classification score.\n            post_process (bool): Whether to do post processing the\n                inference results. It will convert the output to a list.\n\n        Returns:\n            Tensor | list: The inference results.\n\n                - If no post processing, the output is a tensor with shape\n                  ``(num_samples, num_classes)``.\n                - If post processing, the output is a multi-dimentional list of\n                  float and the dimensions are ``(num_samples, num_classes)``.\n        \"\"\"\n        x = self.pre_logits(x)\n        cls_score = self.fc(x)\n\n        if sigmoid:\n            # Convert to full precision because sigmoid is sensitive.\n            pred = torch.sigmoid(\n                cls_score.float()) if cls_score is not None else None\n        else:\n            pred = cls_score\n\n        if post_process:\n            return self.post_process(pred)\n        else:\n            return pred\n", "path": "mmcls/models/heads/multi_label_linear_head.py"}]}