To my understanding, I think these two methods are different.
For example, we have a tensor a = tensor([0.0000, 0.5000, 0.0000, 0.0000, 0.7000]), if I only want the top 2 softmax result for this tensor, the result  should be tensor([0.0000, 0.4502, 0.0000, 0.0000, 0.5498]), but if I apply nn.Softmax() first and set the values I don’t want to 0,  the calculation procedure is :
softmax([0.0000, 0.5000, 0.0000, 0.0000, 0.7000]) =tensor([0.1501, 0.2475, 0.1501, 0.1501, 0.3023])->tensor([0.0, 0.2475, 0.0, 0.0, 0.3023])
If I am wrong, please correct me
Thank you again!