def forward(self, input_embedding, init_hidden=None, init_cell=None):
    cell_array = []
    hidden_array = []
    for i in range(self._num_layers):
        hidden_array.append(init_hidden[i])
        cell_array.append(init_cell[i])
    res = []
    for index in range(self._num_steps):
        step_input = input_embedding[:, index, :]
        for k in range(self._num_layers):
            pre_hidden = hidden_array[k]
            pre_cell = cell_array[k]
            weight_1 = self.weight_1_arr[k]
            bias = self.bias_arr[k]
            nn = fluid.layers.concat([step_input, pre_hidden], 1)
            gate_input = fluid.layers.matmul(x=nn, y=weight_1)
            gate_input = fluid.layers.elementwise_add(gate_input, bias)
            (i, j, f, o) = fluid.layers.split(gate_input, num_or_sections=4, dim=(- 1))
            c = ((pre_cell * fluid.layers.sigmoid(f)) + (fluid.layers.sigmoid(i) * fluid.layers.tanh(j)))
            m = (fluid.layers.tanh(c) * fluid.layers.sigmoid(o))
            hidden_array[k] = m
            cell_array[k] = c
            step_input = m
            if ((self._dropout is not None) and (self._dropout > 0.0)):
                step_input = fluid.layers.dropout(step_input, dropout_prob=self._dropout, dropout_implementation='upscale_in_train')
        res.append(step_input)
    real_res = fluid.layers.concat(res, 1)
    real_res = fluid.layers.reshape(real_res, [(- 1), self._num_steps, self._hidden_size])
    last_hidden = fluid.layers.concat(hidden_array, 1)
    last_hidden = fluid.layers.reshape(last_hidden, shape=[(- 1), self._num_layers, self._hidden_size])
    last_hidden = fluid.layers.transpose(x=last_hidden, perm=[1, 0, 2])
    last_cell = fluid.layers.concat(cell_array, 1)
    last_cell = fluid.layers.reshape(last_cell, shape=[(- 1), self._num_layers, self._hidden_size])
    last_cell = fluid.layers.transpose(x=last_cell, perm=[1, 0, 2])
    return (real_res, last_hidden, last_cell)
def forward(self, input_embedding, init_hidden=None, init_cell=None):
    cell_array = []
    hidden_array = []
    for i in range(self._num_layers):
        hidden_array.append(init_hidden[i])
        cell_array.append(init_cell[i])
    res = []
    for index in range(self._num_steps):
        step_input = input_embedding[:, index, :]
        for k in range(self._num_layers):
            pre_hidden = hidden_array[k]
            pre_cell = cell_array[k]
            weight_1 = self.weight_1_arr[k]
            bias = self.bias_arr[k]
            nn = fluid.layers.concat([step_input, pre_hidden], 1)
            gate_input = fluid.layers.matmul(x=nn, y=weight_1)
            gate_input = fluid.layers.elementwise_add(gate_input, bias)
            (i, j, f, o) = fluid.layers.split(gate_input, num_or_sections=4, dim=(- 1))
            c = ((pre_cell * fluid.layers.sigmoid(f)) + (fluid.layers.sigmoid(i) * fluid.layers.tanh(j)))
            m = (fluid.layers.tanh(c) * fluid.layers.sigmoid(o))
            hidden_array[k] = m
            cell_array[k] = c
            step_input = m
            if ((self._dropout is not None) and (self._dropout > 0.0)):
                step_input = fluid.layers.dropout(step_input, dropout_prob=self._dropout, dropout_implementation='upscale_in_train')
        res.append(step_input)
    real_res = fluid.layers.concat(res, 1)
    real_res = fluid.layers.reshape(real_res, [(- 1), self._num_steps, self._hidden_size])
    last_hidden = fluid.layers.concat(hidden_array, 1)
    last_hidden = fluid.layers.reshape(last_hidden, shape=[(- 1), self._num_layers, self._hidden_size])
    last_hidden = fluid.layers.transpose(x=last_hidden, perm=[1, 0, 2])
    last_cell = fluid.layers.concat(cell_array, 1)
    last_cell = fluid.layers.reshape(last_cell, shape=[(- 1), self._num_layers, self._hidden_size])
    last_cell = fluid.layers.transpose(x=last_cell, perm=[1, 0, 2])
    return (real_res, last_hidden, last_cell)