{"record":{"id":"d208cb6e4cc92acc","repo":"tensorflow/models","slug":"encoder-network-s-output-should-be-either-a-list-o","errorCode":null,"errorMessage":"encoder_network's output should be either a list or a dict, but got %s","messagePattern":"encoder_network's output should be either a list or a dict, but got (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/modeling/models/bert_pretrainer.py","lineNumber":251,"sourceCode":"          (ref.name, tensor) for ref, tensor in zip(self.inputs, inputs)\n      ])\n\n    outputs = dict()\n    encoder_network_outputs = self.encoder_network(inputs)\n    if isinstance(encoder_network_outputs, list):\n      outputs['pooled_output'] = encoder_network_outputs[1]\n      # When `encoder_network` was instantiated with return_all_encoder_outputs\n      # set to True, `encoder_network_outputs[0]` is a list containing\n      # all transformer layers' output.\n      if isinstance(encoder_network_outputs[0], list):\n        outputs['encoder_outputs'] = encoder_network_outputs[0]\n        outputs['sequence_output'] = encoder_network_outputs[0][-1]\n      else:\n        outputs['sequence_output'] = encoder_network_outputs[0]\n    elif isinstance(encoder_network_outputs, dict):\n      outputs = encoder_network_outputs\n    else:\n      raise ValueError('encoder_network\\'s output should be either a list '\n                       'or a dict, but got %s' % encoder_network_outputs)\n    sequence_output = outputs['sequence_output']\n    # Inference may not have masked_lm_positions and mlm_logits is not needed.\n    if 'masked_lm_positions' in inputs:\n      masked_lm_positions = inputs['masked_lm_positions']\n      outputs['mlm_logits'] = self.masked_lm(\n          sequence_output, masked_positions=masked_lm_positions)\n    for cls_head in self.classification_heads:\n      cls_outputs = cls_head(sequence_output)\n      if isinstance(cls_outputs, dict):\n        outputs.update(cls_outputs)\n      else:\n        outputs[cls_head.name] = cls_outputs\n    return outputs\n\n  @property\n  def checkpoint_items(self):\n    \"\"\"Returns a dictionary of items to be additionally checkpointed.\"\"\"","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/modeling/models/bert_pretrainer.py#L233-L269","documentation":"Error \"encoder_network's output should be either a list or a dict, but got %s\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/modeling/models/bert_pretrainer.py:251 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"}