{"record":{"id":"bb9d85b33fa26dd1","repo":"keras-team/keras","slug":"wrong-number-of-output-arguments-expected-len-ou","errorCode":null,"errorMessage":"wrong number of output arguments: expected {len(output_core_dims)}, got {len(out_shapes)}","messagePattern":"wrong number of output arguments: expected (.+?), got (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/common/backend_utils.py","lineNumber":562,"sourceCode":"\n    def wrapped(*args):\n        out = func(*args)\n        if isinstance(out, (list, tuple)):\n            out_shapes = [ops.shape(x) for x in out]\n        else:\n            out_shapes = [out.shape]\n\n        if expected_output_core_dims is None:\n            output_core_dims = [()] * len(out_shapes)\n        else:\n            output_core_dims = expected_output_core_dims\n            if len(output_core_dims) > 1 and not isinstance(out, tuple):\n                raise TypeError(\n                    \"output must be a tuple when multiple outputs \"\n                    f\"are expected, got: {out}\"\n                )\n            if len(out_shapes) != len(output_core_dims):\n                raise TypeError(\n                    \"wrong number of output arguments: \"\n                    f\"expected {len(output_core_dims)}, got {len(out_shapes)}\"\n                )\n\n        sizes = dict(dim_sizes)\n        for shape, core_dims in zip(out_shapes, output_core_dims):\n            _vectorize_update_dim_sizes(sizes, shape, core_dims, is_input=False)\n\n        return out\n\n    return wrapped\n\n\ndef _vectorize_apply_excluded(func, excluded, args, kwargs):\n    if not excluded:\n        return func, args, kwargs\n\n    dynamic_args = [arg for i, arg in enumerate(args) if i not in excluded]","sourceCodeStart":544,"sourceCodeEnd":580,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/common/backend_utils.py#L544-L580","documentation":"Guard in the wrapped function of ops.vectorize: the number of tensors the wrapped function returned does not match the number of output groups declared in the gufunc signature, so outputs cannot be paired with their declared core dimensions.","triggerScenarios":"Thrown at keras/src/backend/common/backend_utils.py:562 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Return exactly as many outputs as the signature declares after '->'.","Adjust the signature's output list (e.g. '(n),(n)' vs '(n)') to the actual number of returned tensors."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}