The code under tensorflow.keras is legacy, and should not be used.
The correct way of importing keras code is always from “from tensorflow import keras” or “import tensorflow as tf; tf.keras”
Directly “import keras” will access keras package python code directly (not exactly same as the public Keras API), which might lead to method/class not found.