class_docstr: The model template for Multistage Forecast Estimator.
class_docstr_tok: ["The","model","template","for","Multistage","Forecast","Estimator","."]
docstr: Gets the hyperparameter grid for the Multistage Forecast Model.
  
  Returns
  -------
  hyperparameter_grid : `dict` [`str`, `list` [`any`]] or `list` [ `dict` [`str`, `list` [`any`]] ]
      hyperparameter_grid for grid search in
      :func:`~greykite.framework.pipeline.pipeline.forecast_pipeline`.
      The output dictionary values are lists, combined in grid search.
docstr_tok: ["Gets","the","hyperparameter","grid","for","the","Multistage","Forecast","Model",".","Returns","--","--","--","-","hyperparameter_grid",":","`","dict","`","[","`","str","`",",","`","list","`","[","`","any","`","]","]","or","`","list","`","[","`","dict","`","[","`","str","`",",","`","list","`","[","`","any","`","]","]","]","hyperparameter_grid","for","grid","search","in",":","func",":","`","~greykite.framework.pipeline.pipeline.forecast_pipeline","`",".","The","output","dictionary","values","are","lists",",","combined","in","grid","search","."]
code: def get_hyperparameter_grid(self):
      """Gets the hyperparameter grid for the Multistage Forecast Model.
  
      Returns
      -------
      hyperparameter_grid : `dict` [`str`, `list` [`any`]] or `list` [ `dict` [`str`, `list` [`any`]] ]
          hyperparameter_grid for grid search in
          :func:`~greykite.framework.pipeline.pipeline.forecast_pipeline`.
          The output dictionary values are lists, combined in grid search.
      """
      if self.config is None:
          raise ValueError(
              f"Forecast config must be provided, but `self.config` is `None`."
          )
      model_template = self.config.model_template
      model_components = self.config.model_components_param
  
      # Gets the model components from model template.
      default_model_components = self.__get_default_model_components(
          model_template
      )
      default_multistage_forecast_configs = (
          default_model_components.custom.get(
              "multistage_forecast_configs"
          )
      )
  
      # Checks if any parameter is specified in fields other than "custom".
      not_none_parameters = []
      for key, value in model_components.__dict__.items():
          if (
              value is not None
              and value != {}
              and key not in ["custom", "uncertainty"]
          ):
              not_none_parameters.append(key)
      if not_none_parameters:
          log_message(
              message=f"Multistage Forecast template only takes configuration through ``custom`` "
              f"and ``uncertainty`` in ``model_components_param``. "
              f"The following inputs are ignored \n{not_none_parameters}.",
              level=LoggingLevelEnum.WARNING,
          )
  
      # When ``custom`` is not None, we look for the ``multistage_forecast_configs`` key.
      custom = model_components.custom
      # Gets the ``multistage_forecast_configs`` from ``default_multistage_forecast_configs`` and
      # overriden by ``custom["multistage_forecast_configs"]``.
      # If no customized configs, the default configs will be ``new_configs``.
      new_configs = self.__get_multistage_forecast_configs_override(
          custom=custom,
          model_template=model_template,
          default_multistage_forecast_configs=default_multistage_forecast_configs,
      )
  
      # Converts template configs into estimator parameters.
      (
          estimator_list,
          estimator_params_list,
      ) = self.__get_estimators_and_params_from_template_configs(
          new_configs=new_configs
      )
  
      # Now the estimator parameters may contain grids, i.e., list of parameters from template classes.
      # We need to flatten them and wrap them into list of parameters for `MultistageForecastEstimator`.
      # The following function call gets the flattened estimator parameters,
      # in the format of a list of lists (different sets of parameters) of dictionaries (different stage models).
      flattened_dictionaries = self.__flatten_estimator_params_list(
          estimator_params_list=estimator_params_list
      )
  
      # Then we construct the `MultistageForecastEstimator` parameters.
      multistage_model_configs = []
      for grid in flattened_dictionaries:
          list_of_model_configs = []
          for i, config in enumerate(new_configs):
              # This is a single ``MultistageForecastModelConfig`` that corresponds to
              # a single stage model in a set of configuration.
              model_config = MultistageForecastModelConfig(
                  train_length=config.train_length,
                  fit_length=config.fit_length,
                  agg_func=config.agg_func,
                  agg_freq=config.agg_freq,
                  estimator=estimator_list[i],
                  estimator_params=grid[i],
              )
              # Appends this single ``MultistageForecastModelConfig`` to get all stage of models.
              list_of_model_configs.append(model_config)
          # The hyperparameter grid consists of a list of all stage of models for grid search.
          # This corresponds to different sets of configurations.
          multistage_model_configs.append(list_of_model_configs)
      # ``freq`` is the data frequency, which is from ``metadata_param``.
      freq = (
          self.config.metadata_param.freq
          if self.config.metadata_param is not None
          else None
      )
  
      # Gets the uncertainty parameter.
      uncertainty = model_components.uncertainty
      if uncertainty is not None:
          uncertainty_dict = uncertainty.get("uncertainty_dict", None)
      else:
          uncertainty_dict = None
  
      # Gets the hyperparameter grid.
      multistage_forecast_hyperparameter_grid = dict(
          estimator__forecast_horizon=[self.config.forecast_horizon],
          estimator__freq=[freq],
          estimator__model_configs=multistage_model_configs,
          estimator__uncertainty_dict=[uncertainty_dict],
      )
      return multistage_forecast_hyperparameter_grid
  
imports: from itertools import product
  from typing import Dict
  from typing import List
  from typing import Type
  import pandas
  from greykite.common import constants
  from greykite.common.logging import LoggingLevelEnum
  from greykite.common.logging import log_message
  from greykite.common.python_utils import unique_in_list
  from greykite.common.python_utils import update_dictionaries
  from greykite.framework.templates.autogen.forecast_config import ForecastConfig
  from greykite.framework.templates.autogen.forecast_config import MetadataParam
  from greykite.framework.templates.base_template import BaseTemplate
  from greykite.framework.templates.multistage_forecast_template_config import MultistageForecastTemplateConfig
  from greykite.framework.templates.multistage_forecast_template_config import MultistageForecastTemplateConstants
  from greykite.sklearn.estimator.base_forecast_estimator import BaseForecastEstimator
  from greykite.sklearn.estimator.multistage_forecast_estimator import MultistageForecastEstimator
  from greykite.sklearn.estimator.multistage_forecast_estimator import MultistageForecastModelConfig
label_desc: Use image node_id 6 for calling the MultistageForecastTemplate obj's underlying member method code with example usage: obj.get_hyperparameter_grid() and returns: multistage_forecast_hyperparameter_grid