Due to the non-ideality of analog components, transceivers experience high levels of hardware imperfections, like in-phase and quadrature imbalance (IQI), which manifests itself as the mismatches of amplitude and phase between the I and Q branches. Unless proper mitigated, IQI has an important and negative impact on the reliability and efficiency of high-frequency and high-data-rate systems, such as terahertz wireless networks. Recognizing this, the current paper presents an intelligent transmitter (TX) and an intelligent receiver (RX) architecture that by employing machine learning (ML) methodologies is capable to fully-mitigate the impact of IQI without performing IQI coefficients estimation. They key idea lies on co-training the TX mapper's and RX demapper in order to respectively design a constellation and detection scheme that takes accounts for IQI. Two training approaches are implemented, namely: i) conventional that requires a considerable amount of data for training, and ii) a reinforcement learning based one, which demands a shorter dataset in comparison to the former. The feasibility and efficiency of the proposed architecture and training approaches are validated through respective Monte Carlo simulations.