code: def exp_commits(
      scm: "Git", ref_infos: Optional[Iterable[ExpRefInfo]] = None
  ) -> Iterable[str]:
      """Iterate over all experiment commits."""
      shas: Set["str"] = set()
      refs = ref_infos if ref_infos else exp_refs(scm)
      for ref_info in refs:
          shas.update(
              scm.branch_revs(str(ref_info), ref_info.baseline_sha)
          )
      yield from shas
  
imports: import os
  import random
  import sys
  from collections import defaultdict
  from functools import wraps
  from typing import TYPE_CHECKING, Callable, Dict, Generator, Iterable, List, Mapping, Optional, Set, Tuple, Union
  from dvc.exceptions import InvalidArgumentError
  from dvc.repo.experiments.exceptions import AmbiguousExpRefInfo
  from dvc.rwlock import rwlock
  from dvc.scm import Git
  from .refs import EXEC_APPLY, EXEC_BASELINE, EXEC_BRANCH, EXPS_NAMESPACE, ITER_SKIP_NAMESPACES, STASHES, ExpRefInfo
label_desc: Use image node_id 12 for calling a global function with example usage: exp_commits(scm, ref_infos) without return types