code: def upload_output_directory(url):
      if url is None:
          yield None, None
          return
  
      protocol, _ = split_protocol(url)
      if protocol is not None:
          # To avoid extra network load, write all output files locally at runtime,
          # then upload to the remote fs at the end.
          with tempfile.TemporaryDirectory() as tmpdir:
              fs, remote_path = get_fs_and_path(url)
  
              # In cases where we are resuming from a previous run, we first need to download
              # the artifacts from the remote filesystem
              if path_exists(url):
                  fs.get(url, tmpdir + "/", recursive=True)
  
              def put_fn():
                  # Use pyarrow API here as fs.put() is inconsistent in where it uploads the file
                  # See: https://github.com/fsspec/filesystem_spec/issues/1062
                  pyarrow.fs.copy_files(
                      tmpdir,
                      remote_path,
                      destination_filesystem=pyarrow.fs.PyFileSystem(
                          pyarrow.fs.FSSpecHandler(fs)
                      ),
                  )
  
              # Write to temp directory locally
              yield tmpdir, put_fn
  
              # Upload to remote when finished
              put_fn()
      else:
          makedirs(url, exist_ok=True)
          # Just use the output directory directly if using a local filesystem
          yield url, None
  
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 24 for calling a global function with example usage: upload_output_directory(url) without return types