Then, it's "only" a matter of deciding which part of the circuit will be powered for the next oscillation, and the switching can be done when vds=0.
I haven't had the occasion to think about this as much as I wanted, though, so the above explanation might be incorrect. Hopefully this gives you a better idea of the concept (which there are many ways to approach).
So yeah, there are losses (mostly due to circuit resistance), but the "switches" are capacitors, which are just "springs" in the electrical sense. You can get back your energy if done in a clever manner, but we typically just short them to discharge (switch) them :)
So, compare the energy required to compact and extend a spring if:
* You oscillate with it
* You compact it, fully release it, then recompact it.
This is a very apt analogy, I think, up to the mathematical level.
In less idealized models you can't even to do intermediate computations completely losslessly, so those computers will use some energy, but it can approach 0 by working more slowly.
If we're talking about theoretical friction-less thought experiments, you could use a lifted barrier, for example, and recover the energy put in when the barrier is lowered.
But then, it still must take energy to move the switches that send the balls in desired directions, right? But perhaps this is much less. But not 0.
I am not a physicist in case this post was not glaringly obvious.