code: def test_mean_metric_broadcasting(weights, expected):
      """Check that weight broadcasting works for mean metric."""
      values = torch.arange(24).reshape(2, 3, 4)
      avg = MeanMetric()
  
      assert avg(values, weights) == expected
  
imports: import numpy
  import pytest
  import torch
  from torchmetrics.aggregation import CatMetric, MaxMetric, MeanMetric, MinMetric, SumMetric
  from torchmetrics.collections import MetricCollection
  from unittests import BATCH_SIZE, NUM_BATCHES
  from unittests.helpers.testers import MetricTester
label_desc: Use image node_id 8 for calling a global function with example usage: test_mean_metric_broadcasting(weights, expected) without return types