code: def _string_to_bytes(text, max_length):
      """Given string and length, convert to byte seq of at most max_length.
  
      This process mimics docqa/elmo's preprocessing:
      https://github.com/allenai/document-qa/blob/master/docqa/elmo/data.py
  
      Note that we make use of BOS_CHAR_ID and EOS_CHAR_ID in iterator_utils.py &
      our usage differs from docqa/elmo.
  
      Args:
        text: tf.string tensor of shape []
        max_length: max number of chars for each word.
  
      Returns:
        A tf.int32 tensor of the byte encoded text.
      """
      byte_ids = tf.to_int32(tf.decode_raw(text, tf.uint8))
      byte_ids = byte_ids[: max_length - 2]
      padding = tf.fill(
          [max_length - tf.shape(byte_ids)[0] - 2], PAD_CHAR_ID
      )
      byte_ids = tf.concat(
          [[BOW_CHAR_ID], byte_ids, [EOW_CHAR_ID], padding], axis=0
      )
      tf.logging.info(byte_ids)
  
      byte_ids = tf.reshape(byte_ids, [max_length])
      tf.logging.info(byte_ids.get_shape().as_list())
      return byte_ids + 1
  
file_path: nlp-architect/examples/sparse_gnmt/gnmt/utils/vocab_utils.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import codecs
  import os
  import tensorflow
  from tensorflow.python.ops import lookup_ops
  from .None import misc_utils
label_desc: Use image node_id 1 for calling a global function with example usage: _string_to_bytes(text, max_length) and returns: unknown