Thanks for your reply.
Actually I am following the logic applied in that code but my code is different.
This the ways how I define the hidden layer
    def initHidden(self, N):
        return (
        Variable(torch.randn(2, N, self.hidden_size)), Variable(torch.randn(2, N, self.hidden_size)))

where N is the batch size =10 and the hidden size is 50
the shape of the input tensor is [39, 10, 951] (sq,batch,feature)
so I really don’t know from where its expecting (2, 39, 50) for the hidden!