code: def describe(
      scm: "Git",
      revs: Iterable[str],
      logger,
      refs: Optional[Iterable[str]] = None,
  ) -> Dict[str, Optional[str]]:
      """Describe revisions using a tag, branch.
  
      The first matching name will be returned for each rev. Names are preferred in this
      order:
          - current branch (if rev matches HEAD and HEAD is a branch)
          - tags
          - branches
  
      Returns:
          Dict mapping revisions from revs to a name.
      """
  
      head_rev = scm.get_rev()
      head_ref = scm.get_ref("HEAD", follow=False)
      if head_ref and head_ref.startswith("refs/heads/"):
          head_branch = head_ref[len("refs/heads/") :]
      else:
          head_branch = None
  
      tags = {}
      branches = {}
      ref_it = iter(refs) if refs else scm.iter_refs()
      for ref in ref_it:
          is_tag = ref.startswith("refs/tags/")
          is_branch = ref.startswith("refs/heads/")
          if not (is_tag or is_branch):
              continue
          rev = scm.get_ref(ref)
          if not rev:
              logger.debug("unresolved ref %s", ref)
              continue
          if is_tag and rev not in tags:
              tags[rev] = ref[len("refs/tags/") :]
          if is_branch and rev not in branches:
              branches[rev] = ref[len("refs/heads/") :]
  
      names: Dict[str, Optional[str]] = {}
      for rev in revs:
          if rev == head_rev and head_branch:
              names[rev] = head_branch
          else:
              names[rev] = tags.get(rev) or branches.get(rev)
  
      return names
  
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 21 for calling a global function with example usage: describe(scm, revs, logger, refs) and returns: names