code: def mape(df, w):
      """Mean absolute percent error
  
      Parameters
      ----------
      df: Cross-validation results dataframe.
      w: Aggregation window size.
  
      Returns
      -------
      Dataframe with columns horizon and mape.
      """
      ape = np.abs((df["y"] - df["yhat"]) / df["y"])
      if w < 0:
          return pd.DataFrame({"horizon": df["horizon"], "mape": ape})
      return rolling_mean_by_h(
          x=ape.values, h=df["horizon"].values, w=w, name="mape"
      )
  
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 11 for calling a global function with example usage: mape(df, w) and returns: rolling_mean_by_h, pd