It will work on tensors only right now, as we don’t have nonzero() implemented for Variables. I’ll add that soon. I’m afraid for now you need to do it like you originally wrote, sorry for the trouble!