{"record":{"id":"36da7246e64eb6d4","repo":"tensorflow/models","slug":"transformerdecoderblock-must-have-4-inputs-but-it","errorCode":null,"errorMessage":"TransformerDecoderBlock must have 4 inputs, but it got: %d","messagePattern":"TransformerDecoderBlock must have 4 inputs, but it got: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/modeling/layers/transformer.py","lineNumber":405,"sourceCode":"    }\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:\n      self_attention_output = source_tensor + self_attention_output\n    else:\n      self_attention_output = self.self_attention_layer_norm(\n          input_tensor + self_attention_output)","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/modeling/layers/transformer.py#L387-L423","documentation":"Error \"TransformerDecoderBlock must have 4 inputs, but it got: %d\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/modeling/layers/transformer.py:405 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"}