You can flatten the gradients using torch.cat([g.view(-1) for g in grads], 0). This is supported by autograd.
Regarding taking grad of grad, we will support it (that’s why var.grad is a Variable too), but it’s still work in progress. At this point there’s no way to do this, but hopefully it will be implemented in the next month. Sorry!