code: def test_compute(self):
      sur_metric = SurfaceDistance(include_background=True)
  
      def _val_func(engine, batch):
          pass
  
      engine = Engine(_val_func)
      sur_metric.attach(engine, "surface_distance")
  
      y_pred, y = TEST_SAMPLE_1
      sur_metric.update([y_pred, y])
      self.assertAlmostEqual(sur_metric.compute(), 4.17133, places=4)
      y_pred, y = TEST_SAMPLE_2
      sur_metric.update([y_pred, y])
      self.assertAlmostEqual(sur_metric.compute(), 2.08566, places=4)
      y_pred, y = TEST_SAMPLE_3
      sur_metric.update([y_pred, y])
      self.assertAlmostEqual(sur_metric.compute(), float("inf"))
      y_pred, y = TEST_SAMPLE_4
      sur_metric.update([y_pred, y])
      self.assertAlmostEqual(sur_metric.compute(), float("inf"))
  
file_path: MONAI/tests/test_handler_surface_distance.py
imports: from __future__ import annotations
  import unittest
  import numpy
  import torch
  from ignite.engine import Engine
  from monai.handlers import SurfaceDistance
  from tests.utils import assert_allclose
label_desc: Use image node_id 1 for calling the TestHandlerSurfaceDistance obj's underlying member method code with example usage: obj.test_compute() without return types