'Compute this layer\'s output function given a symbolic input variable
Parameters
inputs : list of theano.TensorType
`inputs[0]` should always be the symbolic input variable.  When
this layer has a mask input (i.e. was instantiated with
`mask_input != None`, indicating that the lengths of sequences in
each batch vary), `inputs` should have length 2, where `inputs[1]`
is the `mask`.  The `mask` should be supplied as a Theano variable
denoting whether each time step in each sequence in the batch is
part of the sequence or not.  `mask` should be a matrix of shape
``(n_batch, n_time_steps)`` where ``mask[i, j] = 1`` when ``j <=
(length of sequence i)`` and ``mask[i, j] = 0`` when ``j > (length
of sequence i)``. When the hidden state of this layer is to be
pre-filled (i.e. was set to a :class:`Layer` instance) `inputs`
should have length at least 2, and `inputs[-1]` is the hidden state
to prefill with.
Returns
layer_output : theano.TensorType
Symbolic output variable.'

def get_output_for(self, inputs, **kwargs):

    input = inputs[0]
    mask = None
    hid_init = None
    if (self.mask_incoming_index > 0):
        mask = inputs[self.mask_incoming_index]
    if (self.hid_init_incoming_index > 0):
        hid_init = inputs[self.hid_init_incoming_index]
    if (input.ndim > 3):
        input = T.flatten(input, 3)
    input = input.dimshuffle(1, 0, 2)
    (seq_len, num_batch, _) = input.shape
    W_in_stacked = T.concatenate([self.W_in_to_resetgate, self.W_in_to_updategate, self.W_in_to_hidden_update], axis=1)
    W_hid_stacked = T.concatenate([self.W_hid_to_resetgate, self.W_hid_to_updategate, self.W_hid_to_hidden_update], axis=1)
    b_stacked = T.concatenate([self.b_resetgate, self.b_updategate, self.b_hidden_update], axis=0)
    if self.precompute_input:
        input = (T.dot(input, W_in_stacked) + b_stacked)
    def slice_w(x, n):
        s = x[:, (n * self.num_units):((n + 1) * self.num_units)]
        if (self.num_units == 1):
            s = T.addbroadcast(s, 1)
        return s
    def step(input_n, hid_previous, *args):
        hid_input = T.dot(hid_previous, W_hid_stacked)
        if self.grad_clipping:
            input_n = theano.gradient.grad_clip(input_n, (- self.grad_clipping), self.grad_clipping)
            hid_input = theano.gradient.grad_clip(hid_input, (- self.grad_clipping), self.grad_clipping)
        if (not self.precompute_input):
            input_n = (T.dot(input_n, W_in_stacked) + b_stacked)
        resetgate = (slice_w(hid_input, 0) + slice_w(input_n, 0))
        updategate = (slice_w(hid_input, 1) + slice_w(input_n, 1))
        resetgate = self.nonlinearity_resetgate(resetgate)
        updategate = self.nonlinearity_updategate(updategate)
        hidden_update_in = slice_w(input_n, 2)
        hidden_update_hid = slice_w(hid_input, 2)
        hidden_update = (hidden_update_in + (resetgate * hidden_update_hid))
        if self.grad_clipping:
            hidden_update = theano.gradient.grad_clip(hidden_update, (- self.grad_clipping), self.grad_clipping)
        hidden_update = self.nonlinearity_hid(hidden_update)
        hid = (((1 - updategate) * hid_previous) + (updategate * hidden_update))
        return hid
    def step_masked(input_n, mask_n, hid_previous, *args):
        hid = step(input_n, hid_previous, *args)
        hid = T.switch(mask_n, hid, hid_previous)
        return hid
    if (mask is not None):
        mask = mask.dimshuffle(1, 0, 'x')
        sequences = [input, mask]
        step_fun = step_masked
    else:
        sequences = [input]
        step_fun = step
    if (not isinstance(self.hid_init, Layer)):
        hid_init = T.dot(T.ones((num_batch, 1)), self.hid_init)
    non_seqs = [W_hid_stacked]
    if (not self.precompute_input):
        non_seqs += [W_in_stacked, b_stacked]
    if self.unroll_scan:
        input_shape = self.input_shapes[0]
        hid_out = unroll_scan(fn=step_fun, sequences=sequences, outputs_info=[hid_init], go_backwards=self.backwards, non_sequences=non_seqs, n_steps=input_shape[1])[0]
    else:
        hid_out = theano.scan(fn=step_fun, sequences=sequences, go_backwards=self.backwards, outputs_info=[hid_init], non_sequences=non_seqs, truncate_gradient=self.gradient_steps, strict=True)[0]
    if self.only_return_final:
        hid_out = hid_out[(-1)]
    else:
        hid_out = hid_out.dimshuffle(1, 0, 2)
        if self.backwards:
            hid_out = hid_out[:, ::(-1)]
    return hid_out
