{"record":{"id":"299e81bc73977287","repo":"tensorflow/models","slug":"invalid-attention-bias-type-s","errorCode":null,"errorMessage":"Invalid attention bias type: %s","messagePattern":"Invalid attention bias type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/nhnet/decoder.py","lineNumber":146,"sourceCode":"      # Gets the cache for decoding.\n      if cache is None:\n        output_tensor, _ = self.layers[layer_idx](transformer_inputs)\n      else:\n        cache_layer_idx = str(layer_idx)\n        output_tensor, cache[cache_layer_idx] = self.layers[layer_idx](\n            transformer_inputs,\n            cache=cache[cache_layer_idx],\n            decode_loop_step=decode_loop_step)\n    return output_tensor, cache\n\n\ndef get_attention_bias(input_tensor,\n                       bias_type,\n                       padding_value=0,\n                       max_length=None):\n  \"\"\"A helper function to get various attention bias tensors.\"\"\"\n  if bias_type not in (\"single_cross\", \"multi_cross\", \"decoder_self\"):\n    raise ValueError(\"Invalid attention bias type: %s\" % bias_type)\n  if bias_type == \"single_cross\":\n    length = tf_utils.get_shape_list(input_tensor, expected_rank=2)[1]\n    bias = transformer_utils.get_padding_bias(\n        input_tensor, padding_value=padding_value)\n  elif bias_type == \"multi_cross\":\n    length = tf_utils.get_shape_list(input_tensor, expected_rank=3)[2]\n    padding = transformer_utils.get_padding(\n        input_tensor, padding_value=padding_value)\n    bias = padding * -1e9\n  else:\n    if max_length is not None:\n      length = max_length\n    else:\n      length = tf_utils.get_shape_list(input_tensor, expected_rank=2)[1]\n    bias = transformer_utils.get_decoder_self_attention_bias(length)\n\n  return tf.where(bias < 0, tf.zeros_like(bias), tf.ones_like(bias))\n","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/nhnet/decoder.py#L128-L164","documentation":"Error \"Invalid attention bias type: %s\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/nhnet/decoder.py:146 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"}