code: def push(
      repo: "Repo",
      git_remote: str,
      exp_names: Optional[Union[List[str], str]] = None,
      all_commits: bool = False,
      rev: Optional[Union[List[str], str]] = None,
      num: int = 1,
      force: bool = False,
      push_cache: bool = False,
      **kwargs: Any,
  ) -> Dict[str, Any]:
      exp_ref_set: Set["ExpRefInfo"] = set()
      assert isinstance(repo.scm, Git)
      if all_commits:
          exp_ref_set.update(exp_refs(repo.scm))
      if exp_names:
          exp_ref_set.update(
              exp_refs_from_names(repo.scm, ensure_list(exp_names))
          )
      else:
          rev = rev or "HEAD"
          if isinstance(rev, str):
              rev = [rev]
          exp_ref_set.update(exp_refs_from_rev(repo.scm, rev, num=num))
  
      push_result = _push(repo, git_remote, exp_ref_set, force)
  
      refs = {
          status.name.lower(): [ref.name for ref in ref_list]
          for status, ref_list in push_result.items()
      }
      result: Dict[str, Any] = {**refs, "uploaded": 0}
  
      pushed_refs_info = (
          push_result[SyncStatus.UP_TO_DATE]
          + push_result[SyncStatus.SUCCESS]
      )
  
      e = None
      if push_cache:
          try:
              result["uploaded"] = _push_cache(
                  repo, pushed_refs_info, **kwargs
              )
          except Exception as exc:  # noqa: BLE001
              e = exc
  
      pushed_refs = [str(r) for r in pushed_refs_info]
      result["url"] = notify_refs_to_studio(
          repo, git_remote, pushed=pushed_refs
      )
  
      if e:
          raise UploadError("failed to push cache", result) from e
      return result
  
imports: from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Mapping, Optional, Set, Union
  from funcy import compact, group_by
  from scmrepo.git.backend.base import SyncStatus
  from dvc.env import DVC_STUDIO_TOKEN, DVC_STUDIO_URL
  from dvc.exceptions import DvcException
  from dvc.log import logger
  from dvc.repo import locked
  from dvc.repo.scm_context import scm_context
  from dvc.scm import Git, TqdmGit, iter_revs
  from dvc.utils import env2bool
  from dvc.utils.collections import ensure_list
  from .exceptions import UnresolvedExpNamesError
  from .refs import ExpRefInfo
  from .utils import exp_commits, exp_refs, exp_refs_by_baseline, resolve_name
label_desc: Use image node_id 4 for calling a global function with example usage: push(repo, git_remote, exp_names, all_commits, rev, num, force, push_cache) and returns: result