code: def get_potential_changepoint_n(
      n_points: int,
      total_increment: timedelta,
      resample_freq: str,
      yearly_seasonality_order: int,
      cap: int = 100,
  ) -> int:
      """Gets the number of potential changepoints for changepoint detection.
  
      Parameters
      ----------
      n_points : `int`
          The number of data points in the time series.
      total_increment : `datetime.timedelta`
          The total time span of the input time series.
      resample_freq : `str`
          The resample frequency used in changepoint detection.
      yearly_seasonality_order : `int`
          The yearly seasonality order used in changepoint detection.
      cap : `int`, default 100
          The maximum number of potential changepoints.
  
      Returns
      -------
      potential_changepoint_n : `int`
          The number of potential changepoints used in changepoint detection.
      """
      try:
          # The ``resample_freq`` is one of "D", "3D" and "7D".
          n_points_after_agg = np.floor(
              total_increment / to_offset(resample_freq).delta
          )
      except AttributeError:
          # The ``resample_freq`` is None or other freq that is at least "W".
          n_points_after_agg = n_points
      # Sets number of potential changepoints to be at most
      # aggregated data length - # seasonality features - 1 (intercept term) for estimability.
      # Here we ignore dropping potential changepoints from the end.
      # If we use the function above to infer aggregation frequency,
      # there will be enough potential changepoints.
      n_changepoints = max(
          0, n_points_after_agg - 2 * yearly_seasonality_order - 1
      )
      # Caps the number of potential changepoints for speed purpose.
      n_changepoints = min(n_changepoints, cap)
      return n_changepoints
  
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 3 for calling a global function with example usage: get_potential_changepoint_n(n_points, total_increment, resample_freq, yearly_seasonality_order, cap) and returns: n_changepoints