docstr: Collects plots definitions and data sources.
  
  Generator yielding a structure like:
      {
          revision:
          {
              "definitions":
              {
                  "data":
                  {
                      "config_file":
                      {
                          "data":
                          {
                              plot_id:
                              {
                                  plot_config
                              }
                          }
                      }
                  }
              },
              "sources":
              {
                  "data":
                  {
                      "filename":
                      {
                          "data_source": callable loading the data,
                          "props": properties for the file if it is
                                   plots type output
                      }
                  }
              }
          }
  
      }
code: def collect(
      self,
      targets: Optional[List[str]] = None,
      revs: Optional[List[str]] = None,
      recursive: bool = False,
      onerror: Optional[Callable] = None,
      props: Optional[Dict] = None,
  ) -> Iterator[Dict]:
      """Collects plots definitions and data sources.
  
      Generator yielding a structure like:
          {
              revision:
              {
                  "definitions":
                  {
                      "data":
                      {
                          "config_file":
                          {
                              "data":
                              {
                                  plot_id:
                                  {
                                      plot_config
                                  }
                              }
                          }
                      }
                  },
                  "sources":
                  {
                      "data":
                      {
                          "filename":
                          {
                              "data_source": callable loading the data,
                              "props": properties for the file if it is
                                       plots type output
                          }
                      }
                  }
              }
  
          }
      """
      from dvc.repo.experiments.brancher import switch_repo
      from dvc.utils.collections import ensure_list
  
      targets = ensure_list(targets)
      targets = [
          self.repo.dvcfs.from_os_path(target) for target in targets
      ]
  
      if revs is None:
          revs = ["workspace"]
      else:
          revs = list(revs)
          if "workspace" in revs:
              # reorder revs to match repo.brancher ordering
              revs.remove("workspace")
              revs = ["workspace", *revs]
      for rev in revs:
          with switch_repo(self.repo, rev) as (repo, _):
              res: Dict = {}
              definitions = _collect_definitions(
                  repo,
                  targets=targets,
                  revision=rev,
                  onerror=onerror,
                  props=props,
              )
              if definitions:
                  res[rev] = {"definitions": definitions}
  
                  data_targets = _get_data_targets(definitions)
  
                  res[rev]["sources"] = self._collect_data_sources(
                      repo,
                      targets=data_targets,
                      recursive=recursive,
                      props=props,
                      onerror=onerror,
                  )
              yield res
  
imports: import csv
  import io
  import os
  from collections import defaultdict
  from copy import deepcopy
  from functools import partial
  from multiprocessing import cpu_count
  from typing import TYPE_CHECKING, Any, Callable, Dict, Iterator, List, Optional, Set, Union
  import dpath
  import dpath.options
  from funcy import first, ldistinct, project, reraise
  from dvc.exceptions import DvcException
  from dvc.log import logger
  from dvc.utils import error_handler, errored_revisions
  from dvc.utils.objects import cached_property
  from dvc.utils.serialize import PARSERS, EncodingError
  from dvc.utils.threadpool import ThreadPoolExecutor
  from dvc_render.image import ImageRenderer
label_desc: Use image node_id 2 for calling the Plots obj's underlying member method code with example usage: obj.collect(targets, revs, recursive, onerror, props) without return types