code: def sample_supps(
      supps_size: int,
      length: int,
      dataset: TimeSeriesDataset,
      index_iterator: Iterator,
      q_split: Optional[pd.Timestamp] = None,
      # seed: Optional[int] = None,
      cheat_query: Optional[TimeSeries] = None,
  ):
      """
      Args:
          supps_size: The number of support time series
          length: The length of the support time series slice
          dataset: The dataset to choose support time series slices from
          index_iterator: An iterator that returns indices of the dataset sampled w.r.t. some weights.
          q_split: The latest possible end time of all support time series
          cheat_query: If not None, the cheat query is contained in the support set at a random position.
      """
  
      support_set = []
      for i in range(supps_size):
          series = dataset[next(index_iterator)]
          if q_split:
              # support set slice is the one closest to the prediction point of the query
              freq = series.start_date.freq
              end_point = min(
                  (
                      q_split.to_period(freq)
                      - series.start_date.to_period(freq)
                  ).n,
                  len(series),
              )
              if end_point <= 0:
                  # this should basically never happen and is only there to not break the training in case it happens
                  support_set.append(
                      TimeSeries(
                          dataset_name=series.dataset_name,
                          start_date=None,
                          values=torch.zeros(1, 1),
                          scale=torch.as_tensor([0, 1]),
                      )
                  )
                  continue
          else:
              # if possible choose a full-length slice
              end_point = np.random.randint(
                  low=min(len(series), length), high=len(series) + 1
              )
          support_ts = series[max(0, end_point - length) : end_point]
          support_set.append(support_ts)
      if cheat_query is not None:
          support_set[np.random.choice(supps_size)] = cheat_query
      return support_set
  
imports: from __future__ import annotations
  import numpy
  import pandas
  from dataclasses import dataclass, fields
  from typing import Iterator, List, Optional
  import torch
  from torch.utils.data import IterableDataset, Dataset
  from .dataset import TimeSeries, TimeSeriesDataset
label_desc: Use image node_id 1 for calling a global function with example usage: sample_supps(supps_size, length, dataset, index_iterator, q_split, cheat_query) and returns: support_set