only_inputs=False for torch.autograd.grad now seems to be deprecated (although it is still described as a feature in the master docs for version 0.4.0). When used it issues a warning (see torch/autograd/init.py):
“only_inputs argument is deprecated and is ignored now (defaults to True). To accumulate gradient for other parts of the graph, please use torch.autograd.backward.”