When using the Discretization layer in tensorflow backend you get a different output when calling in graph mode (model.predict() below) as opposed to eager mode.

Keras version: 3.10.0 Tensorflow version: 2.18.1

Reproducible code (gist):

import tensorflow as tf
import keras

layer = keras.layers.Discretization(
    bin_boundaries=[-0.5, 0, 0.1, 0.2, 3],
    name="bucket",
    output_mode="int",
)

x = tf.constant([[0.0, 0.15, 0.21, 0.3], [0.0, 0.17, 0.451, 7.8]])
inputs = keras.layers.Input(name="inp", dtype="float32", shape=(4,))

model_output = layer(inputs)
model = keras.models.Model(inputs=[inputs], outputs=[model_output])
layer(x)
<tf.Tensor: shape=(2, 4), dtype=int64, numpy=
array([[2, 3, 4, 4],
       [2, 3, 4, 5]])>
model(x)
<tf.Tensor: shape=(2, 4), dtype=int64, numpy=
array([[2, 3, 4, 4],
       [2, 3, 4, 5]])>
model.predict(x)
array([[2, 2, 2, 2],
       [2, 2, 2, 5]])

This issue is copied modified upon #20981 as requested.