class_docstr: A template for :class: `~greykite.sklearn.estimator.lag_based_estimator.LagBasedEstimator`.
      
class_docstr_tok: ["A","template","for",":","class",":","`","~greykite.sklearn.estimator.lag_based_estimator.LagBasedEstimator","`","."]
docstr: Fills the default values to ``model_components`` if not provided.
  
  Parameters
  ----------
  model_components : :class:`~greykite.framework.templates.autogen.forecast_config.ModelComponentsParam` or None, default None
      Configuration for `LagBasedTemplate`.
      Should only have values in the "custom" key.
  
  Returns
  -------
  model_components : :class:`~greykite.framework.templates.autogen.forecast_config.ModelComponentsParam`
      The provided ``model_components`` with default values set.
docstr_tok: ["Fills","the","default","values","to","``","model_components","``","if","not","provided",".","Parameters","--","--","--","--","--","model_components",":",":","class",":","`","~greykite.framework.templates.autogen.forecast_config.ModelComponentsParam","`","or","None",",","default","None","Configuration","for","`","LagBasedTemplate","`",".","Should","only","have","values","in","the","``","custom","''","key",".","Returns","--","--","--","-","model_components",":",":","class",":","`","~greykite.framework.templates.autogen.forecast_config.ModelComponentsParam","`","The","provided","``","model_components","``","with","default","values","set","."]
code: def apply_lag_based_model_components_defaults(
      self, model_components: Optional[ModelComponentsParam] = None
  ):
      """Fills the default values to ``model_components`` if not provided.
  
      Parameters
      ----------
      model_components : :class:`~greykite.framework.templates.autogen.forecast_config.ModelComponentsParam` or None, default None
          Configuration for `LagBasedTemplate`.
          Should only have values in the "custom" key.
  
      Returns
      -------
      model_components : :class:`~greykite.framework.templates.autogen.forecast_config.ModelComponentsParam`
          The provided ``model_components`` with default values set.
      """
      if model_components is None:
          model_components = ModelComponentsParam()
      default_params = dict(
          freq=None,
          lag_unit=LagUnitEnum.week.name,
          lags=[1],
          agg_func=AggregationFunctionEnum.mean.name,
          agg_func_params=None,
          past_df=None,
          series_na_fill_func=None,
      )
      default_uncertainty = dict(uncertainty_dict=None)
      # Checks if ``model_components.custom`` has unknown keys.
      # They will be removed and a warning will be logged.
      if model_components.custom is None:
          model_components.custom = {}
      extra_keys_in_custom = [
          key
          for key in model_components.custom.keys()
          if key not in default_params.keys()
      ]
      if extra_keys_in_custom:
          log_message(
              message="The following keys are not recognized and ignored for `LagBasedTemplate`: "
              f"{extra_keys_in_custom}",
              level=LoggingLevelEnum.WARNING,
          )
          custom = {
              key: value
              for key, value in model_components.custom.items()
              if key not in extra_keys_in_custom
          }
      else:
          custom = model_components.custom
      # Updates the defaults.
      model_components.custom = update_dictionary(
          default_params,
          overwrite_dict=custom,
          allow_unknown_keys=False,
      )
      model_components.uncertainty = update_dictionary(
          default_uncertainty,
          overwrite_dict=model_components.uncertainty,
          allow_unknown_keys=False,
      )
  
      # Gets ``freq`` from ``self.config.metadata`` if provided.
      if (
          model_components.custom["freq"] is None
          and self.config is not None
          and self.config.metadata_param is not None
          and self.config.metadata_param.freq is not None
      ):
          model_components.custom[
              "freq"
          ] = self.config.metadata_param.freq
  
      return model_components
  
imports: import functools
  from typing import Dict
  from typing import Optional
  import pandas
  from greykite.common.aggregation_function_enum import AggregationFunctionEnum
  from greykite.common.logging import LoggingLevelEnum
  from greykite.common.logging import log_message
  from greykite.common.python_utils import dictionaries_values_to_lists
  from greykite.common.python_utils import update_dictionaries
  from greykite.common.python_utils import update_dictionary
  from greykite.framework.templates.autogen.forecast_config import ForecastConfig
  from greykite.framework.templates.autogen.forecast_config import ModelComponentsParam
  from greykite.framework.templates.base_template import BaseTemplate
  from greykite.sklearn.estimator.base_forecast_estimator import BaseForecastEstimator
  from greykite.sklearn.estimator.lag_based_estimator import LagBasedEstimator
  from greykite.sklearn.estimator.lag_based_estimator import LagUnitEnum
label_desc: Use image node_id 5 for calling the LagBasedTemplate obj's underlying member method code with example usage: obj.apply_lag_based_model_components_defaults(model_components) and returns: model_components