Here is an example,
import torch
import time
import copy

def reset(t):
   return 1.0 / torch.log(1.0 + t)

source1 = torch.FloatTensor(10000, 10000)
source1.uniform_()
source2 = copy.deepcopy(source1)

start = time.time()
mask = source1 < 0.5
source1[mask] = reset(source1[mask])
print('test1 takes: ', time.time() - start)

start = time.time()
mask = source2 < 0.5
source2 = torch.where(mask, reset(source2), source2)
print('test2 takes: ', time.time() - start)

On my machine,
test1 takes:  3.4766557216644287
test2 takes:  1.7760250568389893