code: def _format_clone_errors(
      destds: Dataset, error_msgs: List, last_clone_url: str
  ) -> Tuple:
      """Format all accumulated clone errors across candidates into one message
  
      Returns
      -------
      (str, list)
        Message body and string formatting arguments for it.
      """
      if len(error_msgs):
          if all(
              not e.stdout and not e.stderr for e in error_msgs.values()
          ):
              # there is nothing we can learn from the actual exception,
              # the exit code is uninformative, the command is predictable
              error_msg = (
                  "Failed to clone from all attempted sources: %s"
              )
              error_args = list(error_msgs.keys())
          else:
              error_msg = (
                  "Failed to clone from any candidate source URL. "
                  "Encountered errors per each url were:\n- %s"
              )
              error_args = "\n- ".join(
                  "{}\n  {}".format(url, exc.to_str())
                  for url, exc in error_msgs.items()
              )
      else:
          # yoh: Not sure if we ever get here but I felt that there could
          #      be a case when this might happen and original error would
          #      not be sufficient to troubleshoot what is going on.
          error_msg = (
              "Awkward error -- we failed to clone properly. "
              "Although no errors were encountered, target "
              "dataset at %s seems to be not fully installed. "
              "The 'succesful' source was: %s"
          )
          error_args = (destds.path, last_clone_url)
      return error_msg, error_args
  
imports: import logging
  import re
  from os.path import expanduser
  from pathlib import Path
  from typing import Dict, List, Tuple
  from urllib.parse import unquote
  from datalad.cmd import CommandError, GitWitlessRunner, StdOutCapture
  from datalad.config import ConfigManager
  from datalad.distributed.ora_remote import LocalIO, RIARemoteError, SSHRemoteIO
  from datalad.distribution.dataset import Dataset
  from datalad.distribution.utils import _get_flexible_source_candidates
  from datalad.dochelpers import single_or_plural
  from datalad.log import log_progress
  from datalad.runner.exception import CommandError
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.exceptions import CapturedException, DownloadError
  from datalad.support.gitrepo import GitRepo
  from datalad.support.network import RI, SSHRI, URL, DataLadRI, download_url, get_local_file_url, is_url
  from datalad.support.strings import get_replacement_dict
  from datalad.utils import Path, PurePosixPath, ensure_bool, ensure_list, make_tempfile, rmtree
label_desc: Use image node_id 13 for calling a global function with example usage: _format_clone_errors(destds, error_msgs, last_clone_url) and returns: error_msg,  error_args