keras/src/backend/tensorflow/random.py/_cast_seed
def _cast_seed(seed):
    # TensorFlow has a device placement issue that `Variable` must be int64
    # in `SeedGenerator`. However, all `tf.random.stateless_*` expect the seed
    # to be int32 to run with XLA.
    # This function addresses the inconsistency using `floormod`.
    # Ref: https://www.tensorflow.org/api_docs/python/tf/random
    if standardize_dtype(seed.dtype) == "int32":
        return seed
    else:
        seed = tf.cast(tf.math.floormod(seed, tf.int32.max - 1), dtype="int32")
        return seed