code: def test_compare_numpy(self):
      set_determinism(seed=123)
      device = "cuda" if torch.cuda.is_available() else "cpu"
  
      # regression metrics to check + truth metric function in numpy
      metrics = [
          MSEMetric,
          MAEMetric,
          RMSEMetric,
          partial(PSNRMetric, 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 batch in batch_dims:
          for spatial in spatial_dims:
              for base in base_dims:
                  # create random tensors
                  in_tensor_a = torch.rand(
                      (batch,) + (base,) * (spatial - 1)
                  ).to(device)
                  in_tensor_b = torch.rand(
                      (batch,) + (base,) * (spatial - 1)
                  ).to(device)
  
                  # check metrics
                  for mt_fn, mt_fn_np in zip(metrics, metrics_np):
                      mt = mt_fn()
                      mt(y_pred=in_tensor_a, y=in_tensor_b)
                      out_tensor = mt.aggregate(reduction="mean")
                      out_np = mt_fn_np(
                          y_pred=in_tensor_a.cpu().numpy(),
                          y=in_tensor_b.cpu().numpy(),
                      )
  
                      np.testing.assert_allclose(
                          out_tensor.cpu().numpy(), out_np, atol=1e-4
                      )
  
file_path: MONAI/tests/test_compute_regression_metrics.py
imports: from __future__ import annotations
  import unittest
  from functools import partial
  import numpy
  import torch
  from monai.metrics import MAEMetric, MSEMetric, PSNRMetric, RMSEMetric
  from monai.utils import set_determinism
label_desc: Use image node_id 2 for calling the TestRegressionMetrics obj's underlying member method code with example usage: obj.test_compare_numpy() without return types