{"record":{"id":"6a0b5c7c4ac1bf9a","repo":"tensorflow/models","slug":"unexpected-inputs-to-self-class-with-length","errorCode":null,"errorMessage":"Unexpected inputs to {self.__class__} with length at {len(inputs)}.","messagePattern":"Unexpected inputs to (.+?) with length at (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/modeling/layers/pack_optimization.py","lineNumber":157,"sourceCode":"  def __init__(self, *args, **kwargs):\n    super().__init__(*args, **kwargs)\n    if self._output_range is not None:\n      raise ValueError(f'{self.__class__} does not '\n                       'support `output_range` argument.')\n    # TODO(b/337888023): Support block sparse attention with strided inputs.\n    if self._src_block_size is not None:\n      raise ValueError(f'{self.__class__} does not '\n                       'support block sparse attention.')\n\n  def call(self, inputs, stride: tf.Tensor):\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(f'Unexpected inputs to {self.__class__} with '\n                         f'length at {len(inputs)}.')\n    else:\n      input_tensor, key_value, attention_mask = (inputs, None, None)\n\n    target_tensor = input_tensor[:, ::stride, :]\n    if attention_mask is not None:\n      attention_mask = attention_mask[:, ::stride, :]\n\n    if key_value is None:\n      key_value = input_tensor\n\n    attention_output = self._attention_layer(\n        query=target_tensor, value=key_value, attention_mask=attention_mask)\n    attention_output = self._attention_dropout(attention_output)\n    attention_output = target_tensor + self._rezero_a * attention_output\n    if self._use_layer_norm:\n      attention_output = self._attention_layer_norm(attention_output)\n    else:","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/modeling/layers/pack_optimization.py#L139-L175","documentation":"Error \"Unexpected inputs to {self.__class__} with length at {len(inputs)}.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/modeling/layers/pack_optimization.py:157 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"}