code: def download_file(
      url,
      directory="./",
      local_fname=None,
      force_write=False,
      auto_unzip=False,
      compre_type="",
  ):
      """Download the data from source url, unless it's already here.
  
      Args:
          filename: string, name of the file in the directory.
          work_directory: string, path to working directory.
          source_url: url to download from if file doesn't exist.
  
      Returns:
          Path to resulting file.
      """
  
      if not os.path.isdir(directory):
          os.mkdir(directory)
  
      if not local_fname:
          k = url.rfind("/")
          local_fname = url[k + 1 :]
  
      local_fname = os.path.join(directory, local_fname)
  
      if os.path.exists(local_fname) and not force_write:
          print("File [{}] existed!".format(local_fname))
          return local_fname
  
      else:
          print(
              "Downloading file [{}] from [{}]".format(local_fname, url)
          )
          try:
              import wget
  
              ret = wget.download(url, local_fname)
              print("")
          except:
              ret = _single_thread_download(url, local_fname)
  
      if auto_unzip:
          if ret.endswith(".tar.gz") or ret.endswith(".tgz"):
              try:
                  import tarfile
  
                  tar = tarfile.open(ret)
                  for name in tar.getnames():
                      if not (
                          os.path.realpath(
                              os.path.join(directory, name)
                          )
                          + os.sep
                      ).startswith(
                          os.path.realpath(directory) + os.sep
                      ):
                          raise ValueError(
                              "The decompression path does not match the current path. For more info: https://docs.python.org/3/library/tarfile.html#tarfile.TarFile.extractall"
                          )
                  tar.extractall(directory)
                  tar.close()
              except ValueError:
                  raise
              except:
                  print("Unzip file [{}] failed.".format(ret))
  
          elif ret.endswith(".zip"):
              try:
                  import zipfile
  
                  zip_ref = zipfile.ZipFile(ret, "r")
                  for name in zip_ref.namelist():
                      if not (
                          os.path.realpath(
                              os.path.join(directory, name)
                          )
                          + os.sep
                      ).startswith(
                          os.path.realpath(directory) + os.sep
                      ):
                          raise ValueError(
                              "The decompression path does not match the current path. For more info: https://docs.python.org/3/library/zipfile.html?highlight=zipfile#zipfile.ZipFile.extractall"
                          )
                  zip_ref.extractall(directory)
                  zip_ref.close()
              except ValueError:
                  raise
              except:
                  print("Unzip file [{}] failed.".format(ret))
      return ret
  
file_path: MMdnn/mmdnn/conversion/common/utils.py
imports: from __future__ import division
  import os
  import sys
  import numpy
  from six import text_type, binary_type, integer_types
  import mmdnn.conversion.common.IR.graph_pb2
label_desc: Use image node_id 14 for calling a global function with example usage: download_file(url, directory, local_fname, force_write, auto_unzip, compre_type) and returns: ret, local_fname