Doing the sum() like that is the same as calling backward with a vector full of ones like you do.
But why it works is because it makes the overall function have a single output and so the overall jacobian has a single row. And multiplying it by a vector of [1] will return that row in one backward pass.