code: def get_encoder_from_vocab(vocab_filepath):
      """Get encoder from vocab file.
  
      If vocab is not found in output dir, it will be copied there by
      copy_vocab_to_output_dir to clarify the vocab used to generate the data.
  
      Args:
        vocab_filepath: path to vocab, either local or cns
  
      Returns:
        A SubwordTextEncoder vocabulary object. None if the output_parallel_text
        is set.
      """
      if not tf.gfile.Exists(vocab_filepath):
          raise ValueError(
              "Vocab file does not exist: {}.".format(vocab_filepath)
          )
  
      tf.logging.info("Found vocab file: %s", vocab_filepath)
      encoder = text_encoder.SubwordTextEncoder(vocab_filepath)
      return encoder
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import math
  import os
  import random
  import re
  import subprocess
  from tensor2tensor.data_generators import generator_utils
  from tensor2tensor.data_generators import text_encoder
  import tensorflow.compat.v1
label_desc: Use image node_id 22 for calling a global function with example usage: get_encoder_from_vocab(vocab_filepath) and returns: encoder