code: def close_distance_matrix(X: npt.ArrayLike, k: int, frac: float):
      """Calculate distance between close pairs.
  
      Parameters
      ----------
      X : np.ArrayLike
          Data to be transformed
      k : int
          Number of nearest neighbours considered. If k = None, it is empirically
          derived as ``min(0.05 * number of observations, 20)``
  
      Returns
      -------
      pd.DataFrame of pairs of close neighbour indices
      """
      X = pd.DataFrame(X)
      nbrs = NearestNeighbors(
          n_neighbors=k + 1, metric="euclidean"
      ).fit(X)
      _, indices = nbrs.kneighbors(X)
  
      dist = pd.DataFrame(
          [
              ((X.iloc[i,] - X.iloc[j,]) ** 2).tolist()
              for (i, j) in zip(
                  np.repeat(indices[:, 0], repeats=k),
                  indices[:, 1:].flatten(),
              )
          ]
      )
  
      row_sums = dist.apply(sum, axis=1)
      q_frac = np.quantile(row_sums, q=frac)
  
      mask = row_sums > q_frac
  
      return dist.loc[mask,]
  
file_path: sktime/sktime/transformations/series/dobin.py
imports: import warnings
  import numpy
  import numpy.typing
  import pandas
  from pandas.api.types import is_numeric_dtype
  from sklearn.decomposition import PCA
  from sklearn.neighbors import NearestNeighbors
  from sktime.transformations.base import BaseTransformer
label_desc: Use image node_id 1 for calling a global function with example usage: close_distance_matrix(X, k, frac) and returns: dist