docstr: Collect different artifacts based on recorder after filtering.
  
  Args:
      artifacts_key (str or List, optional): the artifacts key you want to get. If None, use the default.
      rec_filter_func (Callable, optional): filter the recorder by return True or False. If None, use the default.
      only_exist (bool, optional): if only collect the artifacts when a recorder really has.
          If True, the recorder with exception when loading will not be collected. But if False, it will raise the exception.
  
  Returns:
      dict: the dict after collected like {artifact: {rec_key: object}}
docstr_tok: ["Collect","different","artifacts","based","on","recorder","after","filtering",".","Args",":","artifacts_key","(","str","or","List",",","optional",")",":","the","artifacts","key","you","want","to","get",".","If","None",",","use","the","default",".","rec_filter_func","(","Callable",",","optional",")",":","filter","the","recorder","by","return","True","or","False",".","If","None",",","use","the","default",".","only_exist","(","bool",",","optional",")",":","if","only","collect","the","artifacts","when","a","recorder","really","has",".","If","True",",","the","recorder","with","exception","when","loading","will","not","be","collected",".","But","if","False",",","it","will","raise","the","exception",".","Returns",":","dict",":","the","dict","after","collected","like","{","artifact",":","{","rec_key",":","object","}","}"]
code: def collect(
      self, artifacts_key=None, rec_filter_func=None, only_exist=True
  ) -> dict:
      """
      Collect different artifacts based on recorder after filtering.
  
      Args:
          artifacts_key (str or List, optional): the artifacts key you want to get. If None, use the default.
          rec_filter_func (Callable, optional): filter the recorder by return True or False. If None, use the default.
          only_exist (bool, optional): if only collect the artifacts when a recorder really has.
              If True, the recorder with exception when loading will not be collected. But if False, it will raise the exception.
  
      Returns:
          dict: the dict after collected like {artifact: {rec_key: object}}
      """
      if artifacts_key is None:
          artifacts_key = self.artifacts_key
      if rec_filter_func is None:
          rec_filter_func = self.rec_filter_func
  
      if isinstance(artifacts_key, str):
          artifacts_key = [artifacts_key]
  
      collect_dict = {}
      # filter records
  
      if isinstance(self.experiment, Experiment):
          with TimeInspector.logt(
              "Time to `list_recorders` in RecorderCollector"
          ):
              recs = list(
                  self.experiment.list_recorders(
                      **self.list_kwargs
                  ).values()
              )
      elif isinstance(self.experiment, Callable):
          recs = self.experiment()
  
      recs = [
          rec
          for rec in recs
          if (
              (self.status is None or rec.status in self.status)
              and (rec_filter_func is None or rec_filter_func(rec))
          )
      ]
  
      logger = get_module_logger("RecorderCollector")
      status_stat = defaultdict(int)
      for r in recs:
          status_stat[r.status] += 1
      logger.info(f"Nubmer of recorders after filter: {status_stat}")
      for rec in recs:
          rec_key = self.rec_key_func(rec)
          for key in artifacts_key:
              if self.ART_KEY_RAW == key:
                  artifact = rec
              else:
                  try:
                      artifact = rec.load_object(
                          self.artifacts_path[key]
                      )
                  except LoadObjectError as e:
                      if only_exist:
                          # only collect existing artifact
                          logger.warning(
                              f"Fail to load {self.artifacts_path[key]} and it is ignored."
                          )
                          continue
                      raise e
              # give user some warning if the values are overridden
              cdd = collect_dict.setdefault(key, {})
              if rec_key in cdd:
                  logger.warning(
                      f"key '{rec_key}' is duplicated. Previous value will be overrides. Please check you `rec_key_func`"
                  )
              cdd[rec_key] = artifact
  
      return collect_dict
  
imports: from collections import defaultdict
  from qlib.log import TimeInspector
  from typing import Callable, Dict, Iterable, List
  from qlib.log import get_module_logger
  from qlib.utils.serial import Serializable
  from qlib.utils.exceptions import LoadObjectError
  from qlib.workflow import R
  from qlib.workflow.exp import Experiment
  from qlib.workflow.recorder import Recorder
label_desc: Use image node_id 2 for calling the RecorderCollector obj's underlying member method code with example usage: obj.collect(artifacts_key, rec_filter_func, only_exist) and returns: collect_dict