The first thing to note, is that the fuel generation gear would be perfectly sized to create the amount of fuel required to bring the astronauts back to Earth. It is not like it has surplus capacity. So we really need to consider bringing fuel back from Mars, somewhat separately to the plan of bringing the astronauts back. It is going to require bringing a lot of extra equipment.
If the intention is to bring something to be used as fuel back to Earth, the logical thing to bring would actually be plain water either in liquid or ice form. Water can be turned into H2 and O2 in a perfect ratio for fuel using electrolysis. However, in the H2O form it is highly stable and easily transported, while in the H2/O2 form it is highly volatile - with both forms having exactly the same mass. Instead of bringing extra electrolysis gear, extra power generation and extra tanks all the way to Mars, it'd make more sense to put all that extra gear in Earth Orbit, bring water back from Mars, and perform the electrolysis in Earth Orbit, where the fuel would be used.
It would also be possible to bring CO2 back from Mars (probably as dry ice) and perform the Sabatier reaction and electrolysis in Earth Orbit, with Hydrogen brought only from Earth to Earth Orbit instead of all the way to Mars. CO2 has the advantage of being easily extracted from the Martian atmosphere, while water has to be mined from the ground or extracted from the atmosphere at considerably greater effort.
Note that these options result in just as much usable fuel in Earth Orbit, with much less mass needing to be sent to Mars. Of course, it would still be necessary to generate a lot more methane and lox to bring the H2O or CO2 back to Earth - the whole point of in situ generation is that carbon and oxygen are heavy elements (compared with hydrogen) and not desirable things to be delivering between planets, so the plan of bringing carbon or oxygen from Mars to Earth somewhat defeats the purpose of in situ generation - which is to save on mass. Yet it could still be cheaper to bring them from Mars to Earth Orbit, than from Earth, at least in terms of delta-V.
But there are potentially cheaper places to get water (and maybe carbon) from, it would actually be a lot cheaper in terms of delta-V to bring fuel from the moons of Mars than Mars itself. This comes down to gravity, Mars has a relatively deep gravity well while the moons have very shallow gravity wells. In fact, various factors conspire to making Phobos and Deimos even closer in terms of Delta-V than the Moon - but only for very restricted windows when the Earth and Mars are properly aligned. At the moment we don't really know what resources are available on Phobos and Deimos, it is only speculated that there are exploitable quantities of volatiles.
The other good candidate to bring water from is the Moon, even though Phobos and Deimos are occasionally slightly closer in terms of Delta-V, the Moon is far more accessible in every other way, most importantly the trip time is mere days or weeks instead of 8 months. The moon likely has water in the form of ice in permanently shaded craters, which could be extracted and processed into fuel in-situ, or delivered to Earth Orbit for processing.
Considering the much greater accessibility of the Moon, I believe it does not make sense at this time to bring extra equipment to Mars with the purpose of bringing fuel back to Earth Orbit. In situ generation of fuel on Mars only makes sense if that fuel is to be used on Mars.