class_docstr: Trainer based on (R)ecorder and Task(M)anager.
  It can train a list of tasks and return a list of model recorders in a multiprocessing way.
  
  Assumption: `task` will be saved to TaskManager and `task` will be fetched and trained from TaskManager
class_docstr_tok: ["Trainer","based","on","(","R",")","ecorder","and","Task","(","M",")","anager",".","It","can","train","a","list","of","tasks","and","return","a","list","of","model","recorders","in","a","multiprocessing","way",".","Assumption",":","`","task","`","will","be","saved","to","TaskManager","and","`","task","`","will","be","fetched","and","trained","from","TaskManager"]
docstr: Given a list of `tasks` and return a list of trained Recorder. The order can be guaranteed.
  
  This method defaults to a single process, but TaskManager offered a great way to parallel training.
  Users can customize their train_func to realize multiple processes or even multiple machines.
  
  Args:
      tasks (list): a list of definitions based on `task` dict
      train_func (Callable): the training method which needs at least `tasks` and `experiment_name`. None for the default training method.
      experiment_name (str): the experiment name, None for use default name.
      before_status (str): the tasks in before_status will be fetched and trained. Can be STATUS_WAITING, STATUS_PART_DONE.
      after_status (str): the tasks after trained will become after_status. Can be STATUS_WAITING, STATUS_PART_DONE.
      kwargs: the params for train_func.
  
  Returns:
      List[Recorder]: a list of Recorders
docstr_tok: ["Given","a","list","of","`","tasks","`","and","return","a","list","of","trained","Recorder",".","The","order","can","be","guaranteed",".","This","method","defaults","to","a","single","process",",","but","TaskManager","offered","a","great","way","to","parallel","training",".","Users","can","customize","their","train_func","to","realize","multiple","processes","or","even","multiple","machines",".","Args",":","tasks","(","list",")",":","a","list","of","definitions","based","on","`","task","`","dict","train_func","(","Callable",")",":","the","training","method","which","needs","at","least","`","tasks","`","and","`","experiment_name","`",".","None","for","the","default","training","method",".","experiment_name","(","str",")",":","the","experiment","name",",","None","for","use","default","name",".","before_status","(","str",")",":","the","tasks","in","before_status","will","be","fetched","and","trained",".","Can","be","STATUS_WAITING",",","STATUS_PART_DONE",".","after_status","(","str",")",":","the","tasks","after","trained","will","become","after_status",".","Can","be","STATUS_WAITING",",","STATUS_PART_DONE",".","kwargs",":","the","params","for","train_func",".","Returns",":","List","[","Recorder","]",":","a","list","of","Recorders"]
code: def train(
      self,
      tasks: list,
      train_func: Callable = None,
      experiment_name: str = None,
      before_status: str = TaskManager.STATUS_WAITING,
      after_status: str = TaskManager.STATUS_DONE,
      default_rec_name: Optional[str] = None,
      **kwargs,
  ) -> List[Recorder]:
      """
      Given a list of `tasks` and return a list of trained Recorder. The order can be guaranteed.
  
      This method defaults to a single process, but TaskManager offered a great way to parallel training.
      Users can customize their train_func to realize multiple processes or even multiple machines.
  
      Args:
          tasks (list): a list of definitions based on `task` dict
          train_func (Callable): the training method which needs at least `tasks` and `experiment_name`. None for the default training method.
          experiment_name (str): the experiment name, None for use default name.
          before_status (str): the tasks in before_status will be fetched and trained. Can be STATUS_WAITING, STATUS_PART_DONE.
          after_status (str): the tasks after trained will become after_status. Can be STATUS_WAITING, STATUS_PART_DONE.
          kwargs: the params for train_func.
  
      Returns:
          List[Recorder]: a list of Recorders
      """
      if isinstance(tasks, dict):
          tasks = [tasks]
      if len(tasks) == 0:
          return []
      if train_func is None:
          train_func = self.train_func
      if experiment_name is None:
          experiment_name = self.experiment_name
      if default_rec_name is None:
          default_rec_name = self.default_rec_name
      task_pool = self.task_pool
      if task_pool is None:
          task_pool = experiment_name
      tm = TaskManager(task_pool=task_pool)
      _id_list = tm.create_task(
          tasks
      )  # all tasks will be saved to MongoDB
      query = {"_id": {"$in": _id_list}}
      if not self.skip_run_task:
          run_task(
              train_func,
              task_pool,
              query=query,  # only train these tasks
              experiment_name=experiment_name,
              before_status=before_status,
              after_status=after_status,
              recorder_name=default_rec_name,
              **kwargs,
          )
  
      if not self.is_delay():
          tm.wait(query=query)
  
      recs = []
      for _id in _id_list:
          rec = tm.re_query(_id)["res"]
          rec.set_tags(**{self.STATUS_KEY: self.STATUS_BEGIN})
          rec.set_tags(**{self.TM_ID: _id})
          recs.append(rec)
      return recs
  
imports: import socket
  from typing import Callable, List, Optional
  from tqdm.auto import tqdm
  from qlib.config import C
  from qlib.data.dataset import Dataset
  from qlib.data.dataset.weight import Reweighter
  from qlib.log import get_module_logger
  from qlib.model.base import Model
  from qlib.utils import auto_filter_kwargs, fill_placeholder, flatten_dict, init_instance_by_config
  from qlib.utils.paral import call_in_subproc
  from qlib.workflow import R
  from qlib.workflow.recorder import Recorder
  from qlib.workflow.task.manage import TaskManager, run_task
label_desc: Use image node_id 2 for calling the TrainerRM obj's underlying member method code with example usage: obj.train(tasks, train_func, experiment_name, before_status, after_status, default_rec_name) and returns: recs, list