Sorry for ignoring the difference between tensor.where(condition, y) and np.where(condition, y). In order to get results like R.lt(r_max), the code should be:
mask = R_norm.where(R_norm>1, torch.ones_like(r))
mask = mask.where(R_norm<1, torch.zeros_like(r))