class_docstr: Define a SketchRNN model.
class_docstr_tok: ["Define","a","SketchRNN","model","."]
docstr: Define the bi-directional encoder module of sketch-rnn.
docstr_tok: ["Define","the","bi-directional","encoder","module","of","sketch-rnn","."]
code: def encoder(self, batch, sequence_lengths):
      """Define the bi-directional encoder module of sketch-rnn."""
      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,  # bi-dir, so x2
          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,  # bi-dir, so x2
          scope="ENC_RNN_sigma",
          init_w="gaussian",
          weight_start=0.001,
      )
      return mu, presig
  
file_path: magenta/magenta/models/sketch_rnn/model.py
imports: import random
  from magenta.contrib import training
  from magenta.models.sketch_rnn import rnn
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 2 for calling the Model obj's underlying member method code with example usage: obj.encoder(batch, sequence_lengths) and returns: mu,  presig