code: def build_autoreg_df_multi(
      value_lag_info_dict,
      series_na_fill_func=lambda s: s.bfill().ffill(),
  ):
      """A function which returns a function to build autoregression
      dataframe for multiple value columns.
      This function should not be applied to data before CV split is done.
  
  
      Parameters
      ----------
      value_lag_info_dict : `dict` [`str`, `dict`]
          A dictionary with keys being the target value columns: `value_col`
          For each of these value columns, a dictionary with following keys
  
              `lag_dict`,
              `agg_lag_dict`,
              `series_na_fill_func`
  
          The `value_col` and the above three variables are then passed to the
          following function:
  
              build_autoreg_df(
                  value_col,
                  lag_dict,
                  agg_lag_dict,
                  series_na_fill_func)
  
          Check the
          `greykite.common.features.timeseries_lags.build_autoreg_df`
          docstring for more details for each argument.
      series_na_fill_func : callable, (pd.Series -> pd.Series)
          default: `lambda s: s.bfill.ffill()`
          This function is used to fill in the missing data
          The default works by first back-filling and then forward-filling
  
      Returns
      -------
      A dictionary with following items
  
          "autoreg_func" : callable, (pd.DataFrame -> pd.DataFrame)
              A function which can be applied to a dataframe and return a dataframe
              which has the lagged values for all the relevant columns
          "autoreg_col_names" : List[str]
              A list of all the generated columns
          "autoreg_orig_col_names" : List[str]
              A list of all the original target value columns
          "max_order" : int
              Maximum lag order for all target value columns
          "min_order" : int
              Minimum lag order for all target value columns
  
      """
  
      multi_autoreg_info = {}
      autoreg_col_names = []
      autoreg_orig_col_names = list(value_lag_info_dict.keys())
      min_order = np.inf
      max_order = 0
  
      for value_col, lag_info in value_lag_info_dict.items():
          # we assign the interpolation function to be the default specified above
          # in this function
          # if a custom interpolation function is made available for that
          # `value_col`, we replace the default
          series_na_fill_func0 = lag_info.get(
              "series_na_fill_func", series_na_fill_func
          )
  
          autoreg_info = build_autoreg_df(
              value_col,
              lag_dict=lag_info.get("lag_dict"),
              agg_lag_dict=lag_info.get("agg_lag_dict"),
              series_na_fill_func=series_na_fill_func0,
          )
  
          # store the result (`autoreg_info`) for each `value_col` in a dictionary
          # the result for each `value_col` will be
          # a dictionary with following keys:
          # "build_lags_func"
          # "lag_col_names"
          # "agg_lag_col_names"
          # "min_order"
          # "max_order"
          multi_autoreg_info[value_col] = autoreg_info
  
          # extract column names for lagged variables and add to the full list of
          # all lagged variable column names: `autoreg_col_names`
          lag_col_names = autoreg_info["lag_col_names"]
          agg_lag_col_names = autoreg_info["agg_lag_col_names"]
          if lag_col_names is not None:
              autoreg_col_names += lag_col_names
          if agg_lag_col_names is not None:
              autoreg_col_names += agg_lag_col_names
  
          # extract the min_order and max_order for each col and update the overall lagged_regressor_order
          min_order = np.nanmin([min_order, autoreg_info["min_order"]])
          max_order = np.nanmax([max_order, autoreg_info["max_order"]])
  
      def build_lags_func_multi(df, past_df=None):
          """A function which generates a lagged dataframe
          for a given dataframe with potentially multiple value columns
          to be lagged. Note `df` and `past_df` must have the same extract
          columns. However time column is not needed as the function assumes
          `past_df` is the data which precedes `df` (without gaps).
  
          Parameters
          ----------
          df : `pd.DataFrame`
              The dataframe which includes the value columns for which lagged
              data is needed
          past_df : `pandas.DataFrame` or None, default None
              The past data which is immediately before `df` with same
              value columns.
  
  
          Returns :
          -------
          autoreg_df : `pandas.DataFrame`
              A DataFrame which includes the lagged values as columns
          """
  
          autoreg_df = None
          lag_dfs = []
          for value_col, lag_info in multi_autoreg_info.items():
              build_lags_func = lag_info["build_lags_func"]
              res = build_lags_func(df=df[[value_col]], past_df=past_df)
              lag_df = res["lag_df"]
              agg_lag_df = res["agg_lag_df"]
              lag_dfs.append(lag_df)
              lag_dfs.append(agg_lag_df)
  
          try:
              # Concatenates the columns to the result
              # dataframe in column-wise fashion
              autoreg_df = pd.concat(lag_dfs, axis=1)
          except ValueError:  # All objects passed are None
              autoreg_df = None
  
          return autoreg_df
  
      return {
          "autoreg_func": build_lags_func_multi,
          "autoreg_col_names": autoreg_col_names,
          "autoreg_orig_col_names": autoreg_orig_col_names,
          "min_order": min_order,
          "max_order": max_order,
      }
  
imports: import numpy
  import pandas
  from greykite.common import constants
label_desc: Use image node_id 5 for calling a global function with example usage: build_autoreg_df_multi(value_lag_info_dict, series_na_fill_func) and returns: dict, autoreg_df