internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: encode/httpx

Issue:
0.27.0: replacing `app=app` with `transport=ASGITransport(app)` doesn't type check
```diff
 @pytest_asyncio.fixture
 async def deprecated_client(deprecated_db_manager: MainDbManager) -> AsyncGenerator[AsyncClient, None]:
     async with _make_mocked_test_app(db_manager=deprecated_db_manager, authorization=False) as app:
-        async with AsyncClient(app=app, base_url=URL, headers=USER_AGENT) as ac:
+        async with AsyncClient(transport=ASGITransport(app), base_url=URL, headers=USER_AGENT) as ac:
             yield ac
```

```
% poetry run mypy .                                              
tests/conftest.py:64: error: Argument 1 to "ASGITransport" has incompatible type "FastAPI"; expected "Callable[[dict[str, Any], Callable[[], Awaitable[dict[str, Any]]], Callable[[dict[str, Any]], Coroutine[None, None, None]]], Coroutine[None, None, None]]"  [arg-type]
tests/conftest.py:64: note: "FastAPI.__call__" has type "Callable[[Arg(MutableMapping[str, Any], 'scope'), Arg(Callable[[], Awaitable[MutableMapping[str, Any]]], 'receive'), Arg(Callable[[MutableMapping[str, Any]], Awaitable[None]], 'send')], Coroutine[Any, Any, None]]"
Found 1 error in 1 file (checked 472 source files)
 
 It looks like FastAPI and httpx disagree on the shape of an ASGI application. How am I meant to resolve this?



Discussion:

Resolving patch:
diff --git a/httpx/_transports/asgi.py b/httpx/_transports/asgi.py
--- a/httpx/_transports/asgi.py
+++ b/httpx/_transports/asgi.py
@@ -16,13 +16,13 @@
     Event = typing.Union[asyncio.Event, trio.Event]
 
 
-_Message = typing.Dict[str, typing.Any]
+_Message = typing.MutableMapping[str, typing.Any]
 _Receive = typing.Callable[[], typing.Awaitable[_Message]]
 _Send = typing.Callable[
-    [typing.Dict[str, typing.Any]], typing.Coroutine[None, None, None]
+    [typing.MutableMapping[str, typing.Any]], typing.Awaitable[None]
 ]
 _ASGIApp = typing.Callable[
-    [typing.Dict[str, typing.Any], _Receive, _Send], typing.Coroutine[None, None, None]
+    [typing.MutableMapping[str, typing.Any], _Receive, _Send], typing.Awaitable[None]
 ]
 
 __all__ = ["ASGITransport"]
@@ -141,7 +141,7 @@ async def receive() -> dict[str, typing.Any]:
                 return {"type": "http.request", "body": b"", "more_body": False}
             return {"type": "http.request", "body": body, "more_body": True}
 
-        async def send(message: dict[str, typing.Any]) -> None:
+        async def send(message: typing.MutableMapping[str, typing.Any]) -> None:
             nonlocal status_code, response_headers, response_started
 
             if message["type"] == "http.response.start":


Test patch:
Repository: RUCAIBox/RecBole

Issue:
[🐛BUG] case_study.py 中， 输入的用户id只有一个时， full_sort_topk 报错
代码
```python3
import torch
import pandas as pd

from recbole.model.general_recommender.bpr import BPR
from recbole.config import Config
from recbole.data import create_dataset, data_preparation
from recbole.utils.case_study import full_sort_topk

param_dict = {
    'use_gpu': False
}

# 加载 BPR 模型
bpr_model_path = "D:\\source\\recbole-0.2.0\\app\\ex\\saved\\BPR-Jan-18-2021_14-03-52.pth"
bpr_config = Config(model='BPR',
                    dataset='ml-100k',
                    config_dict=param_dict)
dataset = create_dataset(bpr_config)
train_data, valid_data, test_data = data_preparation(bpr_config, dataset)

bpr_model = BPR(bpr_config, train_data)
checkpoint = torch.load(bpr_model_path)
bpr_model.load_state_dict(checkpoint['state_dict'])
bpr_model.eval()

uid_series = dataset.token2id(dataset.uid_field, ['200'])  # 原始数据集中的用户id，变换为训练内部使用的索引id

full_sort_topk(uid_series, bpr_model, test_data, 10)
```

报错信息
Traceback (most recent call last):
  File "D:/source/recbole-0.2.0/app/ex/bpr_predict_ml100k.py", line 33, in <module>
    full_sort_topk(uid_series, bpr_model, test_data, 10)
  File "D:\source\recbole-0.2.0\recbole\utils\case_study.py", line 87, in full_sort_topk
    scores = full_sort_scores(uid_series, model, test_data)
  File "D:\Anaconda3\envs\pytorch\lib\site-packages\torch\autograd\grad_mode.py", line 26, in decorate_context
    return func(*args, **kwargs)
  File "D:\source\recbole-0.2.0\recbole\utils\case_study.py", line 45, in full_sort_scores
    history_row = torch.cat([torch.full_like(hist_iid, i) for i, hist_iid in enumerate(history_item)])
RuntimeError: zero-dimensional tensor (at position 0) cannot be concatenated


Discussion:

Resolving patch:
diff --git a/recbole/utils/case_study.py b/recbole/utils/case_study.py
--- a/recbole/utils/case_study.py
+++ b/recbole/utils/case_study.py
@@ -41,7 +41,7 @@ def full_sort_scores(uid_series, model, test_data):
     if isinstance(test_data, GeneralFullDataLoader):
         index = np.isin(test_data.user_df[uid_field].numpy(), uid_series)
         input_interaction = test_data.user_df[index]
-        history_item = test_data.uid2history_item[input_interaction[uid_field]]
+        history_item = test_data.uid2history_item[input_interaction[uid_field].numpy()]
         history_row = torch.cat([torch.full_like(hist_iid, i) for i, hist_iid in enumerate(history_item)])
         history_col = torch.cat(list(history_item))
         history_index = history_row, history_col


Test patch:
Repository: RUCAIBox/RecBole

Issue:
[🐛BUG] Extreme memory usage with contextual features?
I'm testing with a reasonably sized dataset (350k~ interactions) with a handful of token or token_seq features:

```yaml
  item:
    [
      "item_id",
      "year",
      "artist",
      "category",
      "designer",
      "family",
      "game_type",
      "mechanic",
      "publisher",
    ]
```
When I try running e.g. SASRecF or FDSA I get:

```
RuntimeError: CUDA out of memory. Tried to allocate 53.25 GiB (GPU 0; 15.90 GiB total capacity; 264.21 MiB already allocated; 14.79 GiB free; 306.00 MiB reserved in total by PyTorch)
```

Some of these categories are high cardinality, but they should be represented as sparse, right? What would cause memory usage this high?

for context, the size of the dataset:

![image](https://user-images.githubusercontent.com/11601778/104849199-87c41980-58b6-11eb-85d2-bf1f62a08a22.png)



Discussion:

Resolving patch:
diff --git a/recbole/trainer/trainer.py b/recbole/trainer/trainer.py
--- a/recbole/trainer/trainer.py
+++ b/recbole/trainer/trainer.py
@@ -373,9 +373,10 @@ def _full_sort_batch_eval(self, batched_data):
             # Note: interaction without item ids
             scores = self.model.full_sort_predict(interaction.to(self.device))
         except NotImplementedError:
+            inter_len = len(interaction)
             new_inter = interaction.to(self.device).repeat_interleave(self.tot_item_num)
             batch_size = len(new_inter)
-            new_inter.update(self.item_tensor[:batch_size])
+            new_inter.update(self.item_tensor.repeat(inter_len))
             if batch_size <= self.test_batch_size:
                 scores = self.model.predict(new_inter)
             else:
@@ -438,11 +439,10 @@ def evaluate(self, eval_data, load_best_model=True, model_file=None, show_progre
 
         if eval_data.dl_type == DataLoaderType.FULL:
             if self.item_tensor is None:
-                self.item_tensor = eval_data.dataset.get_item_feature().to(self.device).repeat(eval_data.step)
+                self.item_tensor = eval_data.dataset.get_item_feature().to(self.device)
         if self.config['eval_type'] == EvaluatorType.RANKING:
             self.tot_item_num = eval_data.dataset.item_num
 
-        batch_matrix_list = []
         iter_data = (
             tqdm(
                 enumerate(eval_data),


Test patch:
Repository: Lightning-AI/torchmetrics

Issue:
User Warning thrown when calling AveragePrecision
## 🐛 Bug

Using the AveragePrecision metric throws the following warning every time it is called:

UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).

### To Reproduce

Steps to reproduce the behavior:
1. Import AveragePrecision and create an object of this class
2. Call the object by passing in pred and target tensors

#### Code sample

```
import torch
from torchmetrics import AveragePrecision

a = torch.softmax(torch.randn(4, 4), dim=1)
b = torch.randint(0, 2, (4, 4))

ap = AveragePrecision(pos_label=1)
ap(a, b)
```

### Expected behavior
This warning should not be thrown. The recommended way of copying a tensor should be followed.


### Environment

- PyTorch Version: 1.8.2
- OS (e.g., Linux): Ubuntu 18
- How you installed PyTorch (`conda`, `pip`, source): conda
- Build command you used (if compiling from source):
- Python version: 3.8.5
- CUDA/cuDNN version: 11.1/8.0.5
- GPU models and configuration: Quadro RTX 8000
- Any other relevant information:

### Additional context

The problem is arising due to line 156 in torchmetrics/functional/classification/precision_recall_curve.py
The line currently reads:
```
thresholds = tensor(reversed(thresholds[sl]))
```
This problem should be fixed by changing that line to:
```
thresholds = reversed(thresholds[sl]).detach().clone()
```



Discussion:
Hi! thanks for your contribution!, great first issue!
good catch, shall be a simple fix, are you interested in sending a PR? :rabbit: 
Sure, I'll send a PR. :)

Resolving patch:
diff --git a/torchmetrics/functional/classification/precision_recall_curve.py b/torchmetrics/functional/classification/precision_recall_curve.py
--- a/torchmetrics/functional/classification/precision_recall_curve.py
+++ b/torchmetrics/functional/classification/precision_recall_curve.py
@@ -153,7 +153,7 @@ def _precision_recall_curve_compute_single_class(
 
     recall = torch.cat([reversed(recall[sl]), torch.zeros(1, dtype=recall.dtype, device=recall.device)])
 
-    thresholds = tensor(reversed(thresholds[sl]))
+    thresholds = reversed(thresholds[sl]).detach().clone()  # type: ignore
 
     return precision, recall, thresholds
 


Test patch:
Repository: Lightning-AI/torchmetrics

Issue:
Refactor `_input_format_classification` and `_hinge_update` so that it uses `_input_squeeze`.
There is a function to in `checks.py` for removing the excess dimensions:
https://github.com/PyTorchLightning/metrics/blob/1171a1f12507df5c8206475f3692b31ddab8d934/torchmetrics/utilities/checks.py#L284-L293

Instead of reusing this function in [`_input_format_classification`](https://github.com/PyTorchLightning/metrics/blob/1171a1f12507df5c8206475f3692b31ddab8d934/torchmetrics/utilities/checks.py#L384) and [`_hinge_update`](https://github.com/PyTorchLightning/metrics/blob/525642df8c3f3f5f93cdd22b6b9cd802a3854634/torchmetrics/functional/classification/hinge.py#L92), the code is duplicated there.

https://github.com/PyTorchLightning/metrics/blob/1171a1f12507df5c8206475f3692b31ddab8d934/torchmetrics/utilities/checks.py#L384-L388

https://github.com/PyTorchLightning/metrics/blob/525642df8c3f3f5f93cdd22b6b9cd802a3854634/torchmetrics/functional/classification/hinge.py#L92-L95



I think it is appropriate to fix that.


Discussion:
Hi! thanks for your contribution!, great first issue!
@yassersouri agree that this should be fixed. Want to send a PR? :]

Resolving patch:
diff --git a/torchmetrics/functional/classification/hinge.py b/torchmetrics/functional/classification/hinge.py
--- a/torchmetrics/functional/classification/hinge.py
+++ b/torchmetrics/functional/classification/hinge.py
@@ -16,6 +16,7 @@
 import torch
 from torch import Tensor, tensor
 
+from torchmetrics.utilities.checks import _input_squeeze
 from torchmetrics.utilities.data import to_onehot
 from torchmetrics.utilities.enums import DataType, EnumStr
 
@@ -88,11 +89,7 @@ def _hinge_update(
             ``MulticlassMode.CRAMMER_SINGER`` or ``"crammer-singer"``, uses the Crammer Singer multi-class hinge loss.
             ``MulticlassMode.ONE_VS_ALL`` or ``"one-vs-all"`` computes the hinge loss in a one-vs-all fashion.
     """
-
-    if preds.shape[0] == 1:
-        preds, target = preds.squeeze().unsqueeze(0), target.squeeze().unsqueeze(0)
-    else:
-        preds, target = preds.squeeze(), target.squeeze()
+    preds, target = _input_squeeze(preds, target)
 
     mode = _check_shape_and_type_consistency_hinge(preds, target)
 
diff --git a/torchmetrics/utilities/checks.py b/torchmetrics/utilities/checks.py
--- a/torchmetrics/utilities/checks.py
+++ b/torchmetrics/utilities/checks.py
@@ -382,10 +382,7 @@ def _input_format_classification(
             ``'multi-dim multi-class'``
     """
     # Remove excess dimensions
-    if preds.shape[0] == 1:
-        preds, target = preds.squeeze().unsqueeze(0), target.squeeze().unsqueeze(0)
-    else:
-        preds, target = preds.squeeze(), target.squeeze()
+    preds, target = _input_squeeze(preds, target)
 
     # Convert half precision tensors to full precision, as not all ops are supported
     # for example, min() is not supported


Test patch:
Repository: Lightning-AI/torchmetrics

Issue:
pit bug: the device and type of preds and target may not the same with the results returned by metric_func
## 🐛 Bug

the device and type of preds and target may not the same with the results returned by metric_func

### To Reproduce

use a self-designed metric-func which accepts complex tensor but return real tensor

<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->

#### Code sample

<!-- Ideally attach a minimal code sample to reproduce the decried issue.
Minimal means having the shortest code but still preserving the bug. -->

### Expected behavior

<!-- A clear and concise description of what you expected to happen. -->

### Environment

- PyTorch Version (e.g., 1.0):
- OS (e.g., Linux):
- How you installed PyTorch (`conda`, `pip`, source):
- Build command you used (if compiling from source):
- Python version:
- CUDA/cuDNN version:
- GPU models and configuration:
- Any other relevant information:

### Additional context

<!-- Add any other context about the problem here. -->



Discussion:

Resolving patch:
diff --git a/torchmetrics/functional/audio/pit.py b/torchmetrics/functional/audio/pit.py
--- a/torchmetrics/functional/audio/pit.py
+++ b/torchmetrics/functional/audio/pit.py
@@ -151,10 +151,17 @@ def pit(
 
     # calculate the metric matrix
     batch_size, spk_num = target.shape[0:2]
-    metric_mtx = torch.empty((batch_size, spk_num, spk_num), dtype=preds.dtype, device=target.device)
-    for t in range(spk_num):
-        for e in range(spk_num):
-            metric_mtx[:, t, e] = metric_func(preds[:, e, ...], target[:, t, ...], **kwargs)
+    metric_mtx = None
+    for target_idx in range(spk_num):  # we have spk_num speeches in target in each sample
+        for preds_idx in range(spk_num):  # we have spk_num speeches in preds in each sample
+            if metric_mtx is not None:
+                metric_mtx[:, target_idx, preds_idx] = metric_func(
+                    preds[:, preds_idx, ...], target[:, target_idx, ...], **kwargs
+                )
+            else:
+                first_ele = metric_func(preds[:, preds_idx, ...], target[:, target_idx, ...], **kwargs)
+                metric_mtx = torch.empty((batch_size, spk_num, spk_num), dtype=first_ele.dtype, device=first_ele.device)
+                metric_mtx[:, target_idx, preds_idx] = first_ele
 
     # find best
     op = torch.max if eval_func == "max" else torch.min


Test patch:
Repository: Lightning-AI/torchmetrics

Issue:
Code example error for AveragePrecision and PrecisionRecallCurve
## 📚 Documentation
In their binary case code examples, the `pred` inputs are integers, but shouldn't they be probabilities? 
<img width="575" alt="image" src="https://user-images.githubusercontent.com/28517073/147843097-ca5049ac-c3e0-4aa8-8988-b670552d1956.png">

Here is the scikit-learn counterpart, where probabilities are used.

<img width="520" alt="image" src="https://user-images.githubusercontent.com/28517073/147843102-49a6ff01-ef44-4376-8432-ae3431ff574d.png">


Discussion:
yeah, it shall be named as multi-class or fix the prediction... are you interested in sending PR with a quick fix? :]
@Borda - I'm looking to get more involved with contributions for pytorch lightning. Are you ok if I pick up this issue?
There is already an example for multi class, so I went ahead and updated the documentation for the binary class to fix the prediction values as floats. Also updated the values of `precision`, `recall`, and `thresholds` to match the output and validated that the floats match that from sklearn. Will link to the PR once completed.

Resolving patch:
diff --git a/torchmetrics/classification/avg_precision.py b/torchmetrics/classification/avg_precision.py
--- a/torchmetrics/classification/avg_precision.py
+++ b/torchmetrics/classification/avg_precision.py
@@ -67,7 +67,7 @@ class AveragePrecision(Metric):
 
     Example (binary case):
         >>> from torchmetrics import AveragePrecision
-        >>> pred = torch.tensor([0, 1, 2, 3])
+        >>> pred = torch.tensor([0, 0.1, 0.8, 0.4])
         >>> target = torch.tensor([0, 1, 1, 1])
         >>> average_precision = AveragePrecision(pos_label=1)
         >>> average_precision(pred, target)
diff --git a/torchmetrics/classification/precision_recall_curve.py b/torchmetrics/classification/precision_recall_curve.py
--- a/torchmetrics/classification/precision_recall_curve.py
+++ b/torchmetrics/classification/precision_recall_curve.py
@@ -53,16 +53,16 @@ class PrecisionRecallCurve(Metric):
 
     Example (binary case):
         >>> from torchmetrics import PrecisionRecallCurve
-        >>> pred = torch.tensor([0, 1, 2, 3])
+        >>> pred = torch.tensor([0, 0.1, 0.8, 0.4])
         >>> target = torch.tensor([0, 1, 1, 0])
         >>> pr_curve = PrecisionRecallCurve(pos_label=1)
         >>> precision, recall, thresholds = pr_curve(pred, target)
         >>> precision
-        tensor([0.6667, 0.5000, 0.0000, 1.0000])
+        tensor([0.6667, 0.5000, 1.0000, 1.0000])
         >>> recall
-        tensor([1.0000, 0.5000, 0.0000, 0.0000])
+        tensor([1.0000, 0.5000, 0.5000, 0.0000])
         >>> thresholds
-        tensor([1, 2, 3])
+        tensor([0.1000, 0.4000, 0.8000])
 
     Example (multiclass case):
         >>> pred = torch.tensor([[0.75, 0.05, 0.05, 0.05, 0.05],


Test patch:
Repository: Lightning-AI/torchmetrics

Issue:
TweedieDevianceScore producing nan results when setting power=1.0
## 🐛 Bug

<!-- A clear and concise description of what the bug is. -->

### To Reproduce

```>>> td=TweedieDevianceScore(power=1.0)
>>> targets=torch.tensor([0,1,0,1])
>>> preds=torch.tensor([0.1,0.1,0.1,0.1])
>>> td(preds,targets)
tensor(nan)
>>> td=TweedieDevianceScore(power=1.0001)
>>> td(preds,targets)
tensor(1.5038)```

I assume this is a bug since the documentation says targets >= 0 (obviously Poisson data will often be 0). 


Discussion:
Hi! thanks for your contribution!, great first issue!

Resolving patch:
diff --git a/torchmetrics/functional/regression/tweedie_deviance.py b/torchmetrics/functional/regression/tweedie_deviance.py
--- a/torchmetrics/functional/regression/tweedie_deviance.py
+++ b/torchmetrics/functional/regression/tweedie_deviance.py
@@ -19,6 +19,13 @@
 from torchmetrics.utilities.checks import _check_same_shape
 
 
+def xlogy(x: Tensor, y: Tensor) -> Tensor:
+    """Computes x * log(y). Returns 0 if x=0"""
+    res = x * torch.log(y)
+    res[x == 0] = 0.0
+    return res
+
+
 def _tweedie_deviance_score_update(preds: Tensor, targets: Tensor, power: float = 0.0) -> Tuple[Tensor, Tensor]:
     """Updates and returns variables required to compute Deviance Score for the given power. Checks for same shape
     of input tensors.
@@ -50,7 +57,7 @@ def _tweedie_deviance_score_update(preds: Tensor, targets: Tensor, power: float
                 f"For power={power}, 'preds' has to be strictly positive and 'targets' cannot be negative."
             )
 
-        deviance_score = 2 * (targets * torch.log(targets / preds) + preds - targets)
+        deviance_score = 2 * (xlogy(targets, targets / preds) + preds - targets)
     elif power == 2:
         # Gamma distribution
         if torch.any(preds <= 0) or torch.any(targets <= 0):


Test patch:
diff --git a/tests/regression/test_tweedie_deviance.py b/tests/regression/test_tweedie_deviance.py
--- a/tests/regression/test_tweedie_deviance.py
+++ b/tests/regression/test_tweedie_deviance.py
@@ -138,3 +138,13 @@ def test_error_on_invalid_inputs(metric_class=TweedieDevianceScore):
 
     with pytest.raises(ValueError, match="For power=2, both 'preds' and 'targets' have to be strictly positive."):
         metric(torch.rand(3), torch.tensor([-1.0, 2.0, 3.0]))
+
+
+def test_corner_case_for_power_at_1(metric_class=TweedieDevianceScore):
+    """Test that corner case for power=1.0 produce valid result."""
+    metric = TweedieDevianceScore()
+    targets = torch.tensor([0, 1, 0, 1])
+    preds = torch.tensor([0.1, 0.1, 0.1, 0.1])
+    val = metric(preds, targets)
+    assert val != 0.0
+    assert not torch.isnan(val)
Repository: Lightning-AI/torchmetrics

Issue:
Rename detection map file 
## 🐛 Bug

The MeanAveragePrecision metric is located in a file `torchmetrics/detection/map.py`. If you want to import this file, you would write `from torchmetrics.detection import map`. This replaces the built-in map function which is not so pretty.

Changing this file would avoid this. I suggest mean_ap.py.



Discussion:
Good point, mind sending a PR? :rabbit: 
cc: @SkafteNicki 
Fine by me :]

Resolving patch:
diff --git a/tm_examples/detection_map.py b/tm_examples/detection_map.py
--- a/tm_examples/detection_map.py
+++ b/tm_examples/detection_map.py
@@ -18,7 +18,7 @@
 
 import torch
 
-from torchmetrics.detection.map import MeanAveragePrecision
+from torchmetrics.detection.mean_ap import MeanAveragePrecision
 
 # Preds should be a list of elements, where each element is a dict
 # containing 3 keys: boxes, scores, labels
diff --git a/torchmetrics/detection/__init__.py b/torchmetrics/detection/__init__.py
--- a/torchmetrics/detection/__init__.py
+++ b/torchmetrics/detection/__init__.py
@@ -14,4 +14,4 @@
 from torchmetrics.utilities.imports import _TORCHVISION_GREATER_EQUAL_0_8
 
 if _TORCHVISION_GREATER_EQUAL_0_8:
-    from torchmetrics.detection.map import MeanAveragePrecision  # noqa: F401
+    from torchmetrics.detection.mean_ap import MeanAveragePrecision  # noqa: F401
diff --git a/torchmetrics/detection/map.py b/torchmetrics/detection/mean_ap.py
similarity index 99%
rename from torchmetrics/detection/map.py
rename to torchmetrics/detection/mean_ap.py
--- a/torchmetrics/detection/map.py
+++ b/torchmetrics/detection/mean_ap.py
@@ -179,7 +179,7 @@ class MeanAveragePrecision(Metric):
 
     Example:
         >>> import torch
-        >>> from torchmetrics.detection.map import MeanAveragePrecision
+        >>> from torchmetrics.detection.mean_ap import MeanAveragePrecision
         >>> preds = [
         ...   dict(
         ...     boxes=torch.Tensor([[258.0, 41.0, 606.0, 285.0]]),


Test patch:
diff --git a/tests/detection/test_map.py b/tests/detection/test_map.py
--- a/tests/detection/test_map.py
+++ b/tests/detection/test_map.py
@@ -18,7 +18,7 @@
 import torch
 
 from tests.helpers.testers import MetricTester
-from torchmetrics.detection.map import MeanAveragePrecision
+from torchmetrics.detection.mean_ap import MeanAveragePrecision
 from torchmetrics.utilities.imports import _TORCHVISION_AVAILABLE, _TORCHVISION_GREATER_EQUAL_0_8
 
 Input = namedtuple("Input", ["preds", "target"])
diff --git a/tests/helpers/testers.py b/tests/helpers/testers.py
--- a/tests/helpers/testers.py
+++ b/tests/helpers/testers.py
@@ -24,7 +24,7 @@
 from torch.multiprocessing import Pool, set_start_method
 
 from torchmetrics import Metric
-from torchmetrics.detection.map import MAPMetricResults
+from torchmetrics.detection.mean_ap import MAPMetricResults
 from torchmetrics.utilities.data import apply_to_collection
 
 try: