code: def test_compute(self):
      set_determinism(seed=123)
      device = "cuda" if torch.cuda.is_available() else "cpu"
  
      # regression metrics to check + truth metric function in numpy
      metrics = [
          MeanSquaredError,
          MeanAbsoluteError,
          RootMeanSquaredError,
          partial(PeakSignalToNoiseRatio, max_val=1.0),
      ]
      metrics_np = [
          msemetric_np,
          maemetric_np,
          rmsemetric_np,
          partial(psnrmetric_np, max_val=1.0),
      ]
  
      # define variations in batch/base_dims/spatial_dims
      batch_dims = [1, 2, 4, 16]
      base_dims = [16, 32, 64]
      spatial_dims = [2, 3, 4]
  
      # iterate over all variations and check shapes for different reduction functions
      for mt_fn, mt_fn_np in zip(metrics, metrics_np):
          for batch in batch_dims:
              for spatial in spatial_dims:
                  for base in base_dims:
                      mt_fn_obj = mt_fn(**{"save_details": False})
  
                      # create random tensor
                      in_tensor_a1 = torch.rand(
                          (batch,) + (base,) * (spatial - 1)
                      ).to(device)
                      in_tensor_b1 = torch.rand(
                          (batch,) + (base,) * (spatial - 1)
                      ).to(device)
                      mt_fn_obj.update([in_tensor_a1, in_tensor_b1])
                      out_tensor_np1 = mt_fn_np(
                          y_pred=in_tensor_a1.cpu().numpy(),
                          y=in_tensor_b1.cpu().numpy(),
                      )
  
                      in_tensor_a2 = torch.rand(
                          (batch,) + (base,) * (spatial - 1)
                      ).to(device)
                      in_tensor_b2 = torch.rand(
                          (batch,) + (base,) * (spatial - 1)
                      ).to(device)
                      mt_fn_obj.update([in_tensor_a2, in_tensor_b2])
                      out_tensor_np2 = mt_fn_np(
                          y_pred=in_tensor_a2.cpu().numpy(),
                          y=in_tensor_b2.cpu().numpy(),
                      )
  
                      out_tensor = mt_fn_obj.compute()
                      out_tensor_np = (
                          out_tensor_np1 + out_tensor_np2
                      ) / 2.0
  
                      np.testing.assert_allclose(
                          out_tensor, out_tensor_np, atol=1e-4
                      )
  
file_path: MONAI/tests/test_handler_regression_metrics.py
imports: from __future__ import annotations
  import unittest
  from functools import partial
  import numpy
  import torch
  from ignite.engine import Engine
  from monai.handlers import MeanAbsoluteError, MeanSquaredError, PeakSignalToNoiseRatio, RootMeanSquaredError
  from monai.utils import set_determinism
label_desc: Use image node_id 1 for calling the TestHandlerRegressionMetrics obj's underlying member method code with example usage: obj.test_compute() without return types