code: def _build_vocab(filename):
      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))
      word_to_id = dict(zip(words, range(len(words))))
  
      return word_to_id
  
file_path: tensorpack/examples/PennTreebank/reader.py
imports: from __future__ import absolute_import, division, print_function
  import collections
  import os
  import tensorflow
label_desc: Use image node_id 2 for calling a global function with example usage: _build_vocab(filename) and returns: word_to_id