code: def prepare_data(data_path):
      """Preprocess PTB data."""
      train_path = os.path.join(data_path, "ptb.train.txt")
      if not tf.gfile.Exists(train_path):
          url = "http://www.fit.vutbr.cz/~imikolov/rnnlm/simple-examples.tgz"
          tx.data.maybe_download(url, data_path, extract=True)
          data_path = os.path.join(data_path, "simple-examples", "data")
  
      train_path = os.path.join(data_path, "ptb.train.txt")
      valid_path = os.path.join(data_path, "ptb.valid.txt")
      test_path = os.path.join(data_path, "ptb.test.txt")
  
      word_to_id = tx.data.make_vocab(
          train_path, newline_token="<EOS>", return_type="dict"
      )
      assert len(word_to_id) == 10000
  
      train_text = tx.data.read_words(train_path, newline_token="<EOS>")
      train_text_id = [
          word_to_id[w] for w in train_text if w in word_to_id
      ]
  
      valid_text = tx.data.read_words(valid_path, newline_token="<EOS>")
      valid_text_id = [
          word_to_id[w] for w in valid_text if w in word_to_id
      ]
  
      test_text = tx.data.read_words(test_path, newline_token="<EOS>")
      test_text_id = [
          word_to_id[w] for w in test_text if w in word_to_id
      ]
  
      data = {
          "train_text": train_text,
          "valid_text": valid_text,
          "test_text": test_text,
          "train_text_id": train_text_id,
          "valid_text_id": valid_text_id,
          "test_text_id": test_text_id,
          "vocab": word_to_id,
          "vocab_size": len(word_to_id),
      }
      return data
  
imports: import os
  import numpy
  import tensorflow
  import horovod.tensorflow
  import texar.tf
label_desc: Use image node_id 2 for calling a global function with example usage: prepare_data(data_path) and returns: data