Use numpy style advanced index.
>>> import torch                                    
>>> z = torch.zeros(3,4)                            
>>> z[[0, 2], [2, 3]] = 1                           
>>> z                                               
                                                    
 0  0  1  0                                         
 0  0  0  0                                         
 0  0  0  1                                         
[torch.FloatTensor of size 3x4]                     
                                                    
>>>