code: def _predict_batch_autoreg(
      self, dataset: Iterable[Dict], **kwargs
  ) -> Iterator[Forecast]:
      # TODO clean up
      # TODO optimize
      batch_ids = []
      batch_scales = []
      batch_series = []
  
      for entry in dataset:
          batch_ids.append(entry.get(FieldName.ITEM_ID, None))
          series, scale = self.scaling(to_pandas(entry))
          batch_scales.append(scale)
          batch_series.append(series)
  
      batch_forecast_indices = [
          pd.period_range(
              series.index[-1] + 1,
              periods=self.prediction_length,
          )
          for series in batch_series
      ]
  
      batch_full_series = [
          series.append(
              pd.Series(
                  [None] * self.prediction_length,
                  index=forecast_index,
              )
          )
          for series, forecast_index in zip(
              batch_series, batch_forecast_indices
          )
      ]
  
      output = np.zeros(
          (len(batch_series), self.prediction_length), dtype=self.dtype
      )
  
      for k in range(self.prediction_length):
          dfs = []
          for fs, idx in zip(batch_full_series, batch_forecast_indices):
              idx_k = idx[k]
              dfs.append(
                  get_features_dataframe(
                      fs[idx_k:idx_k],
                      time_features=self.time_features,
                      lag_indices=self.lag_indices,
                      past_data=fs[:idx_k][:-1],
                  )
              )
          df = pd.concat(dfs)
          out_k = self.ag_model.predict(df)
          output[:, k] = out_k
          for fs, idx, v in zip(
              batch_full_series, batch_forecast_indices, out_k
          ):
              fs.at[idx[k]] = v
  
      for arr, scale, forecast_index, item_id in zip(
          output, batch_scales, batch_forecast_indices, batch_ids
      ):
          yield self._to_forecast(
              scale * arr,
              forecast_index[0],
              item_id=item_id,
          )
  
imports: from typing import Callable, Dict, List, Optional, Iterator, Iterable, Tuple
  import numpy
  import pandas
  import shutil
  from pathlib import Path
  from autogluon.tabular import TabularPredictor
  from gluonts.core.serde import dump_json, load_json
  from gluonts.dataset.util import to_pandas
  from gluonts.dataset.field_names import FieldName
  from gluonts.itertools import batcher
  from gluonts.model.forecast import SampleForecast, QuantileForecast, Forecast
  from gluonts.model.predictor import Predictor
  from gluonts.time_feature import TimeFeature
label_desc: Use image node_id 6 for calling the TabularPredictor obj's underlying member method code with example usage: obj._predict_batch_autoreg(dataset) without return types