code: def combine_detected_and_custom_trend_changepoints(
      detected_changepoint_dates,
      custom_changepoint_dates,
      min_distance=None,
      keep_detected=False,
  ):
      """Adds custom trend changepoints to detected trend changepoints.
  
      Compares the distance between custom changepoints and detected changepoints,
      and drops a detected changepoint or a custom changepoint depending on ``keep_detected``
      if their distance is less than ``min_distance``.
  
      Parameters
      ----------
      detected_changepoint_dates : `list`
          A list of detected trend changepoints, parsable by `pandas.to_datetime`.
      custom_changepoint_dates : `list`
          A list of additional custom trend changepoints, parsable by `pandas.to_datetime`.
      min_distance : `DateOffset`, `Timedelta`, `str` or None, default None
          The minimum distance between detected changepoints and custom changepoints.
          If a detected changepoint and a custom changepoint have distance less than ``min_distance``,
          either the detected changepoint or the custom changepoint will be dropped according to ``keep_detected``.
          Does not compare the distance within detected changepoints or custom changepoints.
          Note: maximal unit is 'D', i.e., you may only use units no more than 'D' such as
          '10D', '5H', '100T', '200S'. The reason is that 'W', 'M' or higher has either
          cycles or indefinite number of days, thus is not parsable by pandas as timedelta.
          For example, see `pandas.tseries.frequencies.to_offset`.
      keep_detected : `bool`, default False
          When the distance of a detected changepoint and a custom changepoint is less than ``min_distance``,
          whether to keep the detected changepoint or the custom changepoint.
  
      Returns
      -------
      combined_changepoint_dates : `list`
          A list of combined changepoints in ascending order.
      """
      check_freq_unit_at_most_day(min_distance, "min_distance")
      detected_changepoint_dates = pd.to_datetime(
          detected_changepoint_dates
      )
      custom_changepoint_dates = pd.to_datetime(
          custom_changepoint_dates
      )
      if len(detected_changepoint_dates) == 0:
          return custom_changepoint_dates
      if len(custom_changepoint_dates) == 0:
          return detected_changepoint_dates
      if keep_detected:
          combined_changepoints = [
              cp for cp in detected_changepoint_dates
          ]
          addition_changepoints = [
              cp for cp in custom_changepoint_dates
          ]
      else:
          combined_changepoints = [
              cp for cp in custom_changepoint_dates
          ]
          addition_changepoints = [
              cp for cp in detected_changepoint_dates
          ]
      for addition_cp in addition_changepoints:
          if min_distance is not None:
              current_min_distance = min(
                  [
                      abs(addition_cp - cp)
                      for cp in combined_changepoints
                  ]
              )
              if current_min_distance >= to_offset(min_distance):
                  combined_changepoints.append(addition_cp)
          else:
              combined_changepoints.append(addition_cp)
      return sorted(combined_changepoints)
  
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 19 for calling a global function with example usage: combine_detected_and_custom_trend_changepoints(detected_changepoint_dates, custom_changepoint_dates, min_distance, keep_detected) and returns: sorted, custom_changepoint_dates, detected_changepoint_dates