docstr: Test past `IntegerIndexEncoder`
docstr_tok: ["Test","past","`","IntegerIndexEncoder","`"]
code: def test_integer_positional_encoder(self):
      """Test past `IntegerIndexEncoder`"""
  
      ts = tg.linear_timeseries(length=24, freq="MS")
      input_chunk_length = 12
      output_chunk_length = 6
      # ===> test relative position encoder <===
      encoder_params = {
          "position": {"past": ["relative"], "future": ["relative"]}
      }
      encs = SequentialEncoder(
          add_encoders=encoder_params,
          input_chunk_length=input_chunk_length,
          output_chunk_length=output_chunk_length,
          takes_past_covariates=True,
          takes_future_covariates=True,
      )
      # relative encoder takes the end of the training series as reference
      vals = np.arange(-len(ts) + 1, 1).reshape((len(ts), 1))
  
      pc1, fc1 = encs.encode_train(ts)
      assert (
          pc1.time_index.equals(ts.time_index[:-output_chunk_length])
          and (pc1.values() == vals[:-output_chunk_length]).all()
      )
      assert (
          fc1.time_index.equals(ts.time_index)
          and (fc1.values() == vals).all()
      )
  
      pc2, fc2 = encs.encode_train(
          TimeSeries.from_times_and_values(
              ts.time_index[:20] + ts.freq, ts[:20].values()
          )
      )
      assert (
          pc2.time_index.equals(
              ts.time_index[: 20 - output_chunk_length] + ts.freq
          )
      ) and (pc2.values() == vals[-20:-output_chunk_length]).all()
      assert (
          fc2.time_index.equals(ts.time_index[:20] + ts.freq)
          and (fc2.values() == vals[-20:]).all()
      )
  
      pc3, fc3 = encs.encode_train(
          TimeSeries.from_times_and_values(
              ts.time_index[:18] - ts.freq, ts[:18].values()
          )
      )
      assert (
          pc3.time_index.equals(
              ts.time_index[: 18 - output_chunk_length] - ts.freq
          )
          and (pc3.values() == vals[-18:-output_chunk_length]).all()
      )
      assert (
          fc3.time_index.equals(ts.time_index[:18] - ts.freq)
          and (fc3.values() == vals[-18:]).all()
      )
  
      # quickly test inference encoding
      # n > output_chunk_length
      n = output_chunk_length + 1
      pc4, fc4 = encs.encode_inference(n, ts)
      assert (
          pc4.univariate_values()
          == np.arange(-input_chunk_length + 1, 1 + 1)
      ).all()
      assert (
          fc4.univariate_values()
          == np.arange(-input_chunk_length + 1, 1 + n)
      ).all()
      # n <= output_chunk_length
      n = output_chunk_length - 1
      t5, fc5 = encs.encode_inference(
          n,
          TimeSeries.from_times_and_values(
              ts.time_index[:20] + ts.freq, ts[:20].values()
          ),
      )
      assert (
          t5.univariate_values()
          == np.arange(-input_chunk_length + 1, 0 + 1)
      ).all()
      assert (
          fc5.univariate_values()
          == np.arange(-input_chunk_length + 1, output_chunk_length + 1)
      ).all()
  
      # quickly test with lags
      min_pc_lag = -input_chunk_length - 2  # = -14
      max_pc_lag = -6
      min_fc_lag = 2
      max_fc_lag = 8
      encs = SequentialEncoder(
          add_encoders=encoder_params,
          input_chunk_length=input_chunk_length,
          output_chunk_length=output_chunk_length,
          takes_past_covariates=True,
          takes_future_covariates=True,
          lags_past_covariates=[min_pc_lag, max_pc_lag],
          lags_future_covariates=[min_fc_lag, max_fc_lag],
      )
      pc1, fc1 = encs.encode_train(ts)
      assert (
          pc1.start_time() == pd.Timestamp("1999-11-01")
          and pc1.end_time() == pd.Timestamp("2001-01-01")
          and (pc1.univariate_values() == np.arange(-25, -10)).all()
          and pc1[ts.start_time()].univariate_values()[0] == -23
      )
      assert (
          fc1.start_time() == pd.Timestamp("2001-03-01")
          and fc1.end_time() == pd.Timestamp("2002-03-01")
          and (fc1.univariate_values() == np.arange(-9, 4)).all()
          and fc1[ts.end_time()].univariate_values()[0] == 0
      )
  
      n = 2
      pc2, fc2 = encs.encode_inference(n=n, target=ts)
      assert (
          pc2.start_time() == pd.Timestamp("2000-11-01")
          and pc2.end_time() == pd.Timestamp("2001-07-01")
          and (pc2.univariate_values() == np.arange(-13, -4)).all()
      )
      assert (
          fc2.start_time() == pd.Timestamp("2002-03-01")
          and fc2.end_time() == pd.Timestamp("2002-09-01")
          and (fc2.univariate_values() == np.arange(3, 10)).all()
      )
  
imports: import copy
  from typing import Optional, Sequence
  import numpy
  import pandas
  import pytest
  from darts import TimeSeries
  from darts.dataprocessing.encoders import FutureCallableIndexEncoder, FutureCyclicEncoder, FutureDatetimeAttributeEncoder, FutureIntegerIndexEncoder, PastCallableIndexEncoder, PastCyclicEncoder, PastDatetimeAttributeEncoder, PastIntegerIndexEncoder, SequentialEncoder
  from darts.dataprocessing.encoders.encoder_base import PastCovariatesIndexGenerator, SingleEncoder
  from darts.dataprocessing.encoders.encoders import CallableIndexEncoder, CyclicTemporalEncoder, DatetimeAttributeEncoder, IntegerIndexEncoder
  from darts.dataprocessing.transformers import Scaler
  from darts.logging import get_logger, raise_log
  from darts.utils import timeseries_generation
label_desc: Use image node_id 10 for calling the TestEncoder obj's underlying member method code with example usage: obj.test_integer_positional_encoder() without return types