During evaluation detaching is not necessary. When you evaluate there is no need to compute the gradients nor backpropagate anything.
So, afaik just put your input variable as volatile and Pytorch won’t hesitate to create the backpropagation graph, it will just do a forward pass.