code: def test_class_reduce():
      """Test that class reduce function works as expected."""
      num = torch.randint(1, 10, (100,)).float()
      denom = torch.randint(10, 20, (100,)).float()
      weights = torch.randint(1, 100, (100,)).float()
  
      assert torch.allclose(
          class_reduce(num, denom, weights, "micro"),
          torch.sum(num) / torch.sum(denom),
      )
      assert torch.allclose(
          class_reduce(num, denom, weights, "macro"),
          torch.mean(num / denom),
      )
      assert torch.allclose(
          class_reduce(num, denom, weights, "weighted"),
          torch.sum(num / denom * (weights / torch.sum(weights))),
      )
      assert torch.allclose(
          class_reduce(num, denom, weights, "none"), num / denom
      )
  
imports: import sys
  import numpy
  import pytest
  import torch
  from torch import tensor
  from torchmetrics.regression import MeanSquaredError, PearsonCorrCoef
  from torchmetrics.utilities import check_forward_full_state_property, rank_zero_debug, rank_zero_info, rank_zero_warn
  from torchmetrics.utilities.checks import _allclose_recursive
  from torchmetrics.utilities.data import _bincount, _cumsum, _flatten, _flatten_dict, select_topk, to_categorical, to_onehot
  from torchmetrics.utilities.distributed import class_reduce, reduce
  from torchmetrics.utilities.exceptions import TorchMetricsUserWarning
  from torchmetrics.utilities.imports import _TORCH_GREATER_EQUAL_1_13
label_desc: Use image node_id 3 for calling a global function with example usage: test_class_reduce() without return types