code: def collect(
      repo: "Repo",
      revs: Union[List[str], str, None] = None,
      all_branches: bool = False,
      all_tags: bool = False,
      all_commits: bool = False,
      num: int = 1,
      hide_queued: bool = False,
      hide_failed: bool = False,
      sha_only: bool = False,
      **kwargs,
  ) -> List["ExpState"]:
      """Collect baseline revisions and derived experiments."""
      assert isinstance(repo.scm, Git)
      if repo.scm.no_commits:
          return []
      if not any([revs, all_branches, all_tags, all_commits]):
          revs = ["HEAD"]
      if isinstance(revs, str):
          revs = [revs]
      cached_refs = list(repo.scm.iter_refs())
      baseline_revs = list(
          iter_revs(
              repo.scm,
              revs=revs,
              num=num,
              all_branches=all_branches,
              all_tags=all_tags,
              all_commits=all_commits,
          )
      )
      if sha_only:
          baseline_names: Dict[str, Optional[str]] = {}
      else:
          baseline_names = describe(
              repo.scm, baseline_revs, refs=cached_refs, logger=logger
          )
  
      workspace_data = collect_rev(repo, "workspace", **kwargs)
      result: List["ExpState"] = [workspace_data]
      queued = (
          collect_queued(repo, baseline_revs, **kwargs)
          if not hide_queued
          else {}
      )
      active = collect_active(repo, baseline_revs, **kwargs)
      failed = (
          collect_failed(repo, baseline_revs, **kwargs)
          if not hide_failed
          else {}
      )
      successful = collect_successful(repo, baseline_revs, **kwargs)
  
      for baseline_rev in baseline_revs:
          baseline_data = collect_rev(repo, baseline_rev)
          experiments = list(
              itertools.chain.from_iterable(
                  _sorted_ranges(collected.get(baseline_rev, []))
                  for collected in (active, successful, queued, failed)
              )
          )
          result.append(
              ExpState(
                  rev=baseline_rev,
                  name=baseline_names.get(baseline_rev),
                  data=baseline_data.data,
                  error=baseline_data.error,
                  experiments=experiments if experiments else None,
              )
          )
      return result
  
imports: import itertools
  import os
  from dataclasses import fields
  from datetime import datetime
  from typing import TYPE_CHECKING, Collection, Dict, Iterable, Iterator, List, Optional, Tuple, Union
  from funcy import first
  from scmrepo.exceptions import SCMError
  from dvc.log import logger
  from dvc.scm import Git, SCMError, iter_revs
  from .exceptions import InvalidExpRefError
  from .refs import EXEC_BRANCH, ExpRefInfo
  from .serialize import ExpRange, ExpState, SerializableError, SerializableExp
  from .utils import describe
label_desc: Use image node_id 10 for calling a global function with example usage: collect(repo, revs, all_branches, all_tags, all_commits, num, hide_queued, hide_failed, sha_only) and returns: result, list