code: def test_prediction_data_creation(self, mode):
      # assigning correct names to variables
      series = [ts[:-50] for ts in self.target_series]
      output_chunk_length = 5
      n = 12
  
      # prediction preprocessing start
      covariates = {
          "past": (self.past_covariates, self.lags_1.get("past")),
          "future": (self.future_covariates, self.lags_1.get("future")),
      }
  
      if mode:
          shift = 0
      else:
          shift = output_chunk_length - 1
  
      # dictionary containing covariate data over time span required for prediction
      covariate_matrices = {}
      # dictionary containing covariate lags relative to minimum covariate lag
      relative_cov_lags = {}
      # number of prediction steps given forecast horizon and output_chunk_length
      n_pred_steps = math.ceil(n / output_chunk_length)
      remaining_steps = (
          n % output_chunk_length
      )  # for multi_models = False
      for cov_type, (covs, lags) in covariates.items():
          if covs is not None:
              relative_cov_lags[cov_type] = np.array(lags) - lags[0]
              covariate_matrices[cov_type] = []
              for idx, (ts, cov) in enumerate(zip(series, covs)):
                  first_pred_ts = ts.end_time() + 1 * ts.freq
                  last_pred_ts = (
                      (
                          first_pred_ts
                          + ((n_pred_steps - 1) * output_chunk_length)
                          * ts.freq
                      )
                      if mode
                      else (first_pred_ts + (n - 1) * ts.freq)
                  )
                  first_req_ts = (
                      first_pred_ts + (lags[0] - shift) * ts.freq
                  )
                  last_req_ts = (
                      last_pred_ts + (lags[-1] - shift) * ts.freq
                  )
  
                  # not enough covariate data checks excluded, they are tested elsewhere
  
                  if cov.has_datetime_index:
                      covariate_matrices[cov_type].append(
                          cov.slice(first_req_ts, last_req_ts).values(
                              copy=False
                          )
                      )
                  else:
                      # include last_req_ts when slicing series with integer indices
                      covariate_matrices[cov_type].append(
                          cov[first_req_ts : last_req_ts + 1].values(
                              copy=False
                          )
                      )
  
              covariate_matrices[cov_type] = np.stack(
                  covariate_matrices[cov_type]
              )
  
      series_matrix = None
      if "target" in self.lags_1:
          series_matrix = np.stack(
              [
                  ts.values(copy=False)[
                      self.lags_1["target"][0] - shift :, :
                  ]
                  for ts in series
              ]
          )
      # prediction preprocessing end
      assert all(
          [
              lag >= 0
              for lags in relative_cov_lags.values()
              for lag in lags
          ]
      )
  
      if mode:
          # tests for multi_models = True
          assert covariate_matrices["past"].shape == (
              len(series),
              relative_cov_lags["past"][-1]
              + (n_pred_steps - 1) * output_chunk_length
              + 1,
              covariates["past"][0][0].width,
          )
          assert covariate_matrices["future"].shape == (
              len(series),
              relative_cov_lags["future"][-1]
              + (n_pred_steps - 1) * output_chunk_length
              + 1,
              covariates["future"][0][0].width,
          )
          assert series_matrix.shape == (
              len(series),
              -self.lags_1["target"][0],
              series[0].width,
          )
          assert list(covariate_matrices["past"][0, :, 0]) == [
              10047.0,
              10048.0,
              10049.0,
              10050.0,
              10051.0,
              10052.0,
              10053.0,
              10054.0,
              10055.0,
              10056.0,
              10057.0,
              10058.0,
              10059.0,
          ]
          assert list(covariate_matrices["future"][0, :, 0]) == [
              20046.0,
              20047.0,
              20048.0,
              20049.0,
              20050.0,
              20051.0,
              20052.0,
              20053.0,
              20054.0,
              20055.0,
              20056.0,
              20057.0,
              20058.0,
              20059.0,
              20060.0,
              20061.0,
              20062.0,
              20063.0,
          ]
          assert list(series_matrix[0, :, 0]) == [48.0, 49.0, 50.0]
      else:
          # tests for multi_models = False
          assert covariate_matrices["past"].shape == (
              len(series),
              relative_cov_lags["past"][-1]
              + (n_pred_steps - 1) * output_chunk_length
              + (remaining_steps - 1)
              + 1,
              covariates["past"][0][0].width,
          )
          assert covariate_matrices["future"].shape == (
              len(series),
              relative_cov_lags["future"][-1]
              + (n_pred_steps - 1) * output_chunk_length
              + (remaining_steps - 1)
              + 1,
              covariates["future"][0][0].width,
          )
          assert series_matrix.shape == (
              len(series),
              -self.lags_1["target"][0] + shift,
              series[0].width,
          )
          assert list(covariate_matrices["past"][0, :, 0]) == [
              10043.0,
              10044.0,
              10045.0,
              10046.0,
              10047.0,
              10048.0,
              10049.0,
              10050.0,
              10051.0,
              10052.0,
              10053.0,
              10054.0,
              10055.0,
              10056.0,
          ]
          assert list(covariate_matrices["future"][0, :, 0]) == [
              20042.0,
              20043.0,
              20044.0,
              20045.0,
              20046.0,
              20047.0,
              20048.0,
              20049.0,
              20050.0,
              20051.0,
              20052.0,
              20053.0,
              20054.0,
              20055.0,
              20056.0,
              20057.0,
              20058.0,
              20059.0,
              20060.0,
          ]
          assert list(series_matrix[0, :, 0]) == [
              44.0,
              45.0,
              46.0,
              47.0,
              48.0,
              49.0,
              50.0,
          ]
  
imports: import copy
  import functools
  import itertools
  import math
  from unittest.mock import patch
  import numpy
  import pandas
  import pytest
  from sklearn.ensemble import HistGradientBoostingRegressor, RandomForestRegressor
  from sklearn.linear_model import LinearRegression
  import darts
  from darts import TimeSeries
  from darts.dataprocessing.encoders import FutureCyclicEncoder, PastDatetimeAttributeEncoder
  from darts.logging import get_logger
  from darts.metrics import mae, rmse
  from darts.models import CatBoostModel, LightGBMModel, LinearRegressionModel, NotImportedModule, RandomForest, RegressionModel, XGBModel
  from darts.utils import timeseries_generation
  from darts.utils.multioutput import MultiOutputRegressor
label_desc: Use image node_id 4 for calling the TestRegressionModels obj's underlying member method code with example usage: obj.test_prediction_data_creation(mode) without return types