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 __iter__(self):
      slices, batch_size = self._get_slices()
      if self.shuffle:
          np.random.shuffle(slices)
  
      for i in range(len(slices))[::batch_size]:
          if self.drop_last and i + batch_size > len(slices):
              break
          # get slices for this batch
          slices_subset = slices[i : i + batch_size]
          if self.batch_size < 0:
              slices_subset = np.concatenate(slices_subset)
          # collect data
          data = []
          label = []
          index = []
          for slc in slices_subset:
              _data = (
                  self._data[slc].clone()
                  if self.pin_memory
                  else self._data[slc].copy()
              )
              if len(_data) != self.seq_len:
                  if self.pin_memory:
                      _data = torch.cat(
                          [
                              self.zeros[: self.seq_len - len(_data)],
                              _data,
                          ],
                          axis=0,
                      )
                  else:
                      _data = np.concatenate(
                          [
                              self.zeros[: self.seq_len - len(_data)],
                              _data,
                          ],
                          axis=0,
                      )
              if self.num_states > 0:
                  _data[-self.horizon :, -self.num_states :] = 0
              data.append(_data)
              label.append(self._label[slc.stop - 1])
              index.append(slc.stop - 1)
          # concate
          index = torch.tensor(index, device=device)
          if isinstance(data[0], torch.Tensor):
              data = torch.stack(data)
              label = torch.stack(label)
          else:
              data = _to_tensor(np.stack(data))
              label = _to_tensor(np.stack(label))
          # yield -> generator
          yield {"data": data, "label": label, "index": index}
  
imports: import copy
  import torch
  import numpy
  import pandas
  from qlib.data.dataset import DatasetH
label_desc: Use image node_id 11 for calling the MTSDatasetH obj's underlying member method code with example usage: obj.__iter__() without return types