You can find here 18 the definition of the backward for the pow operator.
And the function for the backward towards p is here 14. As you can see, it takes the log of the input. So I expect that if x contains any 0, then you will get a nan here. You can check that with: print(x.eq(0).sum()).