{"record":{"id":"9f451339e67acfaa","repo":"keras-team/keras","slug":"array-inputs-to-associative-scan-must-have-the-sam","errorCode":null,"errorMessage":"Array inputs to associative_scan must have the same first dimension. (saw: {})","messagePattern":"Array inputs to associative_scan must have the same first dimension\\. \\(saw: (.+?)\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/numpy/core.py","lineNumber":233,"sourceCode":"def associative_scan(f, elems, reverse=False, axis=0):\n    # Ref: jax.lax.associative_scan\n    if not callable(f):\n        raise TypeError(f\"`f` should be a callable. Received: f={f}\")\n    elems_flat = tree.flatten(elems)\n    elems_flat = [convert_to_tensor(elem) for elem in elems_flat]\n    if reverse:\n        elems_flat = [np.flip(elem, (axis,)) for elem in elems_flat]\n\n    def _combine(a_flat, b_flat):\n        a = tree.pack_sequence_as(elems, a_flat)\n        b = tree.pack_sequence_as(elems, b_flat)\n        c = f(a, b)\n        c_flat = tree.flatten(c)\n        return c_flat\n\n    num_elems = int(elems_flat[0].shape[axis])\n    if not all(int(elem.shape[axis]) == num_elems for elem in elems_flat[1:]):\n        raise ValueError(\n            \"Array inputs to associative_scan must have the same \"\n            \"first dimension. (saw: {})\".format(\n                [elem.shape for elem in elems_flat]\n            )\n        )\n\n    def _interleave(a, b, axis):\n        \"\"\"Given two Tensors of static shape, interleave them along axis.\"\"\"\n        if not (\n            a.shape[axis] == b.shape[axis] or a.shape[axis] == b.shape[axis] + 1\n        ):\n            raise ValueError(\n                \"Shapes are incompatible for associative_scan interleaving. \"\n                f\"a.shape[{axis}]={a.shape[axis]}, \"\n                f\"b.shape[{axis}]={b.shape[axis]}\"\n            )\n\n        # we want to get a: [a1, a2], b: [b1, b2]","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/numpy/core.py#L215-L251","documentation":"Error \"Array inputs to associative_scan must have the same first dimension. (saw: {})\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/backend/numpy/core.py:233 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"}