'Define the bi-directional encoder module of sketch-rnn.'

def encoder(self, batch, sequence_lengths):

    (unused_outputs, last_states) = tf.nn.bidirectional_dynamic_rnn(self.enc_cell_fw, self.enc_cell_bw, batch, sequence_length=sequence_lengths, time_major=False, swap_memory=True, dtype=tf.float32, scope='ENC_RNN')
    (last_state_fw, last_state_bw) = last_states
    last_h_fw = self.enc_cell_fw.get_output(last_state_fw)
    last_h_bw = self.enc_cell_bw.get_output(last_state_bw)
    last_h = tf.concat([last_h_fw, last_h_bw], 1)
    mu = rnn.super_linear(last_h, self.hps.z_size, input_size=(self.hps.enc_rnn_size * 2), scope='ENC_RNN_mu', init_w='gaussian', weight_start=0.001)
    presig = rnn.super_linear(last_h, self.hps.z_size, input_size=(self.hps.enc_rnn_size * 2), scope='ENC_RNN_sigma', init_w='gaussian', weight_start=0.001)
    return (mu, presig)
