'Parse expression and add LSTM Layer.
Args:
prev_layer: Input tensor.
index:      Position in model_str to start parsing
Returns:
Output tensor, end index in model_str.'

def AddLSTMLayer(self, prev_layer, index):

    pattern = re.compile('(L)(f|r|b)(x|y)(s)?({\\w+})?(\\d+)')
    m = pattern.match(self.model_str, index)
    if (m is None):
        return (None, None)
    direction = m.group(2)
    dim = m.group(3)
    summarize = (m.group(4) == 's')
    name = self._GetLayerName(m.group(0), index, m.group(5))
    depth = int(m.group(6))
    if ((direction == 'b') and summarize):
        fwd = self._LSTMLayer(prev_layer, 'forward', dim, True, depth, (name + '_forward'))
        back = self._LSTMLayer(prev_layer, 'backward', dim, True, depth, (name + '_reverse'))
        return (tf.concat(axis=3, values=[fwd, back], name=(name + '_concat')), m.end())
    if (direction == 'f'):
        direction = 'forward'
    elif (direction == 'r'):
        direction = 'backward'
    else:
        direction = 'bidirectional'
    outputs = self._LSTMLayer(prev_layer, direction, dim, summarize, depth, name)
    if summarize:
        if (dim == 'x'):
            self.reduction_factors[2] = None
        else:
            self.reduction_factors[1] = None
    return (outputs, m.end())
