The problem seems to be that you are trying to apply an in-place operation that can’t be in-place because the backprop wouldn’t work (sqrt).
First idea that I had was to perform the operations out of place in different tensors and then concatenate them, something like
out1 = output[:, 2::1+coords, :, :].sqrt()
out2 = output[:, 3::1+coords, :, :].sqrt()

but that still requires concatenating and shuffling around the elements in the tensor, which doesn’t sound like a good solution.
I have no better ideas now given the information I have about what you want to do, sorry