code: def test_long_csv_3M():
      data = (
          "timestamp,item_id,target,static_feat\n"
          "2021-03,0,102,A\n"
          "2022-07,1,138,B\n"
          "2021-06,0,103,A\n"
          "2021-11,2,227,C\n"
          "2021-09,0,102,A\n"
          "2021-12,0,99,A\n"
          "2022-01,1,148,B\n"
          "2022-05,2,229,C\n"
          "2021-04,1,134,B\n"
          "2022-04,1,117,B\n"
          "2021-02,2,212,C\n"
          "2021-05,2,225,C\n"
          "2021-07,1,151,B\n"
          "2021-08,2,221,C\n"
          "2022-02,2,230,C\n"
          "2021-10,1,144,B\n"
      )
  
      expected_entries = [
          {
              "start": pd.Period("2021-03", freq="3M"),
              "item_id": 0,
              "feat_static_cat": np.array([0]),
              "target": np.array([102, 103, 102, 99]),
          },
          {
              "start": pd.Period("2021-04", freq="3M"),
              "item_id": 1,
              "feat_static_cat": np.array([1]),
              "target": np.array([134, 151, 144, 148, 117, 138]),
          },
          {
              "start": pd.Period("2021-02", freq="3M"),
              "item_id": 2,
              "feat_static_cat": np.array([2]),
              "target": np.array([212, 225, 221, 227, 230, 229]),
          },
      ]
  
      datasets = []
  
      with io.StringIO(data) as fp:
          df_long = pd.read_csv(fp)
          df_long["static_feat"] = df_long["static_feat"].astype(
              "category"
          )
          datasets.append(
              pandas.PandasDataset.from_long_dataframe(
                  df_long,
                  target="target",
                  item_id="item_id",
                  timestamp="timestamp",
                  freq="3M",
                  static_feature_columns=["static_feat"],
              )
          )
  
      with io.StringIO(data) as fp:
          df_long = pd.read_csv(fp, index_col="timestamp")
          df_long["static_feat"] = df_long["static_feat"].astype(
              "category"
          )
          datasets.append(
              pandas.PandasDataset.from_long_dataframe(
                  df_long,
                  target="target",
                  item_id="item_id",
                  freq="3M",
                  static_feature_columns=["static_feat"],
              )
          )
  
      for ds in datasets:
          assert ds.static_cardinalities == np.array([3])
          assert isinstance(str(ds), str)
          for entry, expected_entry in zip(ds, expected_entries):
              assert entry["start"].freqstr == "3M"
              assert entry["start"] == expected_entry["start"]
              assert entry["item_id"] == expected_entry["item_id"]
              assert (
                  entry["feat_static_cat"]
                  == expected_entry["feat_static_cat"]
              )
              assert np.allclose(
                  entry["target"], expected_entry["target"]
              )
  
imports: import io
  from typing import Callable, List, Union
  import pandas
  import numpy
  import pytest
  from gluonts.dataset import pandas
  from gluonts.testutil.equality import assert_recursively_equal
label_desc: Use image node_id 12 for calling a global function with example usage: test_long_csv_3M() without return types