For the forward function doing o = x + y, the backward is gx = go and gy = go.
For the forward function doing o = x * y, the backward is gx = y * go and gy = x * go.
For the fft, it depends on which forward function you use. If you use a regular o = fft(x), I think the gradient is just gx = ifft(go). If you want to be sure, you can find here 16 how the top level fft functions are linked to the low level one called _fft_with_size. Here 13 you can find how the backward of that function is defined for each of it’s arguments. And the fft_backward() can be found here 14. Unfortunately thiss function is not accessible directly as the arguments are quite far from the regular python api. But you can easily find the corresponding torch.[]fft call that correspond to your forward.