It does accumulate gradient using accum
(see here), but in-place mutation of the values is not require for accumulation. In your case, I think it will hit this line (called from here). As you can see, it does add the gradients, but accum.(x, y)
will not result in the correct array type being returned back.
PS: still take all this with a grain of salt