class_docstr: Dataset-Based Updater
  
  - Providing updating feature for Updating data based on Qlib Dataset
  
  Assumption
  
  - Based on Qlib dataset
  - The data to be updated is a multi-level index pd.DataFrame. For example label, prediction.
  
      .. code-block::
  
                                   LABEL0
          datetime   instrument
          2021-05-10 SH600000    0.006965
                     SH600004    0.003407
          ...                         ...
          2021-05-28 SZ300498    0.015748
                     SZ300676   -0.001321
class_docstr_tok: ["Dataset-Based","Updater","-","Providing","updating","feature","for","Updating","data","based","on","Qlib","Dataset","Assumption","-","Based","on","Qlib","dataset","-","The","data","to","be","updated","is","a","multi-level","index","pd.DataFrame",".","For","example","label",",","prediction",".","..","code-block",":",":","LABEL0","datetime","instrument","2021-05-10","SH600000","0.006965","SH600004","0.003407","...","...","2021-05-28","SZ300498","0.015748","SZ300676","-0.001321"]
docstr: Load dataset
  - if unprepared_dataset is specified, then prepare the dataset directly
  - Otherwise,
  
  Separating this function will make it easier to reuse the dataset
  
  Returns:
      DatasetH: the instance of DatasetH
docstr_tok: ["Load","dataset","-","if","unprepared_dataset","is","specified",",","then","prepare","the","dataset","directly","-","Otherwise",",","Separating","this","function","will","make","it","easier","to","reuse","the","dataset","Returns",":","DatasetH",":","the","instance","of","DatasetH"]
code: def prepare_data(
      self, unprepared_dataset: Optional[DatasetH] = None
  ) -> DatasetH:
      """
      Load dataset
      - if unprepared_dataset is specified, then prepare the dataset directly
      - Otherwise,
  
      Separating this function will make it easier to reuse the dataset
  
      Returns:
          DatasetH: the instance of DatasetH
      """
      # automatically getting the historical dependency if not specified
      if self.hist_ref is None:
          dataset: DatasetH = (
              self.record.load_object("dataset")
              if unprepared_dataset is None
              else unprepared_dataset
          )
          # Special treatment of historical dependencies
          if isinstance(dataset, TSDatasetH):
              hist_ref = dataset.step_len - 1
          else:
              hist_ref = 0  # if only the lastest data is used, then only current data will be used and no historical data will be used
      else:
          hist_ref = self.hist_ref
  
      start_time_buffer = get_date_by_shift(
          self.last_end,
          -hist_ref + 1,
          clip_shift=False,
          freq=self.freq,  # pylint: disable=E1130
      )
      start_time = get_date_by_shift(self.last_end, 1, freq=self.freq)
      seg = {"test": (start_time, self.to_date)}
      return self.rmdl.get_dataset(
          start_time=start_time_buffer,
          end_time=self.to_date,
          segments=seg,
          unprepared_dataset=unprepared_dataset,
      )
  
imports: from abc import ABCMeta, abstractmethod
  from typing import Optional
  import pandas
  from qlib import get_module_logger
  from qlib.data import D
  from qlib.data.dataset import Dataset, DatasetH, TSDatasetH
  from qlib.data.dataset.handler import DataHandlerLP
  from qlib.model import Model
  from qlib.utils import get_date_by_shift
  from qlib.workflow.recorder import Recorder
  from qlib.workflow.record_temp import SignalRecord
label_desc: Use image node_id 2 for calling the DSBasedUpdater obj's underlying member method code with example usage: obj.prepare_data(unprepared_dataset) and returns: self