Hi,
Pytorch is a bit particular in the sense that the definition of your function is discovered at the same time as it is evaluated at a point. So you cannot get gradient without evaluating the function at a given point. (This allows much more flexibility on what is allowed wrt control flows and inplace operations).
If you want static graphs that are differentiated symbolically (without evaluation), you can turn to TorchScript which is going to do that.