That documentation that you linked explicitly states that it computes a vector jacobian product 
If you want to get the full jacobian in general, you will need to do as many backward as there are outputs to your function.
In the special case where it is diagonal though (like here), you can compute it in one go as done in your example.