Can a turbofan have a fan driven electrically so as to run at optimal speed? I just watched this pretty dumbed-down video about the idea of putting a gearbox in a turbofan so the fan can run at its optimum slower speed while the core runs at its optimum high speed.

And I immediately remembered this answer from Peter Kampf that said basically, a normal gearbox would have huge waste heat.

Then I suddenly remembered an old question of mine about driving a helicopter engine with a diesel-electric system.

So now the obvious 2-and-2 together: Can the fan of a turbofan be driven with an electric motor (powered by the already-existing generator of the engine)? Or the more detailed questions: Can an electric motor be small enough to fit around the fan's axle and still power the fan? How much it would weigh? I'm interested in large turbofans on the orders of 100 to 500 kN, but I think that would make the task easier since there's more room plus weight increases have diminishing returns against a huge airliner.

This would have obvious advantages. The fan:core ratio can be variable without any gearing. Presumably much less maintenance, or at least no more maintenance than the generator requires.
There are plans to run a turbofan-like engine with an electric motor rather than the gas generator used today. But the weight of electric engines does not promise an immediate advantage - only when the electricity is generated in a much more efficient way that what today's gas generators offer will the overall propulsion mass be lower. An example is a hydrogen-powered fuel cell somewhere in the fuselage.

We had a similar discussion here and here.