class_docstr: Memory Augmented Time Series Dataset
  
  Args:
      handler (DataHandler): data handler
      segments (dict): data split segments
      seq_len (int): time series sequence length
      horizon (int): label horizon (to mask historical loss for TRA)
      num_states (int): how many memory states to be added (for TRA)
      batch_size (int): batch size (<0 means daily batch)
      shuffle (bool): whether shuffle data
      pin_memory (bool): whether pin data to gpu memory
      drop_last (bool): whether drop last batch < batch_size
class_docstr_tok: ["Memory","Augmented","Time","Series","Dataset","Args",":","handler","(","DataHandler",")",":","data","handler","segments","(","dict",")",":","data","split","segments","seq_len","(","int",")",":","time","series","sequence","length","horizon","(","int",")",":","label","horizon","(","to","mask","historical","loss","for","TRA",")","num_states","(","int",")",":","how","many","memory","states","to","be","added","(","for","TRA",")","batch_size","(","int",")",":","batch","size","(","<","0","means","daily","batch",")","shuffle","(","bool",")",":","whether","shuffle","data","pin_memory","(","bool",")",":","whether","pin","data","to","gpu","memory","drop_last","(","bool",")",":","whether","drop","last","batch","<","batch_size"]
code: def setup_data(self, handler_kwargs: dict = None, **kwargs):
      super().setup_data()
  
      # change index to <code, date>
      # NOTE: we will use inplace sort to reduce memory use
      df = self.handler._data
      df.index = df.index.swaplevel()
      df.sort_index(inplace=True)
  
      self._data = df["feature"].values.astype("float32")
      self._label = df["label"].squeeze().astype("float32")
      self._index = df.index
  
      # add memory to feature
      self._data = np.c_[
          self._data,
          np.zeros(
              (len(self._data), self.num_states), dtype=np.float32
          ),
      ]
  
      # padding tensor
      self.zeros = np.zeros(
          (self.seq_len, self._data.shape[1]), dtype=np.float32
      )
  
      # pin memory
      if self.pin_memory:
          self._data = _to_tensor(self._data)
          self._label = _to_tensor(self._label)
          self.zeros = _to_tensor(self.zeros)
  
      # create batch slices
      self.batch_slices = _create_ts_slices(self._index, self.seq_len)
  
      # create daily slices
      index = [slc.stop - 1 for slc in self.batch_slices]
      act_index = self.restore_index(index)
      daily_slices = {
          date: [] for date in sorted(act_index.unique(level=1))
      }
      for i, (code, date) in enumerate(act_index):
          daily_slices[date].append(self.batch_slices[i])
      self.daily_slices = list(daily_slices.values())
  
imports: import copy
  import torch
  import numpy
  import pandas
  from qlib.data.dataset import DatasetH
label_desc: Use image node_id 2 for calling the MTSDatasetH obj's underlying member method code with example usage: obj.setup_data(handler_kwargs) without return types