The best solution I found was to use imports via the Keras API. Instead of
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import LSTM, Dense, Dropout
from tensorflow.keras.optimizers import Adam
I now use
from keras.api.models import Sequential
from keras.api.layers import LSTM, Dense, Dropout
from keras.api.optimizers import Adam
This way you can still import the objects directly, without needing to reference their parent. Note that this was tested in Linux using Tensorflow version 2.12 (which includes Keras 3).
API reference: Keras 3 API. Cheers!