Pytorch lstm doc. For details see this paper .