code: def test_surface_distance(cases, distance_metric, spacing, device):
      """Test the surface distance function."""
      if device == "cuda" and not torch.cuda.is_available():
          pytest.skip("CUDA device not available.")
      if spacing != 1 and distance_metric != "euclidean":
          pytest.skip(
              "Only euclidean distance is supported for spacing != 1 in reference"
          )
      preds, target = cases
      spacing = 2 * [spacing]
      res = surface_distance(
          preds.to(device),
          target.to(device),
          distance_metric=distance_metric,
          spacing=spacing,
      )
      reference_res = monai_get_surface_distance(
          preds.numpy(),
          target.numpy(),
          distance_metric=distance_metric,
          spacing=spacing,
      )
      assert torch.allclose(
          res.cpu(), torch.from_numpy(reference_res).to(res.dtype)
      )
  
file_path: torchmetrics/tests/unittests/segmentation/test_utils.py
imports: import pytest
  import torch
  from monai.metrics.utils import get_code_to_measure_table
  from monai.metrics.utils import get_mask_edges
  from monai.metrics.utils import get_surface_distance
  from scipy.ndimage import binary_erosion
  from scipy.ndimage import distance_transform_cdt
  from scipy.ndimage import distance_transform_edt
  from scipy.ndimage import generate_binary_structure
  from torchmetrics.functional.segmentation.utils import binary_erosion, distance_transform, generate_binary_structure, get_neighbour_tables, mask_edges, surface_distance
label_desc: Use image node_id 6 for calling a global function with example usage: test_surface_distance(cases, distance_metric, spacing, device) without return types