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: Parameters
  ----------
  dataset : DatasetH
      DatasetH: the instance of DatasetH. None for prepare it again.
  write : bool
      will the the write action be executed
  ret_new : bool
      will the updated data be returned
  
  Returns
  -------
  Optional[object]
      the updated dataset
docstr_tok: ["Parameters","--","--","--","--","--","dataset",":","DatasetH","DatasetH",":","the","instance","of","DatasetH",".","None","for","prepare","it","again",".","write",":","bool","will","the","the","write","action","be","executed","ret_new",":","bool","will","the","updated","data","be","returned","Returns","--","--","--","-","Optional","[","object","]","the","updated","dataset"]
code: def update(
      self,
      dataset: DatasetH = None,
      write: bool = True,
      ret_new: bool = False,
  ) -> Optional[object]:
      """
      Parameters
      ----------
      dataset : DatasetH
          DatasetH: the instance of DatasetH. None for prepare it again.
      write : bool
          will the the write action be executed
      ret_new : bool
          will the updated data be returned
  
      Returns
      -------
      Optional[object]
          the updated dataset
      """
      # FIXME: the problem below is not solved
      # The model dumped on GPU instances can not be loaded on CPU instance. Follow exception will raised
      # RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.
      # https://github.com/pytorch/pytorch/issues/16797
  
      if self.last_end >= self.to_date:
          self.logger.info(
              f"The data in {self.record.info['id']} are latest ({self.last_end}). No need to update to {self.to_date}."
          )
          return
  
      # load dataset
      if dataset is None:
          # For reusing the dataset
          dataset = self.prepare_data()
  
      updated_data = self.get_update_data(dataset)
  
      if write:
          self.record.save_objects(**{self.fname: updated_data})
      if ret_new:
          return updated_data
  
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 3 for calling the DSBasedUpdater obj's underlying member method code with example usage: obj.update(dataset, write, ret_new) and returns: updated_data