Short-circuiting torch.where?

I am actually doing something like torch.where(cond, f(x), g(y)), where f and g act element-wise and can be expensive. For example see the definitions of logerfc and logerfcx in this code snippet: How to call SciPy functions? - #3 by f3ba