code: def test_time_series_slice():
      entry = {
          "start": pd.Period("2021-02-03", "D"),
          "target": np.array(range(100), dtype=float),
          "feat_dynamic_real": np.expand_dims(
              np.array(range(100), dtype=float), 0
          ),
      }
  
      entry_slice = slice_data_entry(entry, slice(10, 20))
      assert entry_slice["start"] == pd.Period("2021-02-03", "D") + 10
      assert (entry_slice["target"] == np.arange(10, 20)).all()
      assert (
          entry_slice["feat_dynamic_real"]
          == np.array([np.arange(10, 20)])
      ).all()
  
      entry_slice = slice_data_entry(entry, slice(None, -20))
      assert entry_slice["start"] == pd.Period("2021-02-03", "D")
      assert (entry_slice["target"] == np.arange(80)).all()
      assert (
          entry_slice["feat_dynamic_real"] == np.array([np.arange(80)])
      ).all()
  
      entry_slice = slice_data_entry(entry, slice(-20, None))
      assert entry_slice["start"] == pd.Period("2021-02-03", "D") + 80
      assert (entry_slice["target"] == np.arange(80, 100)).all()
      assert (
          entry_slice["feat_dynamic_real"]
          == np.array([np.arange(80, 100)])
      ).all()
  
file_path: gluonts/test/dataset/test_split.py
imports: import numpy
  import pandas
  import pytest
  from gluonts.dataset.field_names import FieldName
  from gluonts.dataset.split import OffsetSplitter, periods_between, split, slice_data_entry
label_desc: Use image node_id 1 for calling a global function with example usage: test_time_series_slice() without return types