class_docstr: Extends the Tensorflow MultiRNNCell with residual connections
class_docstr_tok: ["Extends","the","Tensorflow","MultiRNNCell","with","residual","connections"]
docstr: Run this multi-layer cell on inputs, starting from state.
docstr_tok: ["Run","this","multi-layer","cell","on","inputs",",","starting","from","state","."]
code: def __call__(self, inputs, state, scope=None):
      """Run this multi-layer cell on inputs, starting from state."""
      if not self._residual_connections:
          return super(ExtendedMultiRNNCell, self).__call__(
              inputs, state, (scope or "extended_multi_rnn_cell")
          )
  
      with tf.variable_scope(scope or "extended_multi_rnn_cell"):
          # Adding Residual connections are only possible when input and output
          # sizes are equal. Optionally transform the initial inputs to
          # `cell[0].output_size`
          if self._cells[0].output_size != inputs.get_shape().as_list()[
              1
          ] and (self._residual_combiner in ["add", "mean"]):
              inputs = tf.contrib.layers.fully_connected(
                  inputs=inputs,
                  num_outputs=self._cells[0].output_size,
                  activation_fn=None,
                  scope="input_transform",
              )
  
          # Iterate through all layers (code from MultiRNNCell)
          cur_inp = inputs
          prev_inputs = [cur_inp]
          new_states = []
          for i, cell in enumerate(self._cells):
              with tf.variable_scope("cell_%d" % i):
                  if not nest.is_sequence(state):
                      raise ValueError(
                          "Expected state to be a tuple of length %d, but received: %s"
                          % (len(self.state_size), state)
                      )
                  cur_state = state[i]
                  next_input, new_state = cell(cur_inp, cur_state)
  
                  # Either combine all previous inputs or only the current input
                  input_to_combine = prev_inputs[-1:]
                  if self._residual_dense:
                      input_to_combine = prev_inputs
  
                  # Add Residual connection
                  if self._residual_combiner == "add":
                      next_input = next_input + sum(input_to_combine)
                  if self._residual_combiner == "mean":
                      combined_mean = tf.reduce_mean(
                          tf.stack(input_to_combine), 0
                      )
                      next_input = next_input + combined_mean
                  elif self._residual_combiner == "concat":
                      next_input = tf.concat(
                          [next_input] + input_to_combine, 1
                      )
                  cur_inp = next_input
                  prev_inputs.append(cur_inp)
  
                  new_states.append(new_state)
      new_states = (
          tuple(new_states)
          if self._state_is_tuple
          else array_ops.concat(new_states, 1)
      )
      return cur_inp, new_states
  
file_path: seq2seq/seq2seq/contrib/rnn_cell.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import sys
  import inspect
  import tensorflow
  from tensorflow.python.ops import array_ops
  from tensorflow.python.util import nest
  from tensorflow.contrib.rnn import MultiRNNCell
label_desc: Use image node_id 2 for calling the ExtendedMultiRNNCell obj's underlying member method code with example usage: obj.__call__(inputs, state, scope) and returns: cur_inp,  new_states, super