code: def fetch_single_file(
      url,
      data_dir,
      resume=True,
      overwrite=False,
      md5sum=None,
      username=None,
      password=None,
      verbose=1,
      session=None,
  ):
      """Load requested file, downloading it if needed or requested.
  
      Parameters
      ----------
      %(url)s
      %(data_dir)s
      %(resume)s
      overwrite : bool, default=False
          If true and file already exists, delete it.
  
      md5sum : string, optional
          MD5 sum of the file. Checked if download of the file is required.
  
      username : string, optional
          Username used for basic HTTP authentication.
  
      password : string, optional
          Password used for basic HTTP authentication.
      %(verbose)s
      session : requests.Session, optional
          Session to use to send requests.
  
      Returns
      -------
      files : string
          Absolute path of downloaded file.
  
      Notes
      -----
      If, for any reason, the download procedure fails, all downloaded files are
      removed.
  
      """
      if session is None:
          with requests.Session() as session:
              session.mount("ftp:", _NaiveFTPAdapter())
              return fetch_single_file(
                  url,
                  data_dir,
                  resume=resume,
                  overwrite=overwrite,
                  md5sum=md5sum,
                  username=username,
                  password=password,
                  verbose=verbose,
                  session=session,
              )
      # Determine data path
      if not os.path.exists(data_dir):
          os.makedirs(data_dir)
  
      # Determine filename using URL
      parse = urllib.parse.urlparse(url)
      file_name = os.path.basename(parse.path)
      if file_name == "":
          file_name = md5_hash(parse.path)
  
      temp_file_name = f"{file_name}.part"
      full_name = os.path.join(data_dir, file_name)
      temp_full_name = os.path.join(data_dir, temp_file_name)
      if os.path.exists(full_name):
          if overwrite:
              os.remove(full_name)
          else:
              return full_name
      if os.path.exists(temp_full_name) and overwrite:
          os.remove(temp_full_name)
      t0 = time.time()
      local_file = None
      initial_size = 0
  
      try:
          # Download data
          headers = {}
          auth = None
          if username is not None and password is not None:
              if not url.startswith("https"):
                  raise ValueError(
                      "Authentication was requested "
                      f"on a non secured URL ({url})."
                      "Request has been blocked for security reasons."
                  )
              auth = (username, password)
          if verbose > 0:
              displayed_url = url.split("?")[0] if verbose == 1 else url
              print(f"Downloading data from {displayed_url} ...")
          if resume and os.path.exists(temp_full_name):
              # Download has been interrupted, we try to resume it.
              local_file_size = os.path.getsize(temp_full_name)
              # If the file exists, then only download the remainder
              headers["Range"] = f"bytes={local_file_size}-"
              try:
                  req = requests.Request(
                      method="GET", url=url, headers=headers, auth=auth
                  )
                  prepped = session.prepare_request(req)
                  with session.send(
                      prepped, stream=True, timeout=_REQUESTS_TIMEOUT
                  ) as resp:
                      resp.raise_for_status()
                      content_range = resp.headers.get("Content-Range")
                      if (
                          content_range is None
                          or not content_range.startswith(
                              f"bytes {local_file_size}-"
                          )
                      ):
                          raise OSError(
                              "Server does not support resuming"
                          )
                      initial_size = local_file_size
                      with open(local_file, "ab") as fh:
                          _chunk_read_(
                              resp,
                              fh,
                              report_hook=(verbose > 0),
                              initial_size=initial_size,
                              verbose=verbose,
                          )
              except Exception:
                  if verbose > 0:
                      print(
                          "Resuming failed, try to download the whole file."
                      )
                  return fetch_single_file(
                      url,
                      data_dir,
                      resume=False,
                      overwrite=overwrite,
                      md5sum=md5sum,
                      username=username,
                      password=password,
                      verbose=verbose,
                      session=session,
                  )
          else:
              req = requests.Request(
                  method="GET", url=url, headers=headers, auth=auth
              )
              prepped = session.prepare_request(req)
              with session.send(
                  prepped, stream=True, timeout=_REQUESTS_TIMEOUT
              ) as resp:
                  resp.raise_for_status()
                  with open(temp_full_name, "wb") as fh:
                      _chunk_read_(
                          resp,
                          fh,
                          report_hook=(verbose > 0),
                          initial_size=initial_size,
                          verbose=verbose,
                      )
          shutil.move(temp_full_name, full_name)
          dt = time.time() - t0
          if verbose > 0:
              # Complete the reporting hook
              sys.stderr.write(
                  f" ...done. ({dt:.0f} seconds, {dt // 60:.0f} min)\n"
              )
      except requests.RequestException:
          sys.stderr.write(
              f"Error while fetching file {file_name}; dataset fetching aborted."
          )
          raise
      if md5sum is not None and _md5_sum_file(full_name) != md5sum:
          raise ValueError(
              f"File {local_file} checksum verification has failed."
              " Dataset fetching aborted."
          )
      return full_name
  
imports: import collections.abc
  import contextlib
  import fnmatch
  import hashlib
  import os
  import pickle
  import shutil
  import sys
  import tarfile
  import time
  import urllib
  import warnings
  import zipfile
  from pathlib import Path
  import numpy
  import requests
  from .._utils import fill_doc
  from .utils import get_data_dirs
label_desc: Use image node_id 15 for calling a global function with example usage: fetch_single_file(url, data_dir, resume, overwrite, md5sum, username, password, verbose, session) and returns: full_name, fetch_single_file, full_name, fetch_single_file