code: def get_edge_surface_distance(
      y_pred: torch.Tensor,
      y: torch.Tensor,
      distance_metric: str = "euclidean",
      spacing: int
      | float
      | np.ndarray
      | Sequence[int | float]
      | None = None,
      use_subvoxels: bool = False,
      symmetric: bool = False,
      class_index: int = -1,
  ) -> tuple[
      tuple[torch.Tensor, torch.Tensor],
      tuple[torch.Tensor, torch.Tensor] | tuple[torch.Tensor],
      tuple[torch.Tensor, torch.Tensor] | tuple[()],
  ]:
      """
      This function is used to compute the surface distance from `y_pred` to `y` using the edges of the masks.
  
      Args:
          y_pred: the predicted binary or labelfield image. Expected to be in format (H, W[, D]).
          y: the actual binary or labelfield image. Expected to be in format (H, W[, D]).
          distance_metric: : [``"euclidean"``, ``"chessboard"``, ``"taxicab"``]
              See :py:func:`monai.metrics.utils.get_surface_distance`.
          spacing: spacing of pixel (or voxel). This parameter is relevant only if ``distance_metric`` is set to ``"euclidean"``.
              See :py:func:`monai.metrics.utils.get_surface_distance`.
          use_subvoxels: whether to use subvoxel resolution (using the spacing).
              This will return the areas of the edges.
          symmetric: whether to compute the surface distance from `y_pred` to `y` and from `y` to `y_pred`.
          class_index: The class-index used for context when warning about empty ground truth or prediction.
  
      Returns:
          (edges_pred, edges_gt), (distances_pred_to_gt, [distances_gt_to_pred]), (areas_pred, areas_gt) | tuple()
  
      """
      edges_spacing = None
      if use_subvoxels:
          edges_spacing = (
              spacing
              if spacing is not None
              else ([1] * len(y_pred.shape))
          )
      (edges_pred, edges_gt, *areas) = get_mask_edges(
          y_pred,
          y,
          crop=True,
          spacing=edges_spacing,
          always_return_as_numpy=False,
      )
      if not edges_gt.any():
          warnings.warn(
              f"the ground truth of class {class_index if class_index != -1 else 'Unknown'} is all 0,"
              " this may result in nan/inf distance."
          )
      if not edges_pred.any():
          warnings.warn(
              f"the prediction of class {class_index if class_index != -1 else 'Unknown'} is all 0,"
              " this may result in nan/inf distance."
          )
      distances: tuple[torch.Tensor, torch.Tensor] | tuple[torch.Tensor]
      if symmetric:
          distances = (
              get_surface_distance(
                  edges_pred, edges_gt, distance_metric, spacing
              ),
              get_surface_distance(
                  edges_gt, edges_pred, distance_metric, spacing
              ),
          )  # type: ignore
      else:
          distances = (get_surface_distance(edges_pred, edges_gt, distance_metric, spacing),)  # type: ignore
      return convert_to_tensor(
          ((edges_pred, edges_gt), distances, tuple(areas)),
          device=y_pred.device,
      )
  
imports: from __future__ import annotations
  import warnings
  from functools import lru_cache, partial
  from types import ModuleType
  from typing import Any, Iterable, Sequence
  import numpy
  import torch
  from monai.config import NdarrayOrTensor, NdarrayTensor
  from monai.transforms.croppad.dictionary import CropForegroundD
  from monai.transforms.utils import distance_transform_edt
  from monai.utils import MetricReduction, convert_to_cupy, convert_to_dst_type, convert_to_numpy, convert_to_tensor, deprecated_arg, deprecated_arg_default, ensure_tuple_rep, look_up_option, optional_import
label_desc: Use image node_id 5 for calling a global function with example usage: get_edge_surface_distance(y_pred, y, distance_metric, spacing, use_subvoxels, symmetric, class_index) and returns: convert_to_tensor