code: def _compute_pd(distances: npt.NDArray[np.float32]) -> float:
      pd = 0
  
      n = distances.shape[0]
      adjacency = np.zeros((n, n), dtype=bool)
      for _ in range(n - 1):
          i, j, dist = _get_ij_dist(distances)
  
          while _is_connected(adjacency, i, j):
              if distances[i, j] != -1:
                  distances[i, j] = float("inf")
              if distances[j, i] != -1:
                  distances[j, i] = float("inf")
              i, j, dist = _get_ij_dist(distances)
  
          adjacency[i, j] = True
          adjacency[j, i] = True
          pd += dist
          if distances[j, i] == -1:
              distances[j, i] = float("inf")
          distances[i] = -1
  
      return pd
  
file_path: gluonts/src/gluonts/nursery/tsbench/src/tsbench/analysis/utils/mo_metrics.py
imports: from typing import Tuple
  import numpy
  import numpy.typing
  import pygmo
  import scipy.spatial
label_desc: Use image node_id 4 for calling a global function with example usage: _compute_pd(distances) and returns: pd