Hi, I’m wondering how could we use gather to select and write inplace. For example:
in numpy, we could write
a = np.array([[1,2],[3,4]])
a[np.arange(2), np.arange(2)] = np.ones(2)

However, when I tried in pytorch with gather, I got
In [12]: torch.gather(a, 1, idx) = torch.ones(2,1)
  File "<ipython-input-12-9ba3ceddfc82>", line 1
    torch.gather(a, 1, idx) = torch.ones(2,1)
                                             ^
SyntaxError: can't assign to function call

It would be great helpful for my project if I could do so…
Is there any suggestions?
Best regards