{"record":{"id":"70235d8d1173d4c8","repo":"tensorflow/models","slug":"the-slicing-values-passed-to-the-slicing-spec-must","errorCode":null,"errorMessage":"The slicing values passed to the slicing spec must be unique. Got {slicing_values}.","messagePattern":"The slicing values passed to the slicing spec must be unique\\. Got (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/recommendation/uplift/metrics/sliced_metric.py","lineNumber":105,"sourceCode":"      values, or has slicing values of different types.\n    \"\"\"\n    super().__init__(name=name or f\"sliced_{metric.name}\", dtype=metric.dtype)\n\n    if not slicing_spec:\n      raise ValueError(\"The slicing spec must be a non-empty dictionary.\")\n\n    slice_names, slicing_values = zip(*slicing_spec.items())\n    if not isinstance(slicing_values[0], (int, bool, str)) or not all(\n        isinstance(k, type(slicing_values[0])) for k in slicing_values\n    ):\n      raise ValueError(\n          \"All slicing values in the slicing spec must be one of `int`, \"\n          \"`bool`, or `str`, and all values must have the same type. \"\n          f\"Got types: {list(map(type, slicing_values))}.\"\n      )\n\n    if len(slicing_values) > len(set(slicing_values)):\n      raise ValueError(\n          \"The slicing values passed to the slicing spec must be unique. Got \"\n          f\"{slicing_values}.\"\n      )\n\n    # TODO(b/276811843): Look into validating whether `metric` accepts\n    # `sample_weights` in its `update_state` method.\n\n    # Instance fully owns a deep copy of the metric.\n    self._metric = copy.deepcopy(metric)\n    self._slice_names = list(slice_names)\n    self._slicing_values = list(slicing_values)\n    self._slicing_values_tensors = [\n        tf.constant(v, slicing_feature_dtype) for v in slicing_values\n    ]\n    self._slicing_feature_dtype = self._slicing_values_tensors[0].dtype\n    self._sliced_metrics = [copy.deepcopy(metric) for _ in self._slicing_values]\n\n  def update_state(","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/recommendation/uplift/metrics/sliced_metric.py#L87-L123","documentation":"Error \"The slicing values passed to the slicing spec must be unique. Got {slicing_values}.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/recommendation/uplift/metrics/sliced_metric.py:105 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"}