Oh sorry, I edited my post:
It’s outputs=[y,z], not  outputs=[y,y] that I meant !
torch.autograd.grad(outputs=[y,z], inputs=[x,x], 
                          grad_outputs=[torch.ones_like(y), torch.ones_like(y)], 
                          create_graph=True)

So, if in the sequence you give, you have two times the same variable, the gradient for this variable will be accumulated two times. That’s as simple as this!