I have tensor condition operation, such as
for i:
   if check(rate[i]):
      rate[i] = reset(rate[i])

right now, i implemented as following,
rate = torch.where(check(rate), reset(rate), rate)
It turns out that even for tensor where check(rate) is false, reset(rate) is still operated, kind of like
new_rate = reset(rate)
rate = torch.where(check(rate), new_rate, rate)

I am wondering anyway i could improve the performance here, if reset(rate) is really expensive.