import torch.nn as nn

class BidirectionalLSTM(nn.Module):
    # Module to extract BLSTM features from convolutional feature map

    def __init__(self, nIn, nHidden, nOut):
        super(BidirectionalLSTM, self).__init__()

        self.rnn = nn.LSTM(nIn, nHidden, bidirectional=True)
        self.embedding = nn.Linear(nHidden * 2, nOut)
        self.rnn.cuda()
        self.embedding.cuda()

    def forward(self, input):
        recurrent, _ = self.rnn(input)
        T, b, h = recurrent.size()
        t_rec = recurrent.view(T * b, h)

        output = self.embedding(t_rec)  # [T * b, nOut]
        output = output.view(T, b, -1)

        return output

[((9, 19, 9, 60), 'torch.nn.LSTM', 'nn.LSTM', (), '', True, 'import torch.nn as nn\n'), ((10, 25, 10, 53), 'torch.nn.Linear', 'nn.Linear', ({(10, 35, 10, 46): 'nHidden * 2', (10, 48, 10, 52): 'nOut'}, {}), '(nHidden * 2, nOut)', True, 'import torch.nn as nn\n')]