def _encode(
        self, index: SupportedIndex, target_end: pd.Timestamp, dtype: np.dtype
    ) -> TimeSeries:
        """Apply the user-defined callable to encode the index"""
        super()._encode(index, target_end, dtype)

        return TimeSeries.from_times_and_values(
            times=index,
            values=self.attribute(index),
            columns=[self.base_component_name + "custom"],
        ).astype(np.dtype(dtype))
Apply the user-defined callable to encode the index
darts/dataprocessing/encoders/encoders.py