Many thanks for your reply.
And this example is similiar to what i have tried with torch.no_grad() method, the execution of program still warn “RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation”