code: def find_neighbor_changepoints(cp_idx, min_index_distance=2):
      """Finds neighbor change points given their indices
  
      For example
          x = [1, 2, 3, 7, 8, 10, 15, 20]
      The return with `min_index_distance`=2 is
          result = [[1, 2, 3], [7, 8], [10], [15], [20]]
      The return with `min_index_distance`=3 is
          result = [[1, 2, 3], [7, 8, 10], [15], [20]]
  
      Parameters
      ----------
      cp_idx : `list`
          A list of the change point indices.
      min_index_distance : `int`
          The minimal index distance to be considered separate
  
      Returns
      -------
      neighbor_cps : `list`
          A list of neighbor change points lists. Single change points are put in a list as well.
      """
      if min_index_distance <= 0:
          raise ValueError("`min_index_distance` must be positive.")
      if len(cp_idx) <= 1:
          return [cp_idx]
      # check if sorted
      is_sorted = True
      for i in range(1, len(cp_idx)):
          if cp_idx[i] < cp_idx[i - 1]:
              is_sorted = False
              break
      # sort if `cp_idx` is not sorted
      if not is_sorted:
          cp_idx.sort()
          warnings.warn(
              "The given `cp_idx` is not sorted. It has been sorted."
          )
      neighbor_cps = []
      i = 0
      while i < len(cp_idx):
          neighbor_cps.append([])
          neighbor_cps[-1].append(cp_idx[i])
          i += 1
          while (
              i < len(cp_idx)
              and cp_idx[i] < neighbor_cps[-1][-1] + min_index_distance
          ):
              neighbor_cps[-1].append(cp_idx[i])
              i += 1
      return neighbor_cps
  
imports: import warnings
  from datetime import timedelta
  import numpy
  import pandas
  import plotly.graph_objects
  from pandas.plotting import register_matplotlib_converters
  from pandas.tseries.frequencies import to_offset
  from sklearn.linear_model import Lasso
  from sklearn.linear_model import LassoCV
  from sklearn.linear_model import LinearRegression
  from sklearn.linear_model import RidgeCV
  from greykite.common.constants import CHANGEPOINT_COL_PREFIX
  from greykite.common.constants import TimeFeaturesEnum
  from greykite.common.features.timeseries_features import add_time_features_df
  from greykite.common.features.timeseries_features import build_time_features_df
  from greykite.common.features.timeseries_features import fourier_series_multi_fcn
  from greykite.common.features.timeseries_features import get_changepoint_dates_from_changepoints_dict
  from greykite.common.features.timeseries_features import get_changepoint_features
  from greykite.common.features.timeseries_features import get_changepoint_features_and_values_from_config
  from greykite.common.features.timeseries_features import get_default_origin_for_time_vars
  from greykite.common.python_utils import get_pattern_cols
  from greykite.common.python_utils import unique_elements_in_list
label_desc: Use image node_id 8 for calling a global function with example usage: find_neighbor_changepoints(cp_idx, min_index_distance) and returns: neighbor_cps, list