{"record":{"id":"89960e95f54aa2ed","repo":"tensorflow/models","slug":"exactly-one-of-bert-config-and-encoder-config","errorCode":null,"errorMessage":"Exactly one of `bert_config` and `encoder_config` can be specified, but got %s and %s","messagePattern":"Exactly one of `bert_config` and `encoder_config` can be specified, but got (.+?) and (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/tools/export_tfhub_lib.py","lineNumber":101,"sourceCode":"  \"\"\"Creates the model to export and the model to restore the checkpoint.\n\n  Args:\n    bert_config: A legacy `BertConfig` to create a `BertEncoder` object. Exactly\n      one of encoder_config and bert_config must be set.\n    encoder_config: An `EncoderConfig` to create an encoder of the configured\n      type (`BertEncoder` or other).\n    with_mlm: A bool to control the second component of the result. If True,\n      will create a `BertPretrainerV2` object; otherwise, will create a\n      `BertEncoder` object.\n\n  Returns:\n    A Tuple of (1) a Keras model that will be exported, (2) a `BertPretrainerV2`\n    object or `BertEncoder` object depending on the value of `with_mlm`\n    argument, which contains the first model and will be used for restoring\n    weights from the checkpoint.\n  \"\"\"\n  if (bert_config is not None) == (encoder_config is not None):\n    raise ValueError(\"Exactly one of `bert_config` and `encoder_config` \"\n                     \"can be specified, but got %s and %s\" %\n                     (bert_config, encoder_config))\n\n  if bert_config is not None:\n    encoder = get_bert_encoder(bert_config)\n  else:\n    encoder = encoders.build_encoder(encoder_config)\n\n  # Convert from list of named inputs to dict of inputs keyed by name.\n  # Only the latter accepts a dict of inputs after restoring from SavedModel.\n  if isinstance(encoder.inputs, list) or isinstance(encoder.inputs, tuple):\n    encoder_inputs_dict = {x.name: x for x in encoder.inputs}\n  else:\n    # encoder.inputs by default is dict for BertEncoderV2.\n    encoder_inputs_dict = encoder.inputs\n  encoder_output_dict = encoder(encoder_inputs_dict)\n  # For interchangeability with other text representations,\n  # add \"default\" as an alias for BERT's whole-input reptesentations.","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/tools/export_tfhub_lib.py#L83-L119","documentation":"Error \"Exactly one of `bert_config` and `encoder_config` can be specified, but got %s and %s\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/tools/export_tfhub_lib.py:101 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"}