{"record":{"id":"76cede0501ebdc82","repo":"tensorflow/models","slug":"the-output-of-the-given-metric-must-either-be-a-t","errorCode":null,"errorMessage":"The output of the given metric must either be a `tf.Tensor` or a `dict[str, tf.Tensor]`, but got unsupported output: {metric_result}.","messagePattern":"The output of the given metric must either be a `tf\\.Tensor` or a `dict\\[str, tf\\.Tensor\\]`, but got unsupported output: (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/recommendation/uplift/metrics/sliced_metric.py","lineNumber":190,"sourceCode":"    slice_results = [metric.result() for metric in self._sliced_metrics]\n\n    if isinstance(metric_result, tf.Tensor):\n      results = {metric_name: metric_result}\n      slice_names = (f\"{metric_name}/{name}\" for name in self._slice_names)\n      results.update(zip(slice_names, slice_results))\n      return results\n\n    if isinstance(metric_result, dict) and all(\n        isinstance(result, tf.Tensor) for result in metric_result.values()\n    ):\n      results = {**metric_result}\n      for slice_name, slice_result in zip(self._slice_names, slice_results):\n        result_names, result_values = zip(*slice_result.items())\n        slice_names = [f\"{name}/{slice_name}\" for name in result_names]\n        results.update(zip(slice_names, result_values))\n      return results\n\n    raise ValueError(\n        \"The output of the given metric must either be a `tf.Tensor` or \"\n        \"a `dict[str, tf.Tensor]`, but got unsupported output: \"\n        f\"{metric_result}.\"\n    )\n\n  def reset_state(self):\n    self._metric.reset_state()\n    for metric in self._sliced_metrics:\n      metric.reset_state()\n\n  def get_config(self):\n    return {\n        \"name\": self.name,\n        \"metric\": tf_keras.metrics.serialize(self._metric),\n        \"slicing_spec\": dict(zip(self._slice_names, self._slicing_values)),\n        \"slicing_feature_dtype\": self._slicing_feature_dtype.name,\n    }\n","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/recommendation/uplift/metrics/sliced_metric.py#L172-L208","documentation":"Error \"The output of the given metric must either be a `tf.Tensor` or a `dict[str, tf.Tensor]`, but got unsupported output: {metric_result}.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/recommendation/uplift/metrics/sliced_metric.py:190 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"}