code: def push_refspec(
      scm: "Git",
      url: str,
      push_list=List[Tuple[Optional[str], str]],
      force: bool = False,
      on_diverged: Optional[Callable[[str, str], bool]] = None,
      **kwargs,
  ):
      from scmrepo.exceptions import AuthError
      from scmrepo.git.backend.base import SyncStatus
  
      from dvc.scm import GitAuthError, SCMError
  
      refspecs = []
      for src, dest in push_list:
          if not src:
              refspecs.append(f":{dest}")
          elif src.endswith("/"):
              dest = dest.rstrip("/") + "/"
              for ref in scm.iter_refs(base=src):
                  refname = ref.split("/")[-1]
                  refspecs.append(f"{ref}:{dest}{refname}")
          elif dest.endswith("/"):
              refname = src.split("/")[-1]
              refspecs.append(f"{src}:{dest}/{refname}")
          else:
              refspecs.append(f"{src}:{dest}")
  
      try:
          results = scm.push_refspecs(
              url,
              refspecs,
              force=force,
              on_diverged=on_diverged,
              **kwargs,
          )
          diverged = [
              ref
              for ref in results
              if results[ref] == SyncStatus.DIVERGED
          ]
  
          if diverged:
              raise SCMError(
                  f"local ref '{diverged}' diverged from remote '{url}'"
              )
      except AuthError as exc:
          raise GitAuthError(str(exc))
  
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 8 for calling a global function with example usage: push_refspec(scm, url, push_list, force, on_diverged) without return types