code: def naive_2(
      past_ts_data: np.ndarray,
      prediction_length: int,
      season_length: int,
  ) -> np.ndarray:
      """
      Make seasonality adjusted time series prediction.
  
      For details, see:
      http://www.unic.ac.cy/test/wp-content/uploads/sites/2/2018/09/M4-Competitors-Guide.pdf
  
      Code based on:
      https://github.com/Mcompetitions/M4-methods/blob/master/Benchmarks%20and%20Evaluation.R
      """
      assert (
          season_length > 0
      ), "The value of `season_length` should be > 0"
  
      has_seasonality = False
  
      if season_length > 1:
          has_seasonality = seasonality_test(
              past_ts_data, season_length
          )
  
      # it has seasonality, then calculate the multiplicative seasonal component
      if has_seasonality:
          # TODO: think about maybe only using past_ts_data[- max
          # (5*season_length, 2*prediction_length):] for speedup
          seasonal_decomposition = sm.tsa.seasonal_decompose(
              x=past_ts_data,
              period=season_length,
              model="multiplicative",
          ).seasonal
          seasonality_normed_context = (
              past_ts_data / seasonal_decomposition
          )
  
          last_period = seasonal_decomposition[-season_length:]
          num_required_periods = (
              prediction_length // len(last_period)
          ) + 1
  
          multiplicative_seasonal_component = np.tile(
              last_period, num_required_periods
          )[:prediction_length]
      else:
          seasonality_normed_context = past_ts_data
          multiplicative_seasonal_component = np.ones(
              prediction_length
          )  # i.e. no seasonality component
  
      # calculate naive forecast: (last value prediction_length times)
      naive_forecast = (
          np.ones(prediction_length) * seasonality_normed_context[-1]
      )
  
      forecast = (
          np.mean(naive_forecast) * multiplicative_seasonal_component
      )
  
      return forecast
  
file_path: gluonts/src/gluonts/ext/naive_2/_predictor.py
imports: import numpy
  import statsmodels.api
  from gluonts.core.component import validated
  from gluonts.dataset.common import DataEntry
  from gluonts.dataset.util import forecast_start
  from gluonts.model.forecast import Forecast, SampleForecast
  from gluonts.model.predictor import RepresentablePredictor
label_desc: Use image node_id 2 for calling a global function with example usage: naive_2(past_ts_data, prediction_length, season_length) and returns: forecast