It doesn't matter how the machine works. You can model any dehumidifier regardless of its internal technology as a black box with inputs of humid air and electricity, and outputs of dry air and water.
The water is removed from the room. The heat released by condensing it (and also cooling it below room temperature as a heat pump effect) stays behind. For the dehumidifier to continue to operate, it needs a continuing input of humid air. As the OP noted, how this humid air is created or imported is important. Consider the common situation of water from outside seeping through a basement wall and evaporating from its surface. The process at the wall cools the room, exactly offsetting the heat of condensation in the dehumidifier. The net heat input to the room is then only the electricity. Every kWh of electricity used by the machine eventually becomes heat.