code: def safe_move_directory(src, dst):
      """Recursively moves files from src directory to dst directory and removes src directory.
  
      If dst directory does not exist, it will be created.
      """
      try:
          os.replace(src, dst)
      except OSError as err:
          if err.errno == errno.EXDEV:
              # Generate a unique ID, and copy `<src>` to the target directory with a temporary name `<dst>.<ID>.tmp`.
              # Because we're copying across a filesystem boundary, this initial copy may not be atomic.  We insert a
              # random UUID so if different processes are copying into `<dst>`, they don't overlap in their tmp copies.
              copy_id = uuid.uuid4()
              tmp_dst = f"{dst}.{copy_id}.tmp"
              shutil.copytree(src, tmp_dst)
  
              # Atomic replace directory name onto the new name, and clean up original source directory.
              os.replace(tmp_dst, dst)
              os.unlink(src)
          else:
              raise
  
imports: import contextlib
  import errno
  import functools
  import logging
  import os
  import pathlib
  import shutil
  import tempfile
  import uuid
  from typing import List, Optional
  from urllib.parse import unquote, urlparse
  import certifi
  import fsspec
  import h5py
  import pyarrow.fs
  import urllib3
  from filelock import FileLock
  from fsspec.core import split_protocol
  from ludwig.api_annotations import DeveloperAPI
label_desc: Use image node_id 14 for calling a global function with example usage: safe_move_directory(src, dst) without return types