Backend helpers.
Assumes Keras 3 with TensorFlow backend. You can extend this to support other backends later if desired.