{"record":{"id":"366061fc4c2d9fa8","repo":"tensorflow/models","slug":"transformerdecoderblock-must-have-5-inputs-when-i","errorCode":null,"errorMessage":"TransformerDecoderBlock must have 5 inputs, when it uses multi_channel_cross_attention. But it got: %d","messagePattern":"TransformerDecoderBlock must have 5 inputs, when it uses multi_channel_cross_attention\\. But it got: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/modeling/layers/transformer.py","lineNumber":401,"sourceCode":"            self._attention_initializer, use_legacy_format=True\n        ),\n        \"self_attention_cls\": self._self_attention_cls,\n        \"cross_attention_cls\": self._cross_attention_cls,\n    }\n    base_config = super().get_config()\n    return dict(list(base_config.items()) + list(config.items()))\n\n  def common_layers_with_encoder(self):\n    \"\"\"Gets layer objects that can make a Transformer encoder block.\"\"\"\n    return [\n        self.self_attention, self.self_attention_layer_norm,\n        self.intermediate_dense, self.output_dense, self.output_layer_norm\n    ]\n\n  def call(self, inputs, cache=None, decode_loop_step=None):\n    if self.multi_channel_cross_attention:\n      if len(inputs) != 5:\n        raise ValueError(\n            \"TransformerDecoderBlock must have 5 inputs, when it uses \"\n            \"multi_channel_cross_attention. But it got: %d\" % len(inputs))\n    elif len(inputs) != 4:\n      raise ValueError(\n          \"TransformerDecoderBlock must have 4 inputs, but it got: %d\" %\n          len(inputs))\n    input_tensor, memory, attention_mask, self_attention_mask = inputs[:4]\n    source_tensor = input_tensor\n    if self._norm_first:\n      input_tensor = self.self_attention_layer_norm(input_tensor)\n    self_attention_output, cache = self.self_attention(\n        query=input_tensor,\n        value=input_tensor,\n        attention_mask=self_attention_mask,\n        cache=cache,\n        decode_loop_step=decode_loop_step)\n    self_attention_output = self.self_attention_dropout(self_attention_output)\n    if self._norm_first:","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/modeling/layers/transformer.py#L383-L419","documentation":"Error \"TransformerDecoderBlock must have 5 inputs, when it uses multi_channel_cross_attention. But it got: %d\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/modeling/layers/transformer.py:401 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":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}