code: def get_vocabulary(fobj, is_dict=False):
      """Read text and return dictionary that encodes vocabulary"""
      vocab = Counter()
      for line in fobj:
          if is_dict:
              word, count = line.strip().split()
              vocab[word] = int(count)
          else:
              for word in line.split():
                  vocab[word] += 1
      return vocab
  
file_path: OpenNMT-py/tools/learn_bpe.py
imports: from __future__ import unicode_literals
  import sys
  import codecs
  import re
  import copy
  import argparse
  from collections import defaultdict, Counter
  from io import open
label_desc: Use image node_id 2 for calling a global function with example usage: get_vocabulary(fobj, is_dict) and returns: vocab