{"record":{"id":"0843c7790366509a","repo":"keras-team/keras","slug":"inputs-should-be-a-list-received-inputs-input","errorCode":null,"errorMessage":"`inputs` should be a list. Received: inputs={inputs}","messagePattern":"`inputs` should be a list\\. Received: inputs=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/merging/base_merge.py","lineNumber":261,"sourceCode":"            output_shape = (list(batch_sizes)[0],) + output_shape\n        else:\n            output_shape = (None,) + output_shape\n        return output_shape\n\n    def compute_output_spec(self, inputs):\n        output_shape = self.compute_output_shape([x.shape for x in inputs])\n        output_sparse = all(x.sparse for x in inputs)\n        return KerasTensor(\n            output_shape, dtype=self.compute_dtype, sparse=output_sparse\n        )\n\n    def compute_mask(self, inputs, mask=None):\n        if mask is None:\n            return None\n        if not isinstance(mask, (tuple, list)):\n            raise ValueError(f\"`mask` should be a list. Received: mask={mask}\")\n        if not isinstance(inputs, (tuple, list)):\n            raise ValueError(\n                f\"`inputs` should be a list. Received: inputs={inputs}\"\n            )\n        if len(mask) != len(inputs):\n            raise ValueError(\n                \"The lists `inputs` and `mask` should have the same length. \"\n                f\"Received: inputs={inputs} of length {len(inputs)}, and \"\n                f\"mask={mask} of length {len(mask)}\"\n            )\n        # Default implementation does an OR between the masks, which works\n        # for `Add`, `Subtract`, `Average`, `Maximum`, `Minimum`, `Multiply`.\n        if any(m is None for m in mask):\n            return None\n        output_mask = mask[0]\n        for m in mask[1:]:\n            output_mask = ops.logical_or(output_mask, m)\n        return output_mask\n\n    def get_config(self):","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/merging/base_merge.py#L243-L279","documentation":"compute_mask() of merge layers validates that inputs is a list or tuple. If a single tensor (or other non-sequence) is passed alongside a mask, this error is raised before mask combination logic runs.","triggerScenarios":"Calling compute_mask(x, mask=[m1, m2]) with a bare tensor x; custom subclasses invoking super().compute_mask with unwrapped inputs.","commonSituations":"Custom merge subclasses that forward masks; test code calling compute_mask directly; model surgery that changes input arity.","solutions":["Pass inputs as a list matching the layer's input structure","Keep compute_mask call sites consistent with how __call__/build see inputs","Add input-structure assertions in custom merge subclasses"],"exampleFix":"# before\nmask_out = merge_layer.compute_mask(x, mask=[m1, m2])\n\n# after\nmask_out = merge_layer.compute_mask([x1, x2], mask=[m1, m2])","handlingStrategy":"validation","validationCode":"assert isinstance(inputs, (list, tuple)), 'inputs must be a list when a mask is provided'","typeGuard":"def is_input_list(x) -> bool:\n    return isinstance(x, (list, tuple))","tryCatchPattern":null,"preventionTips":["Mirror __call__ input structure when calling compute_mask directly","Wrap inputs in lists in custom subclasses"],"tags":["keras","merge","masking","input-format"],"backgroundTag":"wrong-argument-structure","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}