code: def test_compute_surface_dice_subvoxel(self):
      mask_gt, mask_pred = torch.zeros(
          1, 1, 128, 128, 128
      ), torch.zeros(1, 1, 128, 128, 128)
      mask_gt[0, 0, 50, 60, 70] = 1
      res = compute_surface_dice(
          mask_pred,
          mask_gt,
          [1.0],
          include_background=True,
          spacing=(3, 2, 1),
          use_subvoxels=True,
      )
      assert_allclose(res, 0.0, type_test=False)
      mask_gt[0, 0, 50, 60, 70] = 0
      mask_pred[0, 0, 50, 60, 72] = 1
      res = compute_surface_dice(
          mask_pred,
          mask_gt,
          [1.0],
          include_background=True,
          spacing=(3, 2, 1),
          use_subvoxels=True,
      )
      assert_allclose(res, 0.0, type_test=False)
      mask_gt[0, 0, 50, 60, 70] = 1
      mask_pred[0, 0, 50, 60, 72] = 1
      res = compute_surface_dice(
          mask_pred,
          mask_gt,
          [1.0],
          include_background=True,
          spacing=(3, 2, 1),
          use_subvoxels=True,
      )
      assert_allclose(res, 0.5, type_test=False)
  
      d = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
      mask_gt, mask_pred = torch.zeros(
          1, 1, 100, 100, 100, device=d
      ), torch.zeros(1, 1, 100, 100, 100, device=d)
      mask_gt[0, 0, 0:50, :, :] = 1
      mask_pred[0, 0, 0:51, :, :] = 1
      res = compute_surface_dice(
          mask_pred,
          mask_gt,
          [1.0],
          include_background=True,
          spacing=(2, 1, 1),
          use_subvoxels=True,
      )
      assert_allclose(
          res, 0.836145, type_test=False, atol=1e-3, rtol=1e-3
      )
  
file_path: MONAI/tests/test_surface_dice.py
imports: from __future__ import annotations
  import unittest
  import numpy
  import torch
  import torch.nn.functional
  from monai.metrics.surface_dice import SurfaceDiceMetric, compute_surface_dice
  from tests.utils import assert_allclose
label_desc: Use image node_id 7 for calling the TestAllSurfaceDiceMetrics obj's underlying member method code with example usage: obj.test_compute_surface_dice_subvoxel() without return types