code: def download_file(
      url: str,
      *,
      filename: Optional[str] = None,
      dirpath: types.PathLike = constants.DEFAULT_DATA_DIR,
      force: bool = False,
  ) -> Optional[str]:
      """
      Download a file from ``url`` and save it to disk.
  
      Args:
          url: Web address from which to download data.
          filename: Name of the file to which downloaded data is saved.
              If None, a filename will be inferred from the ``url``.
          dirpath: Full path to the directory on disk
              under which downloaded data will be saved as ``filename``.
          force: If True, download the data even if it already exists at
              ``dirpath/filename``; otherwise, only download if the data doesn't
              already exist on disk.
  
      Returns:
          Full path of file saved to disk.
      """
      if not filename:
          filename = get_filename_from_url(url)
      filepath = utils.to_path(dirpath).resolve() / filename
      if filepath.is_file() and force is False:
          LOGGER.info(
              "file '%s' already exists and force=False; skipping download...",
              filepath,
          )
          return None
      else:
          write_http_stream(url, filepath, mode="wb", make_dirs=True)
      return str(filepath)
  
imports: from __future__ import annotations
  import bz2
  import gzip
  import io
  import itertools
  import logging
  import lzma
  import os
  import re
  import shutil
  import tarfile
  import urllib
  import zipfile
  from typing import IO, Iterable, Literal, Optional
  from cytoolz import itertoolz
  from ..None import constants
  from ..None import errors
  from ..None import types, utils
  from .http import write_http_stream
label_desc: Use image node_id 11 for calling a global function with example usage: download_file(url) and returns: str, None