code: def compute_time_features(
      entry: Dict,
      time_features: List[TimeFeature],
      pred_length: int = 0,
      dtype=np.float32,
  ):
      assert pred_length >= 0
      index = to_pandas(entry, freq=entry["start"].freq).index
  
      if pred_length > 0:
          index = index.union(
              pd.period_range(
                  index[-1] + 1,
                  index[-1] + pred_length,
                  freq=index.freq,
              )
          )
  
      feature_arrays = [feat(index) for feat in time_features]
      return np.vstack(feature_arrays).astype(dtype)
  
file_path: gluonts/test/transform/test_add_time_features.py
imports: from typing import Dict, List
  import pandas
  import numpy
  import pytest
  from gluonts.dataset.common import Dataset, ListDataset
  from gluonts.dataset.util import to_pandas
  from gluonts.transform.feature import AddTimeFeatures
  from gluonts.time_feature import TimeFeature, month_of_year, time_features_from_frequency_str
label_desc: Use image node_id 1 for calling a global function with example usage: compute_time_features(entry, time_features, pred_length, dtype) and returns: np