code: def download_20newsgroups(target_dir, cache_path):
      """Download the 20 newsgroups data and stored it as a zipped pickle."""
      archive_path = os.path.join(target_dir, ARCHIVE_NAME)
      train_path = os.path.join(target_dir, TRAIN_FOLDER)
      test_path = os.path.join(target_dir, TEST_FOLDER)
  
      if not os.path.exists(target_dir):
          os.makedirs(target_dir)
  
      if os.path.exists(archive_path):
          # Download is not complete as the .tar.gz file is removed after
          # download.
          logger.warning("Download was incomplete, downloading again.")
          os.remove(archive_path)
  
      logger.warning("Downloading dataset from %s (14 MB)", URL)
      opener = urlopen(URL)
      with open(archive_path, "wb") as f:
          f.write(opener.read())
  
      logger.info("Decompressing %s", archive_path)
      tarfile.open(archive_path, "r:gz").extractall(path=target_dir)
      os.remove(archive_path)
  
      # Store a zipped pickle
      cache = dict(
          train=load_files(train_path, encoding="latin1"),
          test=load_files(test_path, encoding="latin1"),
      )
      compressed_content = codecs.encode(
          pickle.dumps(cache), "zlib_codec"
      )
      with open(cache_path, "wb") as f:
          f.write(compressed_content)
  
      shutil.rmtree(target_dir)
      return cache
  
imports: import os
  import logging
  import tarfile
  import pickle
  import shutil
  import re
  import codecs
  import numpy
  import scipy.sparse
  from .base import get_data_home
  from .base import Bunch
  from .base import load_files
  from .base import _pkl_filepath
  from ..utils import check_random_state
  from ..feature_extraction.text import CountVectorizer
  from ..preprocessing import normalize
  from ..externals import joblib, six
label_desc: Use image node_id 1 for calling a global function with example usage: download_20newsgroups(target_dir, cache_path) and returns: cache