Unfortunately in the autograd, we don’t make a difference between “is independent” and “is 0”.
Also such gradient can be represented as:

A Tensor full of 0s
None (or undefined tensor on the c++ side)
An error if you use autograd.grad(..., allow_unused=False)


And the reason for this is that sometimes it will create a graph that produces only 0s and sometimes won’t create the graph at all.
The problem is that it is very hard to be always consistent here as we would like to never create the graph ideally, but we don’t want to have to do extra work either to know if we should create it or not.