First of all thank u for the fast response.
So I changed my if and I’m checking  if p.grad is None: but it seems that the grad still is None. I added also a print inside the if, and the result is the same.