all_outputs = session.run(lstm_outputs, feed_dict={'your inputs'})
last_outputs = all_outputs[(sequence_lengths), (tf.range(batch_size)), :]
use_this_as_an_input_to_new_tensorflow_op = tf.constant(last_outputs)
How to pick the last valid output values from tensorflow RNN