def build_bidirectional_rnn(sequences, length,
                            num_layers, num_residual_layers, num_units,
                            unit_type, forget_bias, dropout, mode,
                            trainable=True):
  """Builds sequences encoded with a bidirectional RNN."""
  # Create RNN cells.
  cells = {
      direction: create_rnn_cell(
          unit_type=unit_type,
          num_units=num_units,
          num_layers=num_layers,
          num_residual_layers=num_residual_layers,
          forget_bias=forget_bias,
          dropout=dropout,
          mode=mode,
          trainable=trainable)
      for direction in ["fw", "bw"]}

  # Encode.
  outputs, state = tf.nn.bidirectional_dynamic_rnn(
      cells["fw"], cells["bw"], sequences,
      sequence_length=length,
      dtype=tf.float32,
      time_major=False)

  # Concatenate bidirectional outputs.
  outputs = tf.concat(outputs, axis=2)

  return outputs, state
Builds sequences encoded with a bidirectional RNN.
language/labs/consistent_zero_shot_nmt/utils/model_utils.py