code: def get_group_data_by_var(name, num_groups, len_sample=9):
      dataset = get_dataset(name)
      dataset_group = [[] for i in range(num_groups)]
      whole_data = []
      ret = []
      it = iter(dataset.train)
      num_ts = int(dataset.metadata.feat_static_cat[0].cardinality)
      group_boundary = [1e3, 5e3, 1e4, 5e4, 1e5, 5e5]
      for i in range(num_ts):
          train_entry = next(it)
          unsplit_ts = train_entry["target"][0:800]
          unsplit_start = train_entry["start"]
          whole_data.append(
              {"target": unsplit_ts, "start": unsplit_start}
          )
          for ts_sample_start in range(len(unsplit_ts) - len_sample):
              group_id = 0
              print(
                  torch.var(
                      torch.FloatTensor(
                          unsplit_ts[
                              ts_sample_start : ts_sample_start
                              + len_sample
                          ]
                      )
                  )
              )
              continue
              dataset_group[group_id].append(
                  {
                      "target": unsplit_ts[
                          ts_sample_start : ts_sample_start + len_sample
                      ],
                      "start": unsplit_start,
                  }
              )
              unsplit_start += pd.Timedelta(hours=1)
      import pdb
  
      pdb.set_trace()
      random.shuffle(whole_data)
      print("append once")
      ret.append(ListDataset(whole_data, freq=dataset.metadata.freq))
      print("append twice")
      ret.append(ListDataset(whole_data, freq=dataset.metadata.freq))
      print("append data")
      for group in dataset_group:
          random.shuffle(group)
          ret.append(ListDataset(group, freq=dataset.metadata.freq))
      print("write whole data")
      with open(
          "synthetic_traffic_time_whole_data.csv", "wb"
      ) as output:
          pickle.dump(ret[0:2], output)
      print("write group data")
      with open(
          "synthetic_traffic_time_group_data.csv", "wb"
      ) as output:
          pickle.dump(ret, output)
      return True
  
imports: from pts.dataset.repository.datasets import get_dataset, dataset_recipes
  from pts.dataset.utils import to_pandas
  import numpy
  import pandas
  from pts.dataset import ListDataset
  import torch
  from pts.model.simple_feedforward import SimpleFeedForwardEstimator
  import pickle
  import json
  import random
label_desc: Use image node_id 4 for calling a global function with example usage: get_group_data_by_var(name, num_groups, len_sample) and returns: True