Nice, Thanks a lot.
However, it is not what I meant.
It is not just to overwrite some lines, but overwrite some elements of some lines in a more fine-grained way. For example:
In [19]: mat = torch.arange(16).view(4,4)

In [20]: idx = torch.LongTensor([[0, 2, 3, 2]])

In [21]: mat
Out[21]: 
tensor([[  0.,   1.,   2.,   3.],
        [  4.,   5.,   6.,   7.],
        [  8.,   9.,  10.,  11.],
        [ 12.,  13.,  14.,  15.]])

In [22]: torch.gather(mat, 0, idx)
Out[22]: tensor([[  0.,   9.,  14.,  11.]])

and I just want to replace the gathered elements with some other things.
It looks like I am doing scatter in a gather way. May be I should check some scatter method?
However, it would be nice if pytorch could support it directly with gather method, just like in numpy.