code: def test_reduce():
      """Test that reduction function works as expected and also raises error on wrong input."""
      start_tensor = torch.rand(50, 40, 30)
  
      assert torch.allclose(
          reduce(start_tensor, "elementwise_mean"),
          torch.mean(start_tensor),
      )
      assert torch.allclose(
          reduce(start_tensor, "sum"), torch.sum(start_tensor)
      )
      assert torch.allclose(reduce(start_tensor, "none"), start_tensor)
  
      with pytest.raises(
          ValueError, match="Reduction parameter unknown."
      ):
          reduce(start_tensor, "error_reduction")
  
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 2 for calling a global function with example usage: test_reduce() without return types