{"record":{"id":"793f1dbba3b14b18","repo":"tensorflow/models","slug":"unexpected-inputs-to-s-with-length-at-d-793f1d","errorCode":null,"errorMessage":"Unexpected inputs to %s with length at %d","messagePattern":"Unexpected inputs to (.+?) with length at (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/modeling/layers/transformer_encoder_block.py","lineNumber":606,"sourceCode":"        streams for the query, and key/value to the multi-head attention. If\n        dictionary is provided, it must contain the following keys:\n        `input_tensor`, `attention_mask`, `key_value_tensor`.\n      output_range: the sequence output range, [0, output_range) for slicing the\n        target sequence. `None` means the target sequence is not sliced. If you\n        would like to have no change to the model training, it is better to only\n        set the `output_range` for serving.\n\n    Returns:\n      An output tensor with the same dimensions as input/query tensor.\n    \"\"\"\n    if isinstance(inputs, (list, tuple)):\n      if len(inputs) == 2:\n        input_tensor, attention_mask = inputs\n        key_value = None\n      elif len(inputs) == 3:\n        input_tensor, key_value, attention_mask = inputs\n      else:\n        raise ValueError(\"Unexpected inputs to %s with length at %d\" %\n                         (self.__class__, len(inputs)))\n    elif isinstance(inputs, dict):\n      if not set(inputs.keys()).issubset(\n          set([\"input_tensor\", \"key_value_tensor\", \"attention_mask\"])\n      ):\n        raise ValueError(\n            f\"Unexpected keys in input dictionary to: {inputs.keys()}\"\n        )\n      try:\n        input_tensor = inputs[\"input_tensor\"]\n      except KeyError as e:\n        raise ValueError(\n            \"Missing required key `input_tensor` in input dictionary.\"\n        ) from e\n      key_value = inputs.get(\"key_value_tensor\", None)\n      attention_mask = inputs.get(\"attention_mask\", None)\n    else:\n      input_tensor, key_value, attention_mask = (inputs, None, None)","sourceCodeStart":588,"sourceCodeEnd":624,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/modeling/layers/transformer_encoder_block.py#L588-L624","documentation":"Error \"Unexpected inputs to %s with length at %d\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/modeling/layers/transformer_encoder_block.py:606 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"}