def _check_model(model):
    """Check whether the model need sto be compiled."""
    # compile model if user gave us an un-compiled model
    if not model.compiled or not model.loss or not model.optimizer:
        raise RuntimeError(
            "Given model needs to be compiled, and have a loss and an "
            "optimizer."
        )
Check whether the model need sto be compiled.
keras/src/wrappers/utils.py