I guess these inplace operations might be causing the issue:
result[label_one_tensor] = lam * temp_result[label_one_tensor, :] + (1 - lam) * temp_result[label_one_tensor_shuffle, :]

result[label_two_tensor] = lam * temp_result[label_two_tensor, :] + (1 - lam) * temp_result[label_two_tensor_shuffle, :]

and you might need to store the output in a temporal tensor and torch.cat or torch.stack them to the final result tensor.