code: def count_words(path, max_vocab_size=40000, tok=False):
      """count all words in the corpus and output a counter"""
      counts = collections.Counter()
      for words in read_file(path, tok):
          for word in words:
              counts[word] += 1
  
      vocab = [word for (word, _) in counts.most_common(max_vocab_size)]
      return vocab
  
file_path: texar/examples/transformer/utils/preprocess.py
imports: import collections
  import re
  import json
  import os
  import numpy
  import pickle
  import argparse
  from io import open
label_desc: Use image node_id 4 for calling a global function with example usage: count_words(path, max_vocab_size, tok) and returns: vocab