I applied softmax in two parts ,  1: before calculating context vector, the outputs of the encoder goes to a linear and then softmax, here I did not mask any since it will learn, also 0 padded words are outputted as 0 vector by the encoder(since i used packing).  and 2: before calculating loss, the output of the decoder goes through a linear and then softmax, then  I used masking here  and used CrossEntropyLoss.