code: def test_nested_collections(input_collections):
      """Test that nested collections gets flattened to a single collection."""
      metrics = MetricCollection(
          input_collections, prefix="valmetrics/"
      )
      preds = torch.randn(10, 3).softmax(dim=-1)
      target = torch.randint(3, (10,))
      val = metrics(preds, target)
      assert "valmetrics/macro_MulticlassAccuracy" in val
      assert "valmetrics/macro_MulticlassPrecision" in val
      assert "valmetrics/micro_MulticlassAccuracy" in val
      assert "valmetrics/micro_MulticlassPrecision" in val
  
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 14 for calling a global function with example usage: test_nested_collections(input_collections) without return types