# tf nightly (should be same as 2.7)
import tensorflow as tf
from tensorflow import keras

x=tf.keras.Input([10])
dense = tf.keras.layers.Dense(1)
y = dense(x)

assert(keras.backend.is_keras_tensor(x))
assert(keras.backend.is_keras_tensor(y))

assert(tf.keras.backend.is_keras_tensor(x))
assert(tf.keras.backend.is_keras_tensor(y))

Note that tensorflow.python.keras is not a valid import, and it is accessing legacy code that is about to delete. You should never import that directly.