It was not because of tensorflow. It is because of Keras, as you can see here
It needs Keras > 3.0. My Keras was also at 2.8.