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 _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 = fn(start)
      end_date = 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
      obj._label = self._label
      obj._index = self._index
      new_batch_slices = []
      for batch_slc in self.batch_slices:
          date = self._index[batch_slc.stop - 1][1]
          if start_date <= date <= end_date:
              new_batch_slices.append(batch_slc)
      obj.batch_slices = np.array(new_batch_slices)
      new_daily_slices = []
      for daily_slc in self.daily_slices:
          date = self._index[daily_slc[0].stop - 1][1]
          if start_date <= date <= end_date:
              new_daily_slices.append(daily_slc)
      obj.daily_slices = new_daily_slices
      return obj
  
imports: import copy
  import torch
  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