code: def build_lag_df(value_col, df=None, max_order=None, orders=None):
      """A function which builds a dataframe including time series lags
      (in the form of data frame columns)
      for a given value column (value_col) from an input dataframe (df)
  
      :param value_col: str
          the column name for the column which includes the values
      :param df: Optional[pd.DataFrame]
          data frame which include the value column of interest
          df could be passed as None if col_names are desired only
          in the output dictionary
      :param max_order: Optional[int]
          if lag orders are not specified then max_order is used.
          max_order is a natural number specifying
          the orders needed. e.g. if "max_order = 5"
          then we add these lag orders 1, 2, 3, 4, 5
      :param orders: List[int]
          a list of the lag orders needed.
          e.g. if orders = [1, 2, 7] for a given time series
          denoted in mathematical notation by Y(t), we calculate
          Y(t-1), Y(t-2), Y(t-7) and store them in the returned data frame
      :return: dict
          dictionary with these items:
  
              - "col_names": List[str]
                  the generated column names
              - "lag_df": Optional[pd.DataFrame]
                  a data frame consisting of the lagged values of the given orders.
                  For example, if the value_col = "y" and the orders = [1, 2, 7],
                  then the returned data frame
                  include the following columns: "y_lag_1", "y_lag_2" and "y_lag_7".
                  These correspond to the 1st lag, the 2nd lag and the 7th lag
                  respectively.
      """
      # initializes the returned items
      lag_df = None
      col_names = []
  
      if max_order is None and orders is None:
          raise ValueError(
              "at least one of 'max_order' or 'orders' must be provided"
          )
  
      if orders is None:
          orders = range(1, max_order + 1)
  
      if df is not None:
          lag_df_list = []
  
      for i in orders:
          col_name = f"{value_col}{cst.LAG_INFIX}{i}"
          col_names.append(col_name)
          if df is not None:
              lag_df_list.append(
                  df[value_col].shift(i).rename(col_name)
              )
  
      if df is not None:
          lag_df = pd.concat(
              objs=lag_df_list, axis=1, ignore_index=False
          )
  
      return {"lag_df": lag_df, "col_names": col_names}
  
imports: import numpy
  import pandas
  from greykite.common import constants
label_desc: Use image node_id 1 for calling a global function with example usage: build_lag_df(value_col, df, max_order, orders) and returns: dict