code: def test_agg_lags(pred_length):
      # create dummy dataset
      target = np.array([1, 1, 1, 2, 2, 3, 3, 4, 5, 6])
      start = pd.Period("01-01-2019 01:00:00", freq="1H")
      freq = "1H"
      ds = ListDataset(
          [{FieldName.TARGET: target, FieldName.START: start}],
          freq=freq,
      )
  
      # 2H aggregate lags
      lags_2H = [1, 2, 3, 4, 6]
  
      add_agg_lags = AddAggregateLags(
          target_field=FieldName.TARGET,
          output_field="lags_2H",
          pred_length=pred_length,
          base_freq=freq,
          agg_freq="2H",
          agg_lags=lags_2H,
      )
  
      assert add_agg_lags.ratio == 2
  
      train_entry = next(add_agg_lags(iter(ds), is_train=True))
      test_entry = next(add_agg_lags(iter(ds), is_train=False))
  
      assert (
          add_agg_lags.valid_lags
          == valid_lags_rolling[f"prediction_length_{pred_length}"]
      )
  
      assert np.allclose(
          train_entry["lags_2H"],
          expected_lags_rolling[f"prediction_length_{pred_length}"][
              "train"
          ],
      )
  
      assert np.allclose(
          test_entry["lags_2H"],
          expected_lags_rolling[f"prediction_length_{pred_length}"][
              "test"
          ],
      )
  
imports: import numpy
  import pandas
  import pytest
  from gluonts.dataset.common import ListDataset
  from gluonts.dataset.field_names import FieldName
  from gluonts.transform import AddAggregateLags
label_desc: Use image node_id 1 for calling a global function with example usage: test_agg_lags(pred_length) without return types