{"record":{"id":"d06792028b64bbe6","repo":"tensorflow/models","slug":"all-inputs-for-packing-must-have-the-same-known-ra","errorCode":null,"errorMessage":"All inputs for packing must have the same known rank, found ranks %s","messagePattern":"All inputs for packing must have the same known rank, found ranks (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/modeling/layers/text_layers.py","lineNumber":567,"sourceCode":"        truncator=self.truncator)\n\n  @staticmethod\n  def bert_pack_inputs(inputs: Union[tf.RaggedTensor, List[tf.RaggedTensor]],\n                       seq_length: Union[int, tf.Tensor],\n                       start_of_sequence_id: Union[int, tf.Tensor],\n                       end_of_segment_id: Union[int, tf.Tensor],\n                       padding_id: Union[int, tf.Tensor],\n                       truncator=\"round_robin\"):\n    \"\"\"Freestanding equivalent of the BertPackInputs layer.\"\"\"\n    _check_if_tf_text_installed()\n    # Sanitize inputs.\n    if not isinstance(inputs, (list, tuple)):\n      inputs = [inputs]\n    if not inputs:\n      raise ValueError(\"At least one input is required for packing\")\n    input_ranks = [rt.shape.rank for rt in inputs]\n    if None in input_ranks or len(set(input_ranks)) > 1:\n      raise ValueError(\"All inputs for packing must have the same known rank, \"\n                       \"found ranks \" + \",\".join(input_ranks))\n    # Flatten inputs to [batch_size, (tokens)].\n    if input_ranks[0] > 2:\n      inputs = [rt.merge_dims(1, -1) for rt in inputs]\n    # In case inputs weren't truncated (as they should have been),\n    # fall back to some ad-hoc truncation.\n    num_special_tokens = len(inputs) + 1\n    if truncator == \"round_robin\":\n      trimmed_segments = text.RoundRobinTrimmer(seq_length -  # pyrefly: ignore[missing-attribute]\n                                                num_special_tokens).trim(inputs)\n    elif truncator == \"waterfall\":\n      trimmed_segments = text.WaterfallTrimmer(  # pyrefly: ignore[missing-attribute]\n          seq_length - num_special_tokens).trim(inputs)\n    else:\n      raise ValueError(\"Unsupported truncator: %s\" % truncator)\n    # Combine segments.\n    segments_combined, segment_ids = text.combine_segments(  # pyrefly: ignore[missing-attribute]\n        trimmed_segments,","sourceCodeStart":549,"sourceCodeEnd":585,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/modeling/layers/text_layers.py#L549-L585","documentation":"Error \"All inputs for packing must have the same known rank, found ranks %s\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/modeling/layers/text_layers.py:567 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"}