'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]
    input = input.dimshuffle(1, 0, *range(2, input.ndim))
    (seq_len, num_batch) = (input.shape[0], input.shape[1])
    if self.precompute_input:
        trailing_dims = tuple((input.shape[n] for n in range(2, input.ndim)))
        input = T.reshape(input, (((seq_len * num_batch),) + trailing_dims))
        input = helper.get_output(self.input_to_hidden, input, **kwargs)
        trailing_dims = tuple((input.shape[n] for n in range(1, input.ndim)))
        input = T.reshape(input, ((seq_len, num_batch) + trailing_dims))
    non_seqs = helper.get_all_params(self.hidden_to_hidden)
    if (not self.precompute_input):
        non_seqs += helper.get_all_params(self.input_to_hidden)
    def step(input_n, hid_previous, *args):
        hid_pre = helper.get_output(self.hidden_to_hidden, hid_previous, **kwargs)
        if self.precompute_input:
            hid_pre += input_n
        else:
            hid_pre += helper.get_output(self.input_to_hidden, input_n, **kwargs)
        if self.grad_clipping:
            hid_pre = theano.gradient.grad_clip(hid_pre, (- self.grad_clipping), self.grad_clipping)
        return self.nonlinearity(hid_pre)
    def step_masked(input_n, mask_n, hid_previous, *args):
        hid = step(input_n, hid_previous, *args)
        hid_out = T.switch(mask_n, hid, hid_previous)
        return [hid_out]
    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)):
        dot_dims = (list(range(1, (self.hid_init.ndim - 1))) + [0, (self.hid_init.ndim - 1)])
        hid_init = T.dot(T.ones((num_batch, 1)), self.hid_init.dimshuffle(dot_dims))
    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, *range(2, hid_out.ndim))
        if self.backwards:
            hid_out = hid_out[:, ::(-1)]
    return hid_out
