code: def adaptive_grid(
      values: np.ndarray, min_bin_points: int = 1
  ) -> Tuple[np.ndarray, int]:
      """
      Find the optimal number of quantiles for the range of values so that each resulting bin
      contains at least `min_bin_points`. Uses bisection.
  
      Parameters
      ----------
      values
          Array of feature values.
      min_bin_points
          Minimum number of points each discretized interval should contain to ensure more precise
          ALE estimation.
  
      Returns
      -------
      q
          Unique quantiles.
      num_quantiles
          Number of non-unique quantiles the feature array was subdivided into.
  
      Notes
      -----
      This is a heuristic procedure since the bisection algorithm is applied
      to a function which is not monotonic. This will not necessarily find the
      maximum number of bins the interval can be subdivided into to satisfy
      the minimum number of points in each resulting bin.
      """
  
      # function to bisect
      def minimum_not_satisfied(
          values: np.ndarray, min_bin_points: int, n: int
      ) -> int:
          """
          Logical not of `minimum_satisfied`, see function for parameter information.
          """
          return 1 - minimum_satisfied(values, min_bin_points, n)
  
      fun = partial(minimum_not_satisfied, values, min_bin_points)
  
      # bisect
      num_quantiles = (
          bisect_fun(fun=fun, target=0.5, lo=0, hi=len(values)) - 1
      )
      q = np.unique(get_quantiles(values, num_quantiles=num_quantiles))
  
      return q, num_quantiles
  
imports: import copy
  import math
  import numpy
  import pandas
  from itertools import count
  from functools import partial
  from typing import Callable, List, Optional, Tuple, Union, Dict, TYPE_CHECKING, no_type_check
  import sys
  import logging
  from alibi.api.interfaces import Explainer, Explanation
  from alibi.api.defaults import DEFAULT_META_ALE, DEFAULT_DATA_ALE
label_desc: Use image node_id 4 for calling a global function with example usage: adaptive_grid(values, min_bin_points) and returns: q,  num_quantiles, unknown