I've been having the same issue for a bit in PyCharm. The solution is quite odd, simply install keras as a package by itself, and then replace imports to import tensorflow.keras
to keras.api
and it will compile just fine.
Would appreciate it if anyone could give further explanation as to why this works..