class_docstr: The meta-model for meta-learning-based data selection.
class_docstr_tok: ["The","meta-model","for","meta-learning-based","data","selection","."]
docstr: The meta-learning-based data selection interacts directly with meta-dataset due to the close-form proxy measurement.
  
  Parameters
  ----------
  meta_dataset : MetaDatasetDS
      The meta-model takes the meta-dataset for its training process.
docstr_tok: ["The","meta-learning-based","data","selection","interacts","directly","with","meta-dataset","due","to","the","close-form","proxy","measurement",".","Parameters","--","--","--","--","--","meta_dataset",":","MetaDatasetDS","The","meta-model","takes","the","meta-dataset","for","its","training","process","."]
code: def fit(self, meta_dataset: MetaDatasetDS):
      """
      The meta-learning-based data selection interacts directly with meta-dataset due to the close-form proxy measurement.
  
      Parameters
      ----------
      meta_dataset : MetaDatasetDS
          The meta-model takes the meta-dataset for its training process.
      """
  
      if not self.fitted:
          for k in set(
              [
                  "lr",
                  "step",
                  "hist_step_n",
                  "clip_method",
                  "clip_weight",
                  "criterion",
                  "max_epoch",
              ]
          ):
              R.log_params(**{k: getattr(self, k)})
  
      # FIXME: get test tasks for just checking the performance
      phases = ["train", "test"]
      meta_tasks_l = meta_dataset.prepare_tasks(phases)
  
      if len(meta_tasks_l[1]):
          R.log_params(
              **dict(
                  proxy_test_begin=meta_tasks_l[1][0].task["dataset"][
                      "kwargs"
                  ]["segments"]["test"]
              )
          )  # debug: record when the test phase starts
  
      self.tn = PredNet(
          step=self.step,
          hist_step_n=self.hist_step_n,
          clip_weight=self.clip_weight,
          clip_method=self.clip_method,
          alpha=self.alpha,
      )
  
      opt = optim.Adam(self.tn.parameters(), lr=self.lr)
  
      # run weight with no weight
      for phase, task_list in zip(phases, meta_tasks_l):
          self.run_epoch(
              f"{phase}_noweight",
              task_list,
              0,
              opt,
              {},
              ignore_weight=True,
          )
          self.run_epoch(f"{phase}_init", task_list, 0, opt, {})
  
      # run training
      loss_l = {}
      for epoch in tqdm(range(self.max_epoch), desc="epoch"):
          for phase, task_list in zip(phases, meta_tasks_l):
              self.run_epoch(phase, task_list, epoch, opt, loss_l)
          R.save_objects(**{"model.pkl": self.tn})
      self.fitted = True
  
imports: import pandas
  import numpy
  import torch
  from torch import nn
  from torch import optim
  from tqdm.auto import tqdm
  import copy
  from typing import Union, List
  from ....model.meta.dataset import MetaTaskDataset
  from ....model.meta.model import MetaTaskModel
  from ....workflow import R
  from .utils import ICLoss
  from .dataset import MetaDatasetDS
  from qlib.log import get_module_logger
  from qlib.model.meta.task import MetaTask
  from qlib.data.dataset.weight import Reweighter
  from qlib.contrib.meta.data_selection.net import PredNet
label_desc: Use image node_id 3 for calling the MetaModelDS obj's underlying member method code with example usage: obj.fit(meta_dataset) without return types