code: def prepare_data_maybe_download(directory):
      
      filename = 'ubuntu_dialogs.tgz'
      url = 'http://cs.mcgill.ca/~jpineau/datasets/ubuntu-corpus-1.0/ubuntu_dialogs.tgz'
      dialogs_path = os.path.join(directory, 'dialogs')
  
      # test it there are some dialogs in the path
      if not os.path.exists(os.path.join(directory, "10", "1.tst")):
          # dialogs are missing
          archive_path = os.path.join(directory, filename)
          if not os.path.exists(archive_path):
              # archive missing, download it
              print("Downloading %s to %s" % (url, archive_path))
              filepath, _ = urllib.request.urlretrieve(url, archive_path)
              print "Successfully downloaded " + filepath
  
          # unpack data
          if not os.path.exists(dialogs_path):
              print("Unpacking dialogs ...")
              with tarfile.open(archive_path) as tar:
                  tar.extractall(path=directory)
              print("Archive unpacked.")
  
          return
docs: Download and unpack dialogs if necessary.