code: def generate_trend_changepoint_detection_params(
      df: pd.DataFrame,
      forecast_horizon: int,
      time_col: str = TIME_COL,
      value_col: str = VALUE_COL,
      yearly_seasonality_order: Optional[int] = None,
  ) -> Optional[dict]:
      """Automatically generates trend changepoint detection parameters
      based on the input data and forecast horizon.
  
      Parameters
      ----------
      df : `pandas.DataFrame`
          The input time series.
      forecast_horizon : `int`
          The forecast horizon.
      time_col : `str`, default TIME_COL
          The column name for timestamps in ``df``.
      value_col : `str`, default VALUE_COL`
          The column name for time series values in ``df``.
      yearly_seasonality_order : `int` or None, default None
          The yearly seasonality Fourier order.
          If a known good order is given, it will be used.
          Otherwise, it will be inferred from the algorithm.
  
      Returns
      -------
      params : `dict` [`str`, any]
          The generated trend changepoint detection parameters.
      """
      df = df.copy()
      df[time_col] = pd.to_datetime(df[time_col])
      total_increment = df[time_col].max() - df[time_col].min()
  
      # Auto changepoints is not active if training data is too short.
      # In such cases, autoregression should be used.
      if total_increment < timedelta(days=90):
          return None
  
      n_points = len(df)
      min_increment = min(
          (df[time_col] - df[time_col].shift(1)).dropna()
      )
  
      # Infers ``resample_freq``.
      resample_freq = get_changepoint_resample_freq(
          n_points=n_points, min_increment=min_increment
      )
  
      # Infers ``yearly_seasonality_order``.
      if yearly_seasonality_order is None:
          yearly_seasonality_order = get_yearly_seasonality_order(
              df=df,
              time_col=time_col,
              value_col=value_col,
              resample_freq=resample_freq,
          )
      elif yearly_seasonality_order < 0:
          raise ValueError(
              f"Yearly seasonality order must be a non-negative integer, "
              f"found {yearly_seasonality_order}."
          )
  
      # Infers ``potential_changepoint_n``.
      potential_changepoint_n = get_potential_changepoint_n(
          n_points=n_points,
          total_increment=total_increment,
          resample_freq=resample_freq,
          yearly_seasonality_order=yearly_seasonality_order,
          cap=100,
      )
  
      # Infers ``no_changepoint_distance_from_end``.
      no_changepoint_distance_from_end = (
          get_no_changepoint_distance_from_end(
              min_increment=min_increment,
              forecast_horizon=forecast_horizon,
              min_num_points_after_last_changepoint=4,
          )
      )
  
      # Infers ``actual_changepoint_min_distance``.
      actual_changepoint_min_distance = (
          get_actual_changepoint_min_distance(
              min_increment=min_increment
          )
      )
  
      # Infers ``regularization_strength``.
      regularization_strength = get_regularization_strength()
  
      return dict(
          yearly_seasonality_order=yearly_seasonality_order,
          resample_freq=resample_freq,
          regularization_strength=regularization_strength,
          actual_changepoint_min_distance=actual_changepoint_min_distance,
          potential_changepoint_n=potential_changepoint_n,
          no_changepoint_distance_from_end=no_changepoint_distance_from_end,
      )
  
file_path: greykite/greykite/algo/changepoint/adalasso/auto_changepoint_params.py
imports: from datetime import timedelta
  from typing import Optional
  import numpy
  import pandas
  from pandas.tseries.frequencies import to_offset
  from greykite.algo.common.seasonality_inferrer import SeasonalityInferConfig
  from greykite.algo.common.seasonality_inferrer import SeasonalityInferrer
  from greykite.algo.common.seasonality_inferrer import TrendAdjustMethodEnum
  from greykite.common.constants import TIME_COL
  from greykite.common.constants import VALUE_COL
label_desc: Use image node_id 7 for calling a global function with example usage: generate_trend_changepoint_detection_params(df, forecast_horizon, time_col, value_col, yearly_seasonality_order) and returns: dict, None