docstr: Removes fourier series terms with perfect or almost perfect collinearity.
  This function is intended to be used when fitting algorithm is OLS.
  
  These terms include, for example, yearly seasonality with order 4 and quarterly
  seasonality with order 1; yearly seasonality with order 12, quarterly seasonality
  with order 3 and monthly seasonality with order 1; etc.
  Including these terms together is possible to lead to NaN coefficients in OLS models.
  
  Note: the function assumes the user includes ``seas_names`` in ``fs_components_df``
  and labels them: weekly, monthly, quarterly and yearly.
  
  Parameters
  ----------
  fs_cols : `list` [`str`]
      A list of Fourier series column names generated by
      `~greykite.common.features.timeseries_features.fourier_series_multi_fcn`
  
  Returns
  -------
  fs_cols : `list` [`str`]
      The ``fs_cols`` with collinear cols removed.
      The removed columns always have shorter periods.
code: def __remove_fourier_col_with_collinearity(self, fs_cols):
      """Removes fourier series terms with perfect or almost perfect collinearity.
      This function is intended to be used when fitting algorithm is OLS.
  
      These terms include, for example, yearly seasonality with order 4 and quarterly
      seasonality with order 1; yearly seasonality with order 12, quarterly seasonality
      with order 3 and monthly seasonality with order 1; etc.
      Including these terms together is possible to lead to NaN coefficients in OLS models.
  
      Note: the function assumes the user includes ``seas_names`` in ``fs_components_df``
      and labels them: weekly, monthly, quarterly and yearly.
  
      Parameters
      ----------
      fs_cols : `list` [`str`]
          A list of Fourier series column names generated by
          `~greykite.common.features.timeseries_features.fourier_series_multi_fcn`
  
      Returns
      -------
      fs_cols : `list` [`str`]
          The ``fs_cols`` with collinear cols removed.
          The removed columns always have shorter periods.
      """
      yearly_cols = [col for col in fs_cols if "yearly" in col]
      quarterly_cols = [col for col in fs_cols if "quarterly" in col]
      monthly_cols = [col for col in fs_cols if "monthly" in col]
      weekly_cols = [col for col in fs_cols if "weekly" in col]
  
      # Assuming the provided seasonality orders are in reasonable ranges.
      # We need to deal with year/quarter, year/month, quarter/month for cos/sin
      # We need to deal with weekly for cos.
      # The Fourier series column names are generated by ``get_fourier_col_name``,
      # and the maximum order of a component can be parsed from the names.
      # For example, yearly seasonality has the form "sin12_ct1_yearly" or "cos12_ct1_yearly".
      # Parsing the number after sin/cos and before the first "_" gives the order.
      max_yearly_order = max(
          [int(col.split("_")[0][3:]) for col in yearly_cols], default=0
      )
      max_quarterly_order = max(
          [int(col.split("_")[0][3:]) for col in quarterly_cols],
          default=0,
      )
  
      # Adds columns to be removed for year/quarter, year/month, quarter/month
      # These always include components with shorter periods.
      # For example, if we have both yearly seasonality with order 4 and quarterly seasonality with order 1,
      # quarterly seasonality with order 1 will be removed.
      removed_cols = []
  
      # Removes redundant quarterly seasonality with yearly seasonality.
      for i in range(4, max_yearly_order + 1, 4):
          removed_cols += [
              col
              for col in quarterly_cols
              if f"sin{i // 4}_" in col or f"cos{i // 4}_" in col
          ]
      # Removes redundant monthly seasonality with yearly seasonality.
      for i in range(12, max_yearly_order + 1, 12):
          removed_cols += [
              col
              for col in monthly_cols
              if f"sin{i // 12}_" in col or f"cos{i // 12}_" in col
          ]
      # Removes redundant monthly seasonality with quarterly seasonality.
      for i in range(3, max_quarterly_order + 1, 3):
          removed_cols += [
              col
              for col in monthly_cols
              if f"sin{i // 3}_" in col or f"cos{i // 3}_" in col
          ]
  
      # Adds columns for weekly seasonality.
      # Removes higher order cosine terms because order k and order period - k have the same cosine columns.
      for i in range(
          int(
              self._silverkite_seasonality_enum.WEEKLY_SEASONALITY.value.period
          )
          // 2
          + 1,
          int(
              self._silverkite_seasonality_enum.WEEKLY_SEASONALITY.value.period
          )
          + 1,
      ):
          removed_cols += [
              col for col in weekly_cols if f"cos{i}_" in col
          ]
  
      # Removes both sine and cosine terms if the order is greater than the period.
      # The reason is that for weekly order 1 is the same as order 8.
      # This concern only applies to weekly seasonality, because the period 7 is small.
      removed_cols += [
          col
          for col in weekly_cols
          if (
              int(col.split("_")[0][3:])
              > self._silverkite_seasonality_enum.WEEKLY_SEASONALITY.value.period
          )
      ]
  
      final_cols = [col for col in fs_cols if col not in removed_cols]
      if len(removed_cols) > 0:
          warnings.warn(
              f"The following Fourier series terms are removed due to collinearity:\n{removed_cols}"
          )
      return final_cols
  
imports: import re
  import warnings
  from typing import Type
  import numpy
  import pandas
  from pandas.plotting import register_matplotlib_converters
  from pandas.tseries.frequencies import to_offset
  from greykite.algo.changepoint.adalasso.changepoint_detector import get_changepoints_dict
  from greykite.algo.changepoint.adalasso.changepoint_detector import get_seasonality_changepoints
  from greykite.algo.changepoint.adalasso.changepoints_utils import build_seasonality_feature_df_from_detection_result
  from greykite.algo.changepoint.adalasso.changepoints_utils import get_seasonality_changepoint_df_cols
  from greykite.algo.common.ml_models import fit_ml_model_with_evaluation
  from greykite.algo.common.ml_models import predict_ml
  from greykite.algo.common.ml_models import predict_ml_with_uncertainty
  from greykite.algo.forecast.silverkite.constants.silverkite_constant import default_silverkite_constant
  from greykite.algo.forecast.silverkite.constants.silverkite_seasonality import SilverkiteSeasonalityEnum
  from greykite.algo.forecast.silverkite.constants.silverkite_seasonality import SilverkiteSeasonalityEnumMixin
  from greykite.algo.forecast.silverkite.forecast_silverkite_helper import get_fourier_feature_col_names
  from greykite.algo.forecast.silverkite.forecast_silverkite_helper import get_similar_lag
  from greykite.common.constants import CHANGEPOINT_COL_PREFIX
  from greykite.common.constants import ERR_STD_COL
  from greykite.common.constants import QUANTILE_SUMMARY_COL
  from greykite.common.constants import SEASONALITY_REGEX
  from greykite.common.constants import TimeFeaturesEnum
  from greykite.common.enums import TimeEnum
  from greykite.common.features.timeseries_features import add_daily_events
  from greykite.common.features.timeseries_features import add_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.features.timeseries_lags import build_autoreg_df
  from greykite.common.features.timeseries_lags import build_autoreg_df_multi
  from greykite.common.logging import LoggingLevelEnum
  from greykite.common.logging import log_message
  from greykite.common.python_utils import get_pattern_cols
  from greykite.common.python_utils import unique_elements_in_list
  from greykite.common.time_properties import describe_timeseries
  from greykite.common.time_properties import fill_missing_dates
  from greykite.common.time_properties import min_gap_in_seconds
  from greykite.common.time_properties_forecast import get_default_horizon_from_period
label_desc: Use image node_id 19 for calling the SilverkiteForecast obj's underlying member method code with example usage: obj.__remove_fourier_col_with_collinearity(fs_cols) and returns: final_cols