code: def _build_vocab(filename, vocab_path, vocab_size):
      """Reads a file to build a vocabulary of `vocab_size` most common words.
  
       The vocabulary is sorted by occurrence count and has one word per line.
  
      Args:
        filename: file to read list of words from.
        vocab_path: path where to save the vocabulary.
        vocab_size: size of the vocabulary to generate.
      """
      data = _read_words(filename)
      counter = collections.Counter(data)
      count_pairs = sorted(counter.items(), key=lambda x: (-x[1], x[0]))
      words, _ = list(zip(*count_pairs))
      words = words[:vocab_size]
      with open(vocab_path, "w") as f:
          f.write("\n".join(words))
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import os
  import sys
  import tarfile
  from tensor2tensor.data_generators import generator_utils
  from tensor2tensor.data_generators import problem
  from tensor2tensor.data_generators import text_encoder
  from tensor2tensor.data_generators import text_problems
  from tensor2tensor.utils import registry
  import tensorflow.compat.v1
label_desc: Use image node_id 2 for calling a global function with example usage: _build_vocab(filename, vocab_path, vocab_size) without return types