Can't do autograd on assignment operation(seems like an inevitable inplace operation)

Hello everybody! Here’s my problem:
My pytorch version is 0.3, so I have to use variable to do autograd in my network. I want to get the output from my network and do some matrix calculation and then get the loss value.This is what I try to do:
I got an output from my designed network, it’s a vector, say 100 dims. And I want to assign the elements from this vector to a 10x10 matrix. And the position of these elements is determined by a 100-dim index array I have calculated already, like this:

But when I try to do this, I encountered this problem:
in-place operations can be only used on variables that don’t share storage with any other variables, but detected that there are 2 objects sharing it
So I can’t do inplace operations on variable, but I need the resulted matrix to calcalate loss value and then do autograd. It really confuses me a lot… So I want to ask everybody, is there a way for me to achieve this purpose? Thanks a lot!!!

Hi, I am caughted in the same problem, can you tell me how do you fix it the end?