docstr: Test `CallableIndexEncoder`
docstr_tok: ["Test","`","CallableIndexEncoder","`"]
code: def test_callable_encoder(self):
      """Test `CallableIndexEncoder`"""
      ts = tg.linear_timeseries(length=24, freq="A")
      input_chunk_length = 12
      output_chunk_length = 6
  
      # encoders must be named functions for pickling
      def index_year(index):
          return index.year
  
      def index_year_shifted(index):
          return index.year - 1
  
      # ===> test callable index encoder <===
      encoder_params = {
          "custom": {
              "past": [index_year, index_year_shifted],
              "future": [index_year],
          }
      }
      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,
      )
  
      # train set
      pc, fc = encs.encode_train(ts)
      # past covariates
      np.testing.assert_array_equal(
          ts[:-output_chunk_length].time_index.year.values,
          pc.values()[:, 0],
      )
      np.testing.assert_array_equal(
          ts[:-output_chunk_length].time_index.year.values - 1,
          pc.values()[:, 1],
      )
      # future covariates
      np.testing.assert_array_equal(
          ts.time_index.year.values, fc.values()[:, 0]
      )
  
      # inference set
      pc, fc = encs.encode_inference(n=12, target=ts)
      year_index = tg.generate_index(
          start=ts.end_time() - ts.freq * (input_chunk_length - 1),
          length=24,
          freq=ts.freq,
      )
      # past covariates
      np.testing.assert_array_equal(
          year_index[:-output_chunk_length].year.values,
          pc.values()[:, 0],
      )
      np.testing.assert_array_equal(
          year_index[:-output_chunk_length].year.values - 1,
          pc.values()[:, 1],
      )
      # future covariates
      np.testing.assert_array_equal(
          year_index.year.values, fc.values()[:, 0]
      )
  
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 11 for calling the TestEncoder obj's underlying member method code with example usage: obj.test_callable_encoder() and returns: index, unknown