code: def test_metric_collection_wrong_input(tmpdir):
      """Check that errors are raised on wrong input."""
      dms = DummyMetricSum()
  
      # Not all input are metrics (list)
      with pytest.raises(
          ValueError,
          match="Input .* to `MetricCollection` is not a instance of .*",
      ):
          _ = MetricCollection([dms, 5])
  
      # Not all input are metrics (dict)
      with pytest.raises(
          ValueError,
          match="Value .* belonging to key .* is not an instance of .*",
      ):
          _ = MetricCollection({"metric1": dms, "metric2": 5})
  
      # Same metric passed in multiple times
      with pytest.raises(
          ValueError, match="Encountered two metrics both named *."
      ):
          _ = MetricCollection([dms, dms])
  
      # Not a list or dict passed in
      with pytest.warns(
          Warning,
          match=" which are not `Metric` so they will be ignored.",
      ):
          _ = MetricCollection(dms, [dms])
  
imports: import pickle
  from copy import deepcopy
  from typing import Any
  import pytest
  import torch
  from torchmetrics import Metric, MetricCollection
  from torchmetrics.classification import BinaryAccuracy, MulticlassAccuracy, MulticlassAUROC, MulticlassAveragePrecision, MulticlassCohenKappa, MulticlassConfusionMatrix, MulticlassF1Score, MulticlassMatthewsCorrCoef, MulticlassPrecision, MulticlassRecall, MultilabelAUROC, MultilabelAveragePrecision
  from torchmetrics.utilities.checks import _allclose_recursive
  from unittests.helpers import seed_all
  from unittests.helpers.testers import DummyMetricDiff, DummyMetricMultiOutputDict, DummyMetricSum
label_desc: Use image node_id 3 for calling a global function with example usage: test_metric_collection_wrong_input(tmpdir) without return types