code: def get_data_frame_with_variable_lengths(
      item_id_to_length: Dict[str, int],
      static_features: Optional[pd.DataFrame] = None,
      covariates_names: Optional[List[str]] = None,
      freq: str = "D",
  ):
      tuples = []
      for item_id, length in item_id_to_length.items():
          for ts in pd.date_range(
              pd.Timestamp("2022-01-01"), periods=length, freq=freq
          ):
              tuples.append((item_id, ts))
      index = pd.MultiIndex.from_tuples(
          tuples, names=[ITEMID, TIMESTAMP]
      )
      df = TimeSeriesDataFrame(
          pd.DataFrame(
              index=index,
              data=[random.random() for _ in index],
              columns=["target"],
          )
      )
      df.freq  # compute _cached_freq
      df.static_features = static_features
      if covariates_names is not None:
          for name in covariates_names:
              df[name] = np.random.normal(size=len(df))
      return df
  
file_path: autogluon/timeseries/tests/unittests/common.py
imports: import random
  from typing import Dict, List, Optional, Union
  import numpy
  import pandas
  from gluonts.dataset.common import ListDataset
  from autogluon.timeseries.dataset import TimeSeriesDataFrame
  from autogluon.timeseries.dataset.ts_dataframe import ITEMID, TIMESTAMP
  from autogluon.timeseries.metrics import TimeSeriesScorer
label_desc: Use image node_id 2 for calling a global function with example usage: get_data_frame_with_variable_lengths(item_id_to_length, static_features, covariates_names, freq) and returns: df