'Encodes a sequence of sentences as skip-thought vectors.
Args:
sess: TensorFlow Session.
data: A list of input strings.
use_norm: Whether to normalize skip-thought vectors to unit L2 norm.
verbose: Whether to log every batch.
batch_size: Batch size for the encoder.
use_eos: Whether to append the end-of-sentence word to each input
sentence.
Returns:
thought_vectors: A list of numpy arrays corresponding to the skip-thought
encodings of sentences in \'data\'.'

def encode(self, sess, data, use_norm=True, verbose=True, batch_size=128, use_eos=False):

    data = self._preprocess(data, use_eos)
    thought_vectors = []
    batch_indices = np.arange(0, len(data), batch_size)
    for (batch, start_index) in enumerate(batch_indices):
        if verbose:
            tf.logging.info('Batch    %d    /    %d.', batch, len(batch_indices))
        (embeddings, mask) = _batch_and_pad(data[start_index:(start_index + batch_size)])
        feed_dict = {'encode_emb:0': embeddings, 'encode_mask:0': mask}
        thought_vectors.extend(sess.run('encoder/thought_vectors:0', feed_dict=feed_dict))
    if use_norm:
        thought_vectors = [(v / np.linalg.norm(v)) for v in thought_vectors]
    return thought_vectors
