class_docstr: Test class collection different tests for different properties parametrized by backend argument.
class_docstr_tok: ["Test","class","collection","different","tests","for","different","properties","parametrized","by","backend","argument","."]
docstr: Test class input validation.
docstr_tok: ["Test","class","input","validation","."]
code: def test_error_on_wrong_input(self, backend):
      """Test class input validation."""
      metric = MeanAveragePrecision(backend=backend)
  
      metric.update([], [])  # no error
  
      with pytest.raises(
          ValueError,
          match="Expected argument `preds` to be of type Sequence",
      ):
          metric.update(Tensor(), [])  # type: ignore
  
      with pytest.raises(
          ValueError,
          match="Expected argument `target` to be of type Sequence",
      ):
          metric.update([], Tensor())  # type: ignore
  
      with pytest.raises(
          ValueError,
          match="Expected argument `preds` and `target` to have the same length",
      ):
          metric.update([{}], [{}, {}])
  
      with pytest.raises(
          ValueError,
          match="Expected all dicts in `preds` to contain the `boxes` key",
      ):
          metric.update(
              [{"scores": Tensor(), "labels": IntTensor}],
              [{"boxes": Tensor(), "labels": IntTensor()}],
          )
  
      with pytest.raises(
          ValueError,
          match="Expected all dicts in `preds` to contain the `scores` key",
      ):
          metric.update(
              [{"boxes": Tensor(), "labels": IntTensor}],
              [{"boxes": Tensor(), "labels": IntTensor()}],
          )
  
      with pytest.raises(
          ValueError,
          match="Expected all dicts in `preds` to contain the `labels` key",
      ):
          metric.update(
              [{"boxes": Tensor(), "scores": IntTensor}],
              [{"boxes": Tensor(), "labels": IntTensor()}],
          )
  
      with pytest.raises(
          ValueError,
          match="Expected all dicts in `target` to contain the `boxes` key",
      ):
          metric.update(
              [
                  {
                      "boxes": Tensor(),
                      "scores": IntTensor,
                      "labels": IntTensor,
                  }
              ],
              [{"labels": IntTensor()}],
          )
  
      with pytest.raises(
          ValueError,
          match="Expected all dicts in `target` to contain the `labels` key",
      ):
          metric.update(
              [
                  {
                      "boxes": Tensor(),
                      "scores": IntTensor,
                      "labels": IntTensor,
                  }
              ],
              [{"boxes": IntTensor()}],
          )
  
      with pytest.raises(
          ValueError,
          match="Expected all boxes in `preds` to be of type Tensor",
      ):
          metric.update(
              [
                  {
                      "boxes": [],
                      "scores": Tensor(),
                      "labels": IntTensor(),
                  }
              ],
              [{"boxes": Tensor(), "labels": IntTensor()}],
          )
  
      with pytest.raises(
          ValueError,
          match="Expected all scores in `preds` to be of type Tensor",
      ):
          metric.update(
              [
                  {
                      "boxes": Tensor(),
                      "scores": [],
                      "labels": IntTensor(),
                  }
              ],
              [{"boxes": Tensor(), "labels": IntTensor()}],
          )
  
      with pytest.raises(
          ValueError,
          match="Expected all labels in `preds` to be of type Tensor",
      ):
          metric.update(
              [{"boxes": Tensor(), "scores": Tensor(), "labels": []}],
              [{"boxes": Tensor(), "labels": IntTensor()}],
          )
  
      with pytest.raises(
          ValueError,
          match="Expected all boxes in `target` to be of type Tensor",
      ):
          metric.update(
              [
                  {
                      "boxes": Tensor(),
                      "scores": Tensor(),
                      "labels": IntTensor(),
                  }
              ],
              [{"boxes": [], "labels": IntTensor()}],
          )
  
      with pytest.raises(
          ValueError,
          match="Expected all labels in `target` to be of type Tensor",
      ):
          metric.update(
              [
                  {
                      "boxes": Tensor(),
                      "scores": Tensor(),
                      "labels": IntTensor(),
                  }
              ],
              [{"boxes": Tensor(), "labels": []}],
          )
  
imports: import contextlib
  import io
  import json
  from copy import deepcopy
  from functools import partial
  from itertools import product
  import numpy
  import pytest
  import torch
  from lightning_utilities import apply_to_collection
  from pycocotools.coco import COCO
  from pycocotools.cocoeval import COCOeval
  from torch import IntTensor, Tensor
  from torchmetrics.detection.mean_ap import MeanAveragePrecision
  from torchmetrics.utilities.imports import _FASTER_COCO_EVAL_AVAILABLE, _PYCOCOTOOLS_AVAILABLE, _TORCHVISION_GREATER_EQUAL_0_8
  from unittests.detection import _DETECTION_BBOX, _DETECTION_SEGM, _DETECTION_VAL
  from unittests.helpers.testers import MetricTester
label_desc: Use image node_id 15 for calling the TestMapProperties obj's underlying member method code with example usage: obj.test_error_on_wrong_input(backend) without return types