{"record":{"id":"e59d2218f16797dd","repo":"tensorflow/models","slug":"reuse-attention-scores-cannot-be-none-when-reuse-a","errorCode":null,"errorMessage":"reuse_attention_scores cannot be None when reuse_attention is True or > 0.","messagePattern":"reuse_attention_scores cannot be None when reuse_attention is True or > 0\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/modeling/layers/reuse_attention.py","lineNumber":577,"sourceCode":"          tf.einsum(self._combine_equation, self._dropout_layer(\n              reuse_scores, training=training), value[0]))\n    # Partial or no reuse\n    if self._reuse_heads < self._num_heads:\n      attention_output.append(\n          tf.einsum(self._combine_equation, self._dropout_layer(\n              new_scores, training=training), value[-1]))\n    return attention_output, attention_scores\n\n  def call(self,\n           query,\n           value,\n           key=None,\n           attention_mask=None,\n           return_attention_scores=False,\n           training=None,\n           reuse_attention_scores=None):\n    if self._reuse_heads > 0 and reuse_attention_scores is None:\n      raise ValueError(\"reuse_attention_scores cannot be None when \"\n                       \"reuse_attention is True or > 0.\")\n    if not self._built_from_signature:\n      self._build_from_signature(query=query, value=value, key=key)\n    if key is None:\n      key = value\n\n    #   N = `num_attention_heads`\n    #   H = `size_per_head`\n    # `value` = [B, S, N, H]\n    value = [vd(value) for vd in self._value_dense]\n    if self._reuse_heads < self._num_heads:\n      # `query` = [B, T, N ,H]\n      query = self._query_dense(query)\n\n      # `key` = [B, S, N, H]\n      key = self._key_dense(key)\n    else:\n      query, key = None, None","sourceCodeStart":559,"sourceCodeEnd":595,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/modeling/layers/reuse_attention.py#L559-L595","documentation":"Error \"reuse_attention_scores cannot be None when reuse_attention is True or > 0.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/modeling/layers/reuse_attention.py:577 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"}