Which option correctly defines a generator?

1. a device that converts thermal energy into mechanical energy
2. a device that converts light energy into electrical energy
3. a device that converts electrical energy into mechanical energy
4. a device that converts mechanical energy into electrical energy