class_docstr: Evaluator class, to compute accuracy metrics by comparing observations to
  forecasts.
  
  Parameters
  ----------
  quantiles
      list of strings of the form 'p10' or floats in [0, 1] with
      the quantile levels
  seasonality
      seasonality to use for seasonal_error, if nothing is passed
      uses the default seasonality
      for the given series frequency as returned by `get_seasonality`
  alpha
      Parameter of the MSIS metric from the M4 competition that
      defines the prediction interval.
      For alpha=0.05 (default) the 95% considered is considered in the
      metric, see
      https://www.m4.unic.ac.cy/wp-content/uploads/2018/03/M4-Competitors-Guide.pdf
      for more detail on MSIS
  calculate_owa
      Determines whether the OWA metric should also be calculated,
      which is computationally expensive to evaluate and thus slows
      down the evaluation process considerably.
      By default False.
  custom_eval_fn
      Option to include custom evaluation metrics. Expected input is
      a dictionary with keys specifying the name of the custom metric
      and the values are a list containing three elements.
      First, a callable which takes as input target and forecast and
      returns the evaluation metric.
      Second, a string specifying the aggregation metric across all
      time series, f.e. "mean", "sum".
      Third, either "mean" or "median" to specify whether mean or median
      forecast should be passed to the custom evaluation function.
      E.g. {"RMSE": [rmse, "mean", "median"]}
  num_workers
      The number of multiprocessing workers that will be used to process
      the data in parallel. Default is multiprocessing.cpu_count().
      Setting it to 0 or None means no multiprocessing.
  chunk_size
      Controls the approximate chunk size each workers handles at a time.
      Default is 32.
  ignore_invalid_values
      Ignore `NaN` and `inf` values in the timeseries when calculating
      metrics.
  aggregation_strategy
      Function for aggregating per timeseries metrics.
      Available options are:
      aggregate_valid | aggregate_all | aggregate_no_nan
      The default function is aggregate_no_nan.
  allow_nan_forecast
      Whether to allow `NaN` values in forecasts.
      If False, raises an error when forecast contains `NaN` values.
      Defaults to False.
docstr: Parameters
  ----------
  time_series
  forecast
  
  Returns
  -------
  np.ndarray
      time series without the forecast dates
docstr_tok: ["Parameters","--","--","--","--","--","time_series","forecast","Returns","--","--","--","-","np.ndarray","time","series","without","the","forecast","dates"]
code: def extract_past_data(
      time_series: Union[pd.Series, pd.DataFrame], forecast: Forecast
  ) -> np.ndarray:
      """
  
      Parameters
      ----------
      time_series
      forecast
  
      Returns
      -------
      np.ndarray
          time series without the forecast dates
      """
  
      assert forecast.index.intersection(time_series.index).equals(
          forecast.index
      ), (
          "Index of forecast is outside the index of target\nIndex of"
          f" forecast: {forecast.index}\n Index of target:"
          f" {time_series.index}"
      )
  
      # Remove the prediction range
      # If the prediction range is not in the end of the time series,
      # everything after the prediction range is truncated
      date_before_forecast = forecast.index[0] - forecast.freq
      return np.atleast_1d(
          np.squeeze(time_series.loc[:date_before_forecast].transpose())
      )
  
imports: import logging
  import multiprocessing
  import sys
  from functools import partial
  from itertools import chain, tee
  from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Tuple, Union, Mapping, cast
  import numpy
  import pandas
  from gluonts.gluonts_tqdm import tqdm
  from gluonts.model.forecast import Forecast, Quantile
  from gluonts.time_feature import get_seasonality
  from .metrics import abs_error, abs_target_mean, abs_target_sum, calculate_seasonal_error, coverage, mape, mase, mse, msis, quantile_loss, smape, num_masked_values
label_desc: Use image node_id 4 for calling the Evaluator obj's underlying member method code with example usage: obj.extract_past_data(time_series, forecast) and returns: np