code: def create_time_delay_embedding(
      series: Series,
      window_size: int,
      horizon: int,
      padding_value: int,
      backend: "Backend",
  ) -> Series:
      """Time delay embedding from:
  
      https://towardsdatascience.com/machine-learning-for-forecasting-transformations-and-feature-extraction-bbbea9de0ac2
  
      Args:
          series: Column-major timeseries data.
          window_size: Size of the lookback sliding window for timeseries inputs.
          horizon: Size of the forward-looking horizon for timeseries outputs.
          padding_value: Value to pad out the window when there is not enough data around the observation.
  
      Returns:
          A column of timeseries window arrays in row-major format for training.
      """
      # Replace default fill value of "" with nan as we will be assuming numeric values here
      series = series.replace("", np.nan)
  
      # Create the list of shifts we want to perform over the series.
      # For backwards looking shifts, we want to include the current element, while for forward looking shifts we do not.
      # Example:
      #   window_size=3, horizon=0 --> shift_offsets=[2, 1, 0]
      #   window_size=0, horizon=2 --> shift_offsets=[-1, -2]
      shift_offsets = list(range(window_size - 1, -(horizon + 1), -1))
      shifts = [series.shift(i) for i in shift_offsets]
      df = backend.df_engine.df_lib.concat(shifts, axis=1)
      df.columns = [f"__tmp_column_{j}" for j in shift_offsets]
      return df.apply(
          lambda x: np.nan_to_num(
              np.array(x.tolist()).astype(np.float32), nan=padding_value
          ),
          axis=1,
      )
  
imports: import logging
  from typing import Dict, List, TYPE_CHECKING, Union
  import numpy
  import torch
  from ludwig.constants import COLUMN, HIDDEN, LOGITS, NAME, PREDICTIONS, PROC_COLUMN, TIMESERIES
  from ludwig.features.base_feature import BaseFeatureMixin, OutputFeature, PredictModule
  from ludwig.features.sequence_feature import SequenceInputFeature
  from ludwig.features.vector_feature import _VectorPostprocessing, _VectorPredict
  from ludwig.schema.features.timeseries_feature import TimeseriesInputFeatureConfig, TimeseriesOutputFeatureConfig
  from ludwig.types import FeatureMetadataDict, ModelConfigDict, PreprocessingConfigDict, TrainingSetMetadataDict
  from ludwig.utils.tokenizers import get_tokenizer_from_registry, TORCHSCRIPT_COMPATIBLE_TOKENIZERS
  from ludwig.utils.types import Series, TorchscriptPreprocessingInput
label_desc: Use image node_id 1 for calling a global function with example usage: create_time_delay_embedding(series, window_size, horizon, padding_value, backend) and returns: df