{"record":{"id":"ff48c9ec370be3ac","repo":"tensorflow/models","slug":"masked-tokens-must-be-provided-in-order-to-initi","errorCode":null,"errorMessage":"`masked_tokens` must be provided in order to initialize the query stream in `TwoStreamRelativeAttention`.","messagePattern":"`masked_tokens` must be provided in order to initialize the query stream in `TwoStreamRelativeAttention`\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/modeling/networks/xlnet_base.py","lineNumber":625,"sourceCode":"    \"\"\"Implements call() for the layer.\"\"\"\n    input_ids = inputs[\"input_ids\"]\n    segment_ids = inputs[\"segment_ids\"]\n    input_mask = inputs[\"input_mask\"]\n    state = inputs[\"state\"]\n    permutation_mask = inputs[\"permutation_mask\"]\n    target_mapping = inputs[\"target_mapping\"]\n    masked_tokens = inputs[\"masked_tokens\"]\n\n    batch_size = tf.shape(input_ids)[0]\n    seq_length = tf.shape(input_ids)[1]\n    if state is not None:\n      memory_length = tf.shape(state[0])[1]\n    else:\n      memory_length = 0\n    total_length = memory_length + seq_length\n\n    if self._two_stream and masked_tokens is None:\n      raise ValueError(\"`masked_tokens` must be provided in order to \"\n                       \"initialize the query stream in \"\n                       \"`TwoStreamRelativeAttention`.\")\n    if masked_tokens is not None and not self._two_stream:\n      logging.warning(\"`masked_tokens` is provided but `two_stream` is not \"\n                      \"enabled. Please enable `two_stream` to enable two \"\n                      \"stream attention.\")\n\n    if input_mask is not None:\n      dtype = input_mask.dtype\n    elif permutation_mask is not None:\n      dtype = permutation_mask.dtype\n    else:\n      dtype = tf.int32\n    query_attention_mask, content_attention_mask = _compute_attention_mask(\n        input_mask=input_mask,\n        permutation_mask=permutation_mask,\n        attention_type=self._attention_type,\n        seq_length=seq_length,","sourceCodeStart":607,"sourceCodeEnd":643,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/modeling/networks/xlnet_base.py#L607-L643","documentation":"Error \"`masked_tokens` must be provided in order to initialize the query stream in `TwoStreamRelativeAttention`.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/modeling/networks/xlnet_base.py:625 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"}