def _decode(cell, helper):
    """Decode function.

    Args:
      cell: rnn cell
      helper: a helper instance from tf.contrib.seq2seq.

    Returns:
      decoded outputs and lengths.
    """
    with tf.variable_scope("decoder"):
      initial_state = cell.zero_state(batch_size, tf.float32)
      if hps.use_bridge:
        h_state, c_state = encoder_outputs.states
        if hps.rnn_cell == "lstm":
          initial_cell_state = tf.contrib.rnn.LSTMStateTuple(h_state, c_state)
        elif hps.rnn_cell == "gru":
          initial_cell_state = h_state
        initial_state = initial_state.clone(cell_state=(initial_cell_state,))

      decoder = tf.contrib.seq2seq.BasicDecoder(
          cell=cell,
          helper=helper,
          initial_state=initial_state)
    with tf.variable_scope("dynamic_decode", reuse=tf.AUTO_REUSE):
      decoder_outputs, _, decoder_len = tf.contrib.seq2seq.dynamic_decode(
          decoder=decoder,
          maximum_iterations=hps.max_dec_steps)
    return decoder_outputs, decoder_len
Decode function.

    Args:
      cell: rnn cell
      helper: a helper instance from tf.contrib.seq2seq.

    Returns:
      decoded outputs and lengths.
    
language/labs/exemplar_decoding/models/baselines.py