code: def load_data(
      dest_dir="/tmp/.zoo/dataset",
      nb_words=None,
      oov_char=2,
      test_split=0.2,
  ):
      """Load reuters dataset.
  
      :argument
          dest_dir: where to cache the data (relative to `~/.zoo/dataset`).
          nb_words: number of words to keep, the words are already indexed by frequency
                    so that the less frequent words would be abandoned
          oov_char: index to pad the abandoned words, if None, one abandoned word
                    would be taken place with its next word and total length -= 1
          test_split: the ratio to split part of dataset to test data,
                      the remained data would be train data
  
      :return
          the train, test separated reuters dataset.
      """
      path = download_reuters(dest_dir)
  
      with open(path, "rb") as f:
          x, y = cPickle.load(f)
          # return data and label, need to separate to train and test
  
      shuffle_by_seed([x, y])
  
      if not nb_words:
          nb_words = max([max(s) for s in x])
  
      if oov_char is not None:
          new_x = []
          for s in x:
              new_s = []
              for word in s:
                  if word >= nb_words:
                      new_s.append(oov_char)
                  else:
                      new_s.append(word)
              new_x.append(new_s)
      else:
          new_x = []
          for s in x:
              new_s = []
              for word in s:
                  if word < nb_words:
                      new_s.append(word)
              new_x.append(new_s)
      x = new_x
  
      split_index = int(len(x) * (1 - test_split))
  
      x_train, y_train = x[:split_index], y[:split_index]
  
      x_test, y_test = x[split_index:], y[split_index:]
  
      return (x_train, y_train), (x_test, y_test)
  
imports: from bigdl.dllib.feature.dataset import base
  import numpy
  from six.moves import cPickle
label_desc: Use image node_id 2 for calling a global function with example usage: load_data(dest_dir, nb_words, oov_char, test_split) and returns: x_train,  y_train,  x_test,  y_test