class_docstr: Adds aggregate lags as a feature to the data_entry.
  
  Aggregates the original time series to a new frequency and selects
  the aggregated lags of interest. It does not use aggregate lags that
  need the last `prediction_length` values to be computed. Therefore
  the transformation is applicable to both training and inference.
  
  If `is_train=True` the lags have the same length as the `target` field.
  If `is_train=False` the lags have length len(target) + pred_length
  
  Parameters
  ----------
  target_field
      Field with target values (array) of time series
  output_field
      Field name to use for the output.
  pred_length
      Prediction length.
  base_freq
      Base frequency, i.e., the frequency of the original time series.
  agg_freq
      Aggregate frequency, i.e., the frequency of the aggregate time series.
  agg_lags
      List of aggregate lags given in the aggregate frequency. If some of them
      are invalid (need some of the last `prediction_length` values to be
      computed) they are ignored.
  agg_fun
      Aggregation function. Default is 'mean'.
class_docstr_tok: ["Adds","aggregate","lags","as","a","feature","to","the","data_entry",".","Aggregates","the","original","time","series","to","a","new","frequency","and","selects","the","aggregated","lags","of","interest",".","It","does","not","use","aggregate","lags","that","need","the","last","`","prediction_length","`","values","to","be","computed",".","Therefore","the","transformation","is","applicable","to","both","training","and","inference",".","If","`","is_train=True","`","the","lags","have","the","same","length","as","the","`","target","`","field",".","If","`","is_train=False","`","the","lags","have","length","len","(","target",")","+","pred_length","Parameters","--","--","--","--","--","target_field","Field","with","target","values","(","array",")","of","time","series","output_field","Field","name","to","use","for","the","output",".","pred_length","Prediction","length",".","base_freq","Base","frequency",",","i.e.",",","the","frequency","of","the","original","time","series",".","agg_freq","Aggregate","frequency",",","i.e.",",","the","frequency","of","the","aggregate","time","series",".","agg_lags","List","of","aggregate","lags","given","in","the","aggregate","frequency",".","If","some","of","them","are","invalid","(","need","some","of","the","last","`","prediction_length","`","values","to","be","computed",")","they","are","ignored",".","agg_fun","Aggregation","function",".","Default","is","'mean","'","."]
code: def map_transform(self, data: DataEntry, is_train: bool) -> DataEntry:
      assert self.base_freq == data["start"].freq
  
      # convert to pandas Series for easier indexing and aggregation
      if is_train:
          t = data[self.target_field]
      else:
          t = np.concatenate(
              [
                  data[self.target_field],
                  np.zeros(shape=(self.pred_length,)),
              ],
              axis=0,
          )
  
      # convert to pandas Series for easier rolling window aggregation
      t_agg = (pd.Series(t).rolling(self.ratio).agg(self.agg_fun))[
          self.ratio - 1 :
      ]
  
      # compute the aggregate lags for each time point of the time series
      agg_vals = np.concatenate(
          [
              np.zeros(
                  (
                      max(self.valid_lags) * self.ratio
                      + self.half_window
                      + 1,
                  )
              ),
              t_agg.values,
          ],
          axis=0,
      )
      lags = np.vstack(
          [
              agg_vals[
                  -(l * self.ratio - self.half_window + len(t)) : -(
                      l * self.ratio - self.half_window
                  )
                  if -(l * self.ratio - self.half_window) != 0
                  else None
              ]
              for l in self.valid_lags
          ]
      )
  
      # update the data entry
      data[self.feature_name] = np.nan_to_num(lags)
  
      assert data[self.feature_name].shape == (
          len(self.valid_lags),
          len(data[self.target_field])
          + self.pred_length * (not is_train),
      )
  
      return data
  
imports: from typing import List, Optional, Union, Type
  import numpy
  import pandas
  from gluonts.core.component import validated
  from gluonts.dataset.common import DataEntry
  from gluonts.dataset.field_names import FieldName
  from gluonts.time_feature import TimeFeature
  from ._base import MapTransformation, SimpleTransformation
label_desc: Use image node_id 2 for calling the AddAggregateLags obj's underlying member method code with example usage: obj.map_transform(data, is_train) and returns: data