import tensorflow as tf

    # Note that this strips spaces from the end of the input as well.
    # We assume no inputs rely on the existence of trailing whitespace.
    txt = tf.strings.strip(txt)
    return txt
