Where are GTK_IM_MODULE and GTK_MODULES set?

Yes, that is most likely the cause.

As regards your question why ~/.xinputrc would contain that, it's a long story. In short it's about various attempts historically to achieve a sensible default configuration. I assume that you installed Ubuntu some years ago, and later upgraded to 20.04.

My advice: Just delete ~/.xinputrc and reboot. It won't return unless you actively change the input method configuration via e.g. Language Support.