code: def _mi_high_dim_cd(
      arr: np.ndarray,
      arr_d: np.ndarray,
      k: int,
      estimate_method: str,
      weights: np.ndarray,
  ) -> Tuple[float, np.ndarray]:
      """Computes high dimensional MI between ordinal and categorical features."""
      n_samples = arr_d.size
      radius = np.empty(n_samples)
      label_counts = np.empty(n_samples)
      k_all = np.empty(n_samples)
  
      nn = sklearn.neighbors.NearestNeighbors(
          metric="chebyshev", n_neighbors=k, n_jobs=1
      )
      each = np.zeros(n_samples)
      for label in np.unique(arr_d):
          mask = arr_d == label
          count = np.sum(mask)
          if count > 1:
              cur_k = min(k, count - 1)
  
              nn.set_params(n_neighbors=cur_k)
              nn.fit(arr[mask])
              k_neighbors = nn.kneighbors()
              if estimate_method == "smaller_data":
                  # When we count the number of points that fall in the sphere of this
                  # radius in each of the two sub feature spaces, we need to exclude the
                  # points on the boundary by taking a radius slightly smaller than the
                  # distance to the k-th nearest neighbor.
                  radius[mask] = np.nextafter(k_neighbors[0][:, -1], 0)
              elif estimate_method == "larger_data":
                  radius[mask] = k_neighbors[0][:, -1]
              k_all[mask] = cur_k
          label_counts[mask] = count
  
      # Ignore the labels that contain only one data point.
      mask = label_counts > 1
      if not np.any(mask):
          raise ValueError(
              "The tuples defined by discrete features (of either side) are all "
              "unique."
          )
  
      n_samples = np.sum(mask)
      label_counts = label_counts[mask]
      k_all = k_all[mask]
      arr = arr[mask]
      radius = radius[mask]
      weights = weights[mask]
  
      mi, mi_each = _process_high_dim(
          arr, radius, estimate_method, weights
      )
      mi /= n_samples
  
      extra = (
          scipy.special.digamma(n_samples)
          + scipy.special.digamma(k_all)
          - scipy.special.digamma(label_counts)
      ) * weights
      mi += np.mean(extra)
      each[mask] += mi_each + extra
  
      final_mi = max(0.0, mi / math.log(2))
      return final_mi, each / math.log(2)
  
imports: import functools
  import itertools
  import math
  from typing import Any, List, Optional, Tuple, Union
  import uuid
  import numpy
  import pandas
  import scipy.special
  import sklearn.neighbors
label_desc: Use image node_id 17 for calling a global function with example usage: _mi_high_dim_cd(arr, arr_d, k, estimate_method, weights) and returns: final_mi,  unknown