code: def _get_token_encoder(vocab_dir, vocab_name, filename):
      """Reads from file and returns a `TokenTextEncoder` for the vocabulary."""
      vocab_path = os.path.join(vocab_dir, vocab_name)
      if not tf.gfile.Exists(vocab_path):
          _build_vocab(filename, vocab_path, 10000)
      return text_encoder.TokenTextEncoder(vocab_path)
  
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 3 for calling a global function with example usage: _get_token_encoder(vocab_dir, vocab_name, filename) and returns: text_encoder