code: def get_encoder_from_vocab(vocab_filepath):
    
    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
docs: 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.