class_docstr: Meta Task for Data Selection
class_docstr_tok: ["Meta","Task","for","Data","Selection"]
docstr: The description of the processed data
  
      time_perf: A array with shape  <hist_step_n * step, data pieces>  ->  data piece performance
  
      time_belong:  A array with shape <sample, data pieces>  -> belong or not (1. or 0.)
      array([[1., 0., 0., ..., 0., 0., 0.],
             [1., 0., 0., ..., 0., 0., 0.],
             [1., 0., 0., ..., 0., 0., 0.],
             ...,
             [0., 0., 0., ..., 0., 0., 1.],
             [0., 0., 0., ..., 0., 0., 1.],
             [0., 0., 0., ..., 0., 0., 1.]])
  
  Parameters
  ----------
  meta_info: pd.DataFrame
      please refer to the docs of _prepare_meta_ipt for detailed explanation.
docstr_tok: ["The","description","of","the","processed","data","time_perf",":","A","array","with","shape","<","hist_step_n","*","step",",","data","pieces",">","-",">","data","piece","performance","time_belong",":","A","array","with","shape","<","sample",",","data","pieces",">","-",">","belong","or","not","(","1.","or","0",".",")","array","(","[","[","1.",",","0.",",","0.",",","...",",","0.",",","0.",",","0",".","]",",","[","1.",",","0.",",","0.",",","...",",","0.",",","0.",",","0",".","]",",","[","1.",",","0.",",","0.",",","...",",","0.",",","0.",",","0",".","]",",","...",",","[","0.",",","0.",",","0.",",","...",",","0.",",","0.",",","1",".","]",",","[","0.",",","0.",",","0.",",","...",",","0.",",","0.",",","1",".","]",",","[","0.",",","0.",",","0.",",","...",",","0.",",","0.",",","1",".","]","]",")","Parameters","--","--","--","--","--","meta_info",":","pd.DataFrame","please","refer","to","the","docs","of","_prepare_meta_ipt","for","detailed","explanation","."]
code: def __init__(
      self,
      task: dict,
      meta_info: pd.DataFrame,
      mode: str = MetaTask.PROC_MODE_FULL,
      fill_method="max",
  ):
      """
  
      The description of the processed data
  
          time_perf: A array with shape  <hist_step_n * step, data pieces>  ->  data piece performance
  
          time_belong:  A array with shape <sample, data pieces>  -> belong or not (1. or 0.)
          array([[1., 0., 0., ..., 0., 0., 0.],
                 [1., 0., 0., ..., 0., 0., 0.],
                 [1., 0., 0., ..., 0., 0., 0.],
                 ...,
                 [0., 0., 0., ..., 0., 0., 1.],
                 [0., 0., 0., ..., 0., 0., 1.],
                 [0., 0., 0., ..., 0., 0., 1.]])
  
      Parameters
      ----------
      meta_info: pd.DataFrame
          please refer to the docs of _prepare_meta_ipt for detailed explanation.
      """
      super().__init__(task, meta_info)
      self.fill_method = fill_method
  
      time_perf = self._get_processed_meta_info()
      self.processed_meta_input = {"time_perf": time_perf}
      # FIXME: memory issue in this step
      if mode == MetaTask.PROC_MODE_FULL:
          # process metainfo_
          ds = self.get_dataset()
  
          # these three lines occupied 70% of the time of initializing MetaTaskDS
          d_train, d_test = ds.prepare(
              ["train", "test"], col_set=["feature", "label"]
          )
          prev_size = d_test.shape[0]
          d_train = d_train.dropna(axis=0)
          d_test = d_test.dropna(axis=0)
          if prev_size == 0 or d_test.shape[0] / prev_size <= 0.1:
              raise ValueError(
                  f"Most of samples are dropped. Please check this task: {task}"
              )
  
          assert (
              d_test.groupby("datetime").size().shape[0] >= 5
          ), "In this segment, this trading dates is less than 5, you'd better check the data."
  
          sample_time_belong = np.zeros(
              (d_train.shape[0], time_perf.shape[1])
          )
          for i, col in enumerate(time_perf.columns):
              # these two lines of code occupied 20% of the time of initializing MetaTaskDS
              slc = slice(
                  *d_train.index.slice_locs(start=col[0], end=col[1])
              )
              sample_time_belong[slc, i] = 1.0
  
          # If you want that last month also belongs to the last time_perf
          # Assumptions: the latest data has similar performance like the last month
          sample_time_belong[
              sample_time_belong.sum(axis=1) != 1, -1
          ] = 1.0
  
          self.processed_meta_input.update(
              dict(
                  X=d_train["feature"],
                  y=d_train["label"].iloc[:, 0],
                  X_test=d_test["feature"],
                  y_test=d_test["label"].iloc[:, 0],
                  time_belong=sample_time_belong,
                  test_idx=d_test["label"].index,
              )
          )
  
      # TODO: set device: I think this is not necessary to converting data format.
      self.processed_meta_input = data_to_tensor(
          self.processed_meta_input
      )
  
imports: import pandas
  import numpy
  from copy import deepcopy
  from joblib import Parallel, delayed
  from typing import Dict, List, Union, Text, Tuple
  from qlib.data.dataset.utils import init_task_handler
  from qlib.data.dataset import DatasetH
  from qlib.contrib.torch import data_to_tensor
  from qlib.model.meta.task import MetaTask
  from qlib.model.meta.dataset import MetaTaskDataset
  from qlib.model.trainer import TrainerR
  from qlib.log import get_module_logger
  from qlib.utils import auto_filter_kwargs, get_date_by_shift, init_instance_by_config
  from qlib.utils.data import deepcopy_basic_type
  from qlib.workflow import R
  from qlib.workflow.task.gen import RollingGen, task_generator
  from qlib.workflow.task.utils import TimeAdjuster
  from tqdm.auto import tqdm
label_desc: Use image node_id 1 to create a new MetaTaskDS object from inherited base classes: MetaTask with example: obj = MetaTaskDS(task, meta_info, mode, fill_method)