code: def download(
      url,
      path=None,
      overwrite=False,
      sha1_hash=None,
      retries=5,
      verify_ssl=True,
  ):
      """Download a given URL
  
      Parameters
      ----------
      url : str
          URL to download
      path : str, optional
          Destination path to store downloaded file. By default stores to the
          current directory with same name as in url.
      overwrite : bool, optional
          Whether to overwrite destination file if already exists.
      sha1_hash : str, optional
          Expected sha1 hash in hexadecimal digits. Will ignore existing file when hash is specified
          but doesn't match.
      retries : integer, default 5
          The number of times to attempt the download in case of failure or non 200 return codes
      verify_ssl : bool, default True
          Verify SSL certificates.
  
      Returns
      -------
      str
          The file path of the downloaded file.
      """
      if path is None:
          fname = url.split("/")[-1]
          # Empty filenames are invalid
          assert fname, (
              "Can't construct file-name from this URL. "
              "Please set the `path` option manually."
          )
      else:
          path = os.path.expanduser(path)
          if os.path.isdir(path):
              fname = os.path.join(path, url.split("/")[-1])
          else:
              fname = path
      assert (
          retries >= 0
      ), "Number of retries should be at least 0, currently it's {}".format(
          retries
      )
  
      if not verify_ssl:
          warnings.warn(
              "Unverified HTTPS request is being made (verify_ssl=False). "
              "Adding certificate verification is strongly advised."
          )
  
      if (
          overwrite
          or not os.path.exists(fname)
          or (sha1_hash and not check_sha1(fname, sha1_hash))
      ):
          dirname = os.path.dirname(
              os.path.abspath(os.path.expanduser(fname))
          )
          if not os.path.exists(dirname):
              os.makedirs(dirname, exist_ok=True)
          while retries + 1 > 0:
              # Disable pyling too broad Exception
              # pylint: disable=W0703
              try:
                  print("Downloading {} from {}...".format(fname, url))
                  r = requests.get(url, stream=True, verify=verify_ssl)
                  if r.status_code != 200:
                      raise RuntimeError(
                          "Failed downloading url {}".format(url)
                      )
                  # create uuid for temporary files
                  random_uuid = str(uuid.uuid4())
                  with open(
                      "{}.{}".format(fname, random_uuid), "wb"
                  ) as f:
                      for chunk in r.iter_content(chunk_size=1024):
                          if chunk:  # filter out keep-alive new chunks
                              f.write(chunk)
                  # if the target file exists(created by other processes)
                  # and have the same hash with target file
                  # delete the temporary file
                  if not os.path.exists(fname) or (
                      sha1_hash and not check_sha1(fname, sha1_hash)
                  ):
                      # atmoic operation in the same file system
                      replace_file(
                          "{}.{}".format(fname, random_uuid), fname
                      )
                  else:
                      try:
                          os.remove("{}.{}".format(fname, random_uuid))
                      except OSError:
                          pass
                      finally:
                          warnings.warn(
                              "File {} exists in file system so the downloaded file is deleted".format(
                                  fname
                              )
                          )
                  if sha1_hash and not check_sha1(fname, sha1_hash):
                      raise UserWarning(
                          "File {} is downloaded but the content hash does not match."
                          " The repo may be outdated or download may be incomplete. "
                          'If the "repo_url" is overridden, consider switching to '
                          "the default repo.".format(fname)
                      )
                  break
              except Exception as e:
                  retries -= 1
                  if retries <= 0:
                      raise e
  
                  print(
                      "download failed due to {}, retrying, {} attempt{} left".format(
                          repr(e), retries, "s" if retries > 1 else ""
                      )
                  )
  
      return fname
  
imports: import os
  import sys
  import hashlib
  import uuid
  import warnings
  import collections
  import weakref
  import requests
  import numpy
  from ..None import ndarray
  from ..util import is_np_shape, is_np_array, TemporaryDirectory
  from ..None import numpy
label_desc: Use image node_id 6 for calling a global function with example usage: download(url, path, overwrite, sha1_hash, retries, verify_ssl) and returns: fname