code: def estimate_trend_with_detected_changepoints(
      df,
      time_col,
      value_col,
      changepoints,
      yearly_seasonality_order=8,
      estimator="ridge",
  ):
      """Estimates the trend effect with detected change points.
  
      Parameters
      ----------
      df : `pandas.DataFrame`
          The data df.
      time_col : `str`
          The column name of the time column in ``df``.
      value_col : `str`
          The column name of the value column in ``df``.
      changepoints : `list`
          A list of detected trend change points.
      yearly_seasonality_order : `int`
          The yearly seasonality order.
      estimator : `str`, default "ridge"
          "ols" or "ridge", the estimation model for trend estimation.
  
      Returns
      -------
      trend_estimate : `pandas.Series`
          The estimated trend.
      """
      trend_df = build_trend_feature_df_with_changes(
          df=df,
          time_col=time_col,
          changepoints_dict={"method": "custom", "dates": changepoints},
      )
      if yearly_seasonality_order > 0:
          long_seasonality_df = (
              build_seasonality_feature_df_with_changes(
                  df=df,
                  time_col=time_col,
                  fs_components_df=pd.DataFrame(
                      {
                          "name": [TimeFeaturesEnum.conti_year.value],
                          "period": [1.0],
                          "order": [yearly_seasonality_order],
                          "seas_names": ["yearly"],
                      }
                  ),
              )
          )
          trend_df = pd.concat([trend_df, long_seasonality_df], axis=1)
      estimators = {"ridge": RidgeCV, "ols": LinearRegression}
      estimator = estimators.get(estimator)
      if estimator is None:
          raise ValueError(
              "estimator can only be either 'ridge' or 'ols'."
          )
      non_na_index = ~df[value_col].isnull().values
      model = estimator().fit(
          trend_df.values[non_na_index],
          df[value_col].values[non_na_index],
      )
      # can't simply do .predict, because need to exclude the seasonality terms.
      trend_estimate = (
          np.matmul(
              trend_df.values[:, : (len(changepoints) + 1)],
              model.coef_[: (len(changepoints) + 1)],
          )
          + model.intercept_
      )
      trend_estimate = pd.Series(trend_estimate)
      trend_estimate.index = pd.to_datetime(df[time_col])
      return trend_estimate
  
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 14 for calling a global function with example usage: estimate_trend_with_detected_changepoints(df, time_col, value_col, changepoints, yearly_seasonality_order, estimator) and returns: trend_estimate