p_copy[batch_indices, word_indices] += attn[batch_indices, idx_repeat]
coverage[batch_indices, idx_repeat] += attn[batch_indices, idx_repeat]

try something like
new_converage = torch.zeros(converage.shape)
# or
# new_converage =  converage.data.copy()
new_converage = Variable(torch.zeros)

new_coverage[batch_indices, idx_repeat] =  attn[batch_indices, idx_repeat] + coverage[batch_indices, idx_repeat]