It’s not really necessary, since the forward pass is also wrapped in a torch.no_grad() block.
Thus the model output shouldn’t even have a grad_fn you could detach.
However, it should be a no-op in this case anyway. At least I cannot think of a use case where this could be necessary.