Yes, the resulting gradient would be the same, but you would use more memory, since both computation graphs needs to be kept before the final backward() operation is called. If you call backward() separately, the intermediate tensors would be freed right afterwards. You would thus save memory but pay for it with two backward operations.