Flywheel Inverted pendulum torque calculation

Jul 2018
I started building my own flywheel inverted pendulum (i'm using a standard PID controller for the balancing).
I came across many articles regarding the differential equation of the pendulum.
Most article develop the motion equation using the Euler–Lagrange, few chose the Newtonian way.
What I cant figure out is the definition of the torque that all Euler–Lagrange articles made:

image 1 -

image 2 -

Why is the torque for the wheel different from the rod?
why isn't the torque a single value given by the motor mounted on the wheel?

I would expect it to be the same torque only in the reversed direction like in a Newtonian development:

image 3 -

Please help :)