class_docstr: A :class:`Predictor` that predicts the moving average based on the last
  `context_length` elements of the input target.
  
  If `prediction_length` = 1, the output is the moving average
  based on the last `context_length` elements of the input target.
  
  If `prediction_length` > 1, the output is the moving average based on the
  last `context_length` elements of the input target, where previously
  calculated moving averages are appended at the end of the inputtarget.
  Hence, for `prediction_length` larger than `context_length`, there will be
  cases where the moving average is calculated on top of previous moving
  averages.
  
  Parameters
  ----------
  context_length
      Length of the target context used to condition the predictions.
  prediction_length
      Length of the prediction horizon.
code: def predict_item(self, item: DataEntry) -> SampleForecast:
      target = item["target"].tolist()
  
      for _ in range(self.prediction_length):
          if self.context_length is not None:
              window = target[-self.context_length :]
          else:
              window = target
  
          target.append(np.nanmean(window))
  
      return SampleForecast(
          samples=np.array([target[-self.prediction_length :]]),
          start_date=forecast_start(item),
          item_id=item.get(FieldName.ITEM_ID),
      )
  
imports: from typing import Optional
  import numpy
  from gluonts.core.component import validated
  from gluonts.dataset.common import DataEntry, Dataset
  from gluonts.dataset.field_names import FieldName
  from gluonts.dataset.util import forecast_start
  from gluonts.model.estimator import Estimator
  from gluonts.model.forecast import SampleForecast
  from gluonts.model.predictor import RepresentablePredictor
  from gluonts.model.trivial.constant import ConstantPredictor
  from gluonts.pydantic import PositiveInt
label_desc: Use image node_id 2 for calling the MovingAveragePredictor obj's underlying member method code with example usage: obj.predict_item(item) and returns: SampleForecast