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
      num_states (int): how many memory states to be added
      memory_mode (str): memory mode (daily or sample)
      batch_size (int): batch size (<0 will use daily sampling)
      n_samples (int): number of samples in the same day
      shuffle (bool): whether shuffle data
      drop_last (bool): whether drop last batch < batch_size
      input_size (int): reshape flatten rows as this input_size (backward compatibility)
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","num_states","(","int",")",":","how","many","memory","states","to","be","added","memory_mode","(","str",")",":","memory","mode","(","daily","or","sample",")","batch_size","(","int",")",":","batch","size","(","<","0","will","use","daily","sampling",")","n_samples","(","int",")",":","number","of","samples","in","the","same","day","shuffle","(","bool",")",":","whether","shuffle","data","drop_last","(","bool",")",":","whether","drop","last","batch","<","batch_size","input_size","(","int",")",":","reshape","flatten","rows","as","this","input_size","(","backward","compatibility",")"]
code: def _prepare_seg(self, slc, **kwargs):
      fn = _get_date_parse_fn(self._index[0][1])
      if isinstance(slc, slice):
          start, stop = slc.start, slc.stop
      elif isinstance(slc, (list, tuple)):
          start, stop = slc
      else:
          raise NotImplementedError(
              f"This type of input is not supported"
          )
      start_date = pd.Timestamp(fn(start))
      end_date = pd.Timestamp(fn(stop))
      obj = copy.copy(self)  # shallow copy
      # NOTE: Seriable will disable copy `self._data` so we manually assign them here
      obj._data = self._data  # reference (no copy)
      obj._label = self._label
      obj._index = self._index
      obj._memory = self._memory
      obj._zeros = self._zeros
      # update index for this batch
      date_index = self._index.get_level_values(1)
      obj._batch_slices = self._batch_slices[
          (date_index >= start_date) & (date_index <= end_date)
      ]
      mask = (self._daily_index.values >= start_date) & (
          self._daily_index.values <= end_date
      )
      obj._daily_slices = self._daily_slices[mask]
      obj._daily_index = self._daily_index[mask]
      return obj
  
imports: import copy
  import torch
  import warnings
  import numpy
  import pandas
  from qlib.data.dataset import DatasetH
label_desc: Use image node_id 3 for calling the MTSDatasetH obj's underlying member method code with example usage: obj._prepare_seg(slc) and returns: obj