code: def test_nan_expected(metric_class, nan_strategy, value, expected):
      """Test that nan values are handled correctly."""
      metric = metric_class(nan_strategy=nan_strategy)
      metric.update(value.clone())
      out = metric.compute()
      assert np.allclose(out, expected, equal_nan=True)
  
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 6 for calling a global function with example usage: test_nan_expected(metric_class, nan_strategy, value, expected) without return types