def __call__(self, input_sequence, regularizer, dropout_rate, is_training=True):
    if (not self.regularize):
        regularizer = None
    sequence_length = sequence_length_3D(input_sequence)
    cell_fn = get_cell_fun(self.cell_type)
    with tf.variable_scope('rnn_stack', reuse=tf.AUTO_REUSE, regularizer=regularizer) as vs:
        if self.bidirectional:
            fw_cell = (lambda state_size: cell_fn(state_size))
            bw_cell = (lambda state_size: cell_fn(state_size))
            fw_cells = [fw_cell(self.state_size) for _ in range(self.num_layers)]
            bw_cells = [bw_cell(self.state_size) for _ in range(self.num_layers)]
            (rnn_outputs, final_state_fw, final_state_bw) = tf.contrib.rnn.stack_bidirectional_dynamic_rnn(cells_fw=fw_cells, cells_bw=bw_cells, dtype=tf.float32, sequence_length=sequence_length, inputs=input_sequence)
        else:
            cell = (lambda state_size: cell_fn(state_size))
            cells = MultiRNNCell([cell(self.state_size) for _ in range(self.num_layers)], state_is_tuple=True)
            (rnn_outputs, final_state) = tf.nn.dynamic_rnn(cells, input_sequence, sequence_length=sequence_length, dtype=tf.float32)
        for v in tf.global_variables():
            if v.name.startswith(vs.name):
                logging.debug('  {}: {}'.format(v.name, v))
        logging.debug('  rnn_outputs: {0}'.format(rnn_outputs))
        rnn_output = reduce_sequence(rnn_outputs, self.reduce_output)
        logging.debug('  reduced_rnn_output: {0}'.format(rnn_output))
    if (self.dropout and (dropout_rate is not None)):
        rnn_output = tf.layers.dropout(rnn_output, rate=dropout_rate, training=is_training)
        logging.debug('  dropout_rnn: {0}'.format(rnn_output))
    return (rnn_output, rnn_output.shape.as_list()[(- 1)])
def __call__(self, input_sequence, regularizer, dropout_rate, is_training=True):
    if (not self.regularize):
        regularizer = None
    sequence_length = sequence_length_3D(input_sequence)
    cell_fn = get_cell_fun(self.cell_type)
    with tf.variable_scope('rnn_stack', reuse=tf.AUTO_REUSE, regularizer=regularizer) as vs:
        if self.bidirectional:
            fw_cell = (lambda state_size: cell_fn(state_size))
            bw_cell = (lambda state_size: cell_fn(state_size))
            fw_cells = [fw_cell(self.state_size) for _ in range(self.num_layers)]
            bw_cells = [bw_cell(self.state_size) for _ in range(self.num_layers)]
            (rnn_outputs, final_state_fw, final_state_bw) = tf.contrib.rnn.stack_bidirectional_dynamic_rnn(cells_fw=fw_cells, cells_bw=bw_cells, dtype=tf.float32, sequence_length=sequence_length, inputs=input_sequence)
        else:
            cell = (lambda state_size: cell_fn(state_size))
            cells = MultiRNNCell([cell(self.state_size) for _ in range(self.num_layers)], state_is_tuple=True)
            (rnn_outputs, final_state) = tf.nn.dynamic_rnn(cells, input_sequence, sequence_length=sequence_length, dtype=tf.float32)
        for v in tf.global_variables():
            if v.name.startswith(vs.name):
                logging.debug('  {}: {}'.format(v.name, v))
        logging.debug('  rnn_outputs: {0}'.format(rnn_outputs))
        rnn_output = reduce_sequence(rnn_outputs, self.reduce_output)
        logging.debug('  reduced_rnn_output: {0}'.format(rnn_output))
    if (self.dropout and (dropout_rate is not None)):
        rnn_output = tf.layers.dropout(rnn_output, rate=dropout_rate, training=is_training)
        logging.debug('  dropout_rnn: {0}'.format(rnn_output))
    return (rnn_output, rnn_output.shape.as_list()[(- 1)])