no, it's simpler than that.
Bosch, Yamaha, Brose, Shimano, Bafang etc make bikes with torque sensors.
You put in X, the motor is programmed to deliver 1X, 1.5X, 2X, 3X etc. The bike computer asks the battery how much charge in WH it has left, works out how many WH 1X, 1.5X, 2X etc is, divides...