{"record":{"id":"ee776095a72e9210","repo":"tensorflow/models","slug":"if-sequence-output-is-not-in-encoder-output-lat","errorCode":null,"errorMessage":"If `sequence_output` is not in encoder output,`latent_output` must be in encoder output.","messagePattern":"If `sequence_output` is not in encoder output,`latent_output` must be in encoder output\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/perceiver/modeling/models/classifier.py","lineNumber":193,"sourceCode":"        'input_mask': input_mask,\n        'input_type_ids': input_type_ids,\n    }\n    encoder_outputs = self._network(encoder_inputs)\n\n    if 'sequence_output' not in encoder_outputs:\n      if 'latent_output' in encoder_outputs:\n        z = encoder_outputs['latent_output']\n        decoder_inputs = {'latent_output': z, 'input_mask': input_mask}\n        decoder_output = self._decoder(decoder_inputs)  # pyrefly: ignore[not-callable]\n\n        outputs = dict()\n        if isinstance(decoder_output, dict):\n          outputs = decoder_output\n        else:\n          raise ValueError('decoder\\'s output should be a dict,'\n                           f'but got {decoder_output}')\n      else:\n        raise ValueError('If `sequence_output` is not in encoder output,'\n                         '`latent_output` must be in encoder output.')\n    else:\n      outputs = encoder_outputs\n\n    return self.classifier(outputs['sequence_output'])\n\n  @property\n  def checkpoint_items(self):\n    \"\"\"Returns a dictionary of items to be additionally checkpointed.\"\"\"\n    items = dict(encoder=self._network, decoder=self._decoder)\n    if hasattr(self.classifier, 'checkpoint_items'):\n      for key, item in self.classifier.checkpoint_items.items():\n        items['.'.join([self.classifier.name, key])] = item\n    return items\n\n  def get_config(self):\n    \"\"\"Return the configuration to set up this object using `from_config`.\"\"\"\n    return self._config","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/perceiver/modeling/models/classifier.py#L175-L211","documentation":"Encoder-output guard in the classifier's call: 'sequence_output' is absent and 'latent_output' is also missing from the encoder's output dict, so there is no representation to decode or classify from.","triggerScenarios":"Thrown at official/projects/perceiver/modeling/models/classifier.py:193 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use the standard Perceiver encoder that returns latent_output (and/or sequence_output)","Check that a custom encoder network's output dict uses the expected keys"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}