{"record":{"id":"c5163f00a2c79a69","repo":"keras-team/keras","slug":"to-use-nnx-with-the-jax-backend-you-must-install","errorCode":null,"errorMessage":"To use NNX with the JAX backend, you must install `flax`.","messagePattern":"To use NNX with the JAX backend, you must install `flax`\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/config.py","lineNumber":260,"sourceCode":"    \"\"\"Checks whether NNX specific features are enabled for the JAX backend.\n\n    Returns:\n        bool: `True` if NNX backend features are enabled, `False` otherwise.\n        Defaults to `False`.\n    \"\"\"\n    return _NNX_ENABLED\n\n\ndef set_nnx_enabled(value):\n    global _NNX_ENABLED\n    from keras.src.backend.common import global_state\n\n    _NNX_ENABLED = bool(value)\n    if _NNX_ENABLED:\n        try:\n            from flax import nnx  # noqa F401\n        except ImportError:\n            raise ImportError(\n                \"To use NNX with the JAX backend, you must install `flax`.\"\n            )\n    global_state.set_global_attribute(\"nnx_enabled\", bool(value))\n\n\ndef standardize_data_format(data_format):\n    if data_format is None:\n        return image_data_format()\n    data_format = str(data_format).lower()\n    if data_format not in {\"channels_first\", \"channels_last\"}:\n        raise ValueError(\n            \"The `data_format` argument must be one of \"\n            \"{'channels_first', 'channels_last'}. \"\n            f\"Received: data_format={data_format}\"\n        )\n    return data_format\n\n","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/config.py#L242-L278","documentation":"Error \"To use NNX with the JAX backend, you must install `flax`.\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/backend/config.py:260 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}