class_docstr: A class to infer appropriate Fourier series orders in different
  seasonality components.
  
  The method allows users to:
  
      - optionally remove the trend with different methods.
        Available methods are in `TrendAdjustMethodEnum`.
      - optionally do an aggregation.
      - fits the seasonality component with different Fourier series orders.
      - calculates the AIC/BIC of the fits.
      - choose the most appropriate order with AIC or BIC and an optional tolerance.
      - plot the investigations.
  
  Attributes
  ----------
  df : `pandas.DataFrame` or None
      The input timeseries.
  time_col : `str` or None
      The column name for timestamps in ``df``.
  value_col : `str` or None
      The column name for values in ``df``.
  fourier_series_orders : `dict` or None
      The inferred Fourier series orders.
      The keys are the seasonality component names.
      The values are the inferred best orders according to the config.
  df_features : `pandas.DataFrame` or None
      The cached dataframe with time features.
      Building this df is slow for large dataset.
      We cache it the first time we build it for subsequent uses.
docstr: For the corresponding parameter in each config in ``configs``,
  replaces `None` with default values;
  overrides all values if ``override_value`` is not `None`;
  checks the final values are in ``allowed_values`` if the latter is not `None`.
  
  Parameters
  ----------
  configs : `list` [`SeasonalityInferConfig`]
      A list of `~greykite.algo.common.seasonality_inferrer.SeasonalityInferConfig`
      objects. Each element corresponds to the config for a seasonality component.
      For example, if you would like to infer seasonality orders for yearly seasonality and
      weekly seasonality, you need to provide a list of two configs.
  param_name : `str`
      The name of the parameter.
      Will be used in error message.
  default_value : `any`
      The default value to replace None.
  allowed_values : `any`, `list` [`any`] or None, default None
      The list of valid values.
      If any given value is not valid, an error will be raised.
      Leave as None to skip checking.
  
  Returns
  -------
  configs : `list` [`SeasonalityInferConfig`]
      A list of `~greykite.algo.common.seasonality_inferrer.SeasonalityInferConfig`
      objects. The values are checked and overridden if needed.
docstr_tok: ["For","the","corresponding","parameter","in","each","config","in","``","configs","``",",","replaces","`","None","`","with","default","values",";","overrides","all","values","if","``","override_value","``","is","not","`","None","`",";","checks","the","final","values","are","in","``","allowed_values","``","if","the","latter","is","not","`","None","`",".","Parameters","--","--","--","--","--","configs",":","`","list","`","[","`","SeasonalityInferConfig","`","]","A","list","of","`","~greykite.algo.common.seasonality_inferrer.SeasonalityInferConfig","`","objects",".","Each","element","corresponds","to","the","config","for","a","seasonality","component",".","For","example",",","if","you","would","like","to","infer","seasonality","orders","for","yearly","seasonality","and","weekly","seasonality",",","you","need","to","provide","a","list","of","two","configs",".","param_name",":","`","str","`","The","name","of","the","parameter",".","Will","be","used","in","error","message",".","default_value",":","`","any","`","The","default","value","to","replace","None",".","allowed_values",":","`","any","`",",","`","list","`","[","`","any","`","]","or","None",",","default","None","The","list","of","valid","values",".","If","any","given","value","is","not","valid",",","an","error","will","be","raised",".","Leave","as","None","to","skip","checking",".","Returns","--","--","--","-","configs",":","`","list","`","[","`","SeasonalityInferConfig","`","]","A","list","of","`","~greykite.algo.common.seasonality_inferrer.SeasonalityInferConfig","`","objects",".","The","values","are","checked","and","overridden","if","needed","."]
code: def _apply_default_value(
      configs: List[SeasonalityInferConfig],
      param_name: str,
      override_value: any,
      default_value: any,
      allowed_values: Optional[List[any]] = None,
  ) -> List[SeasonalityInferConfig]:
      """For the corresponding parameter in each config in ``configs``,
      replaces `None` with default values;
      overrides all values if ``override_value`` is not `None`;
      checks the final values are in ``allowed_values`` if the latter is not `None`.
  
      Parameters
      ----------
      configs : `list` [`SeasonalityInferConfig`]
          A list of `~greykite.algo.common.seasonality_inferrer.SeasonalityInferConfig`
          objects. Each element corresponds to the config for a seasonality component.
          For example, if you would like to infer seasonality orders for yearly seasonality and
          weekly seasonality, you need to provide a list of two configs.
      param_name : `str`
          The name of the parameter.
          Will be used in error message.
      default_value : `any`
          The default value to replace None.
      allowed_values : `any`, `list` [`any`] or None, default None
          The list of valid values.
          If any given value is not valid, an error will be raised.
          Leave as None to skip checking.
  
      Returns
      -------
      configs : `list` [`SeasonalityInferConfig`]
          A list of `~greykite.algo.common.seasonality_inferrer.SeasonalityInferConfig`
          objects. The values are checked and overridden if needed.
      """
      # Checks if ``override_value`` is given but not valid.
      if (
          override_value is not None
          and allowed_values is not None
          and override_value not in allowed_values
      ):
          raise ValueError(
              f"The parameter '{param_name}' has value {override_value}, "
              f"which is not valid. Valid values are '{allowed_values}'."
          )
  
      # If the ``override_value`` is provided and valid,
      # overrides the parameter in all configs.
      if override_value is not None:
          for config in configs:
              setattr(config, param_name, override_value)
          return configs
  
      # If ``override_value`` is None,
      # checks the validity of each config's parameter and
      # fills None with default value.
      for config in configs:
          param = getattr(config, param_name)
          if param is None:
              setattr(config, param_name, default_value)
          elif (
              allowed_values is not None and param not in allowed_values
          ):
              raise ValueError(
                  f"The parameter '{param_name}' in SeasonalityInferConfig has value {param}, "
                  f"which is not valid. Valid values are '{allowed_values}'."
              )
      return configs
  
imports: from dataclasses import dataclass
  from enum import Enum
  from typing import List
  from typing import Optional
  import numpy
  import pandas
  from plotly import graph_objs
  from plotly.colors import DEFAULT_PLOTLY_COLORS
  from plotly.subplots import make_subplots
  from sklearn.linear_model import LinearRegression
  from sklearn.linear_model import RidgeCV
  from sklearn.linear_model import SGDRegressor
  from greykite.common.constants import TIME_COL
  from greykite.common.constants import VALUE_COL
  from greykite.common.constants import TimeFeaturesEnum
  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_default_origin_for_time_vars
label_desc: Use image node_id 4 for calling the SeasonalityInferrer obj's underlying member method code with example usage: obj._apply_default_value(configs, param_name, override_value, default_value, allowed_values) and returns: configs, configs