docstr: Builds lagged regressor df to be used in forecast models.
  
  Parameters
  ----------
  df : `pandas.Dataframe`
      Dataframe to predict on, passed to ``lagged_regressor_func``.
  lagged_regressor_cols : `list` [`str`], optional
      This is the original column names for the lagged regressors.
      This parameter is only required if lagged regressor methods are used.
      ``lagged_regressor_cols`` is needed at the "predict" phase to add to the ``df``
      with NULL values so it can be appended to ``past_df``.
  lagged_regressor_func : callable, optional
      A function constructed by
      `~greykite.common.features.timeseries_lags.build_autoreg_df_multi`
      with the following signature::
  
          def build_autoreg_df_multi(df: pd.DataFrame, past_df: pd.DataFrame) -> autoreg_df: pd.DataFrame
  
      See more details for above parameters in
      `~greykite.common.features.timeseries_lags.build_autoreg_df_multi`.
  phase : `str`, optional, default "fit"
      It denotes the phase the features are being built. It can be either of
  
          - "fit": indicates the features are being built for the fitting phase
  
          - "predict": indicates the features are being built for predict phase
  
      This argument is used minimally inside the function.
      Currently only to throw an exception when ``phase = "predict"`` and
      ``lagged_regressor_func`` is not None but ``past_df`` is None.
  past_df : `pandas.DataFrame`, optional
      If lagged regressor methods are used by providing ``lagged_regressor_func``,
      this parameter is used to append to ``df`` (from left)
      before calculating the lags
  
  Returns
  -------
  lagged_regressor_df : `pandas.DataFrame`
      a data frame with lagged regressor columns
code: def __build_lagged_regressor_features(
      self,
      df,
      lagged_regressor_cols,
      lagged_regressor_func,
      phase="fit",
      past_df=None,
  ):
      """Builds lagged regressor df to be used in forecast models.
  
      Parameters
      ----------
      df : `pandas.Dataframe`
          Dataframe to predict on, passed to ``lagged_regressor_func``.
      lagged_regressor_cols : `list` [`str`], optional
          This is the original column names for the lagged regressors.
          This parameter is only required if lagged regressor methods are used.
          ``lagged_regressor_cols`` is needed at the "predict" phase to add to the ``df``
          with NULL values so it can be appended to ``past_df``.
      lagged_regressor_func : callable, optional
          A function constructed by
          `~greykite.common.features.timeseries_lags.build_autoreg_df_multi`
          with the following signature::
  
              def build_autoreg_df_multi(df: pd.DataFrame, past_df: pd.DataFrame) -> autoreg_df: pd.DataFrame
  
          See more details for above parameters in
          `~greykite.common.features.timeseries_lags.build_autoreg_df_multi`.
      phase : `str`, optional, default "fit"
          It denotes the phase the features are being built. It can be either of
  
              - "fit": indicates the features are being built for the fitting phase
  
              - "predict": indicates the features are being built for predict phase
  
          This argument is used minimally inside the function.
          Currently only to throw an exception when ``phase = "predict"`` and
          ``lagged_regressor_func`` is not None but ``past_df`` is None.
      past_df : `pandas.DataFrame`, optional
          If lagged regressor methods are used by providing ``lagged_regressor_func``,
          this parameter is used to append to ``df`` (from left)
          before calculating the lags
  
      Returns
      -------
      lagged_regressor_df : `pandas.DataFrame`
          a data frame with lagged regressor columns
      """
      df = df.copy()
      # we raise an exception if we are in the 'predict' phase
      # and `lagged_regressor_func` is not None
      # but either of ``past_df`` or ``lagged_regressor_cols`` is not provided
      # This is because in that case `lagged_regressor_func` will not be able to provide useful
      # lag-based predictors
      if phase == "predict":
          if lagged_regressor_cols is None or past_df is None:
              raise ValueError(
                  "At 'predict' phase, if lagged_regressor_func is not None,"
                  " 'past_df' and 'lagged_regressor_cols' must be provided to "
                  "`build_lagged_regressor_features`"
              )
  
      if df is not None:
          df_col_missing = set(lagged_regressor_cols).difference(
              set(df.columns)
          )
          if len(df_col_missing) > 0:
              raise ValueError(
                  "All columns in `lagged_regressor_cols` must appear in `df`, "
                  f"but {df_col_missing} is missing in `df`."
              )
  
      if past_df is not None:
          past_df_col_missing = set(lagged_regressor_cols).difference(
              set(past_df.columns)
          )
          if len(past_df_col_missing) > 0:
              raise ValueError(
                  "All columns in `lagged_regressor_cols` must appear in `past_df`, "
                  f"but {past_df_col_missing} is missing in `past_df`."
              )
  
      lagged_regressor_df = lagged_regressor_func(
          df=df, past_df=past_df
      )
      # Preserves the original index of `df`
      lagged_regressor_df.index = df.index
      return lagged_regressor_df
  
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 15 for calling the SilverkiteForecast obj's underlying member method code with example usage: obj.__build_lagged_regressor_features(df, lagged_regressor_cols, lagged_regressor_func, phase, past_df) and returns: lagged_regressor_df