code: def smape(df, w):
      """Symmetric mean absolute percentage error
      based on Chen and Yang (2004) formula
  
      Parameters
      ----------
      df: Cross-validation results dataframe.
      w: Aggregation window size.
  
      Returns
      -------
      Dataframe with columns horizon and smape.
      """
      sape = np.abs(df["y"] - df["yhat"]) / (
          (np.abs(df["y"]) + np.abs(df["yhat"])) / 2
      )
      if w < 0:
          return pd.DataFrame({"horizon": df["horizon"], "smape": sape})
      return rolling_mean_by_h(
          x=sape.values, h=df["horizon"].values, w=w, name="smape"
      )
  
imports: from __future__ import absolute_import, division, print_function
  import logging
  from tqdm.auto import tqdm
  from copy import deepcopy
  import concurrent.futures
  import numpy
  import pandas
label_desc: Use image node_id 13 for calling a global function with example usage: smape(df, w) and returns: rolling_mean_by_h, pd