code: def compute_percent_hausdorff_distance(
      edges_pred: np.ndarray,
      edges_gt: np.ndarray,
      distance_metric: str = "euclidean",
      percentile: float | None = None,
      spacing: int
      | float
      | np.ndarray
      | Sequence[int | float]
      | None = None,
  ) -> float:
      """
      This function is used to compute the directed Hausdorff distance.
      """
  
      surface_distance: np.ndarray = get_surface_distance(  # type: ignore
          edges_pred,
          edges_gt,
          distance_metric=distance_metric,
          spacing=spacing,
      )
  
      # for both pred and gt do not have foreground
      if surface_distance.shape == (0,):
          return np.nan
  
      if not percentile:
          return surface_distance.max()  # type: ignore[no-any-return]
  
      if 0 <= percentile <= 100:
          return np.percentile(surface_distance, percentile)  # type: ignore[no-any-return]
      raise ValueError(
          f"percentile should be a value between 0 and 100, get {percentile}."
      )
  
file_path: MONAI/monai/metrics/hausdorff_distance.py
imports: from __future__ import annotations
  from collections.abc import Sequence
  from typing import Any
  import numpy
  import torch
  from monai.metrics.utils import do_metric_reduction, get_edge_surface_distance, get_surface_distance, ignore_background, prepare_spacing
  from monai.utils import MetricReduction, convert_data_type, deprecated
  from .metric import CumulativeIterationMetric
label_desc: Use image node_id 3 for calling a global function with example usage: compute_percent_hausdorff_distance(edges_pred, edges_gt, distance_metric, percentile, spacing) and returns: np, surface_distance, np