code: def test_metric_collection_args_kwargs(tmpdir):
      """Check that args and kwargs gets passed correctly in metric collection, checks both update and forward."""
      m1 = DummyMetricSum()
      m2 = DummyMetricDiff()
  
      metric_collection = MetricCollection([m1, m2])
  
      # args gets passed to all metrics
      metric_collection.update(5)
      assert metric_collection["DummyMetricSum"].x == 5
      assert metric_collection["DummyMetricDiff"].x == -5
      metric_collection.reset()
      _ = metric_collection(5)
      assert metric_collection["DummyMetricSum"].x == 5
      assert metric_collection["DummyMetricDiff"].x == -5
      metric_collection.reset()
  
      # kwargs gets only passed to metrics that it matches
      metric_collection.update(x=10, y=20)
      assert metric_collection["DummyMetricSum"].x == 10
      assert metric_collection["DummyMetricDiff"].x == -20
      metric_collection.reset()
      _ = metric_collection(x=10, y=20)
      assert metric_collection["DummyMetricSum"].x == 10
      assert metric_collection["DummyMetricDiff"].x == -20
  
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 4 for calling a global function with example usage: test_metric_collection_args_kwargs(tmpdir) without return types