{"record":{"id":"fe86d68cf43199cc","repo":"keras-team/keras","slug":"key-already-exist-in-the-layoutmap-with-value-s","errorCode":null,"errorMessage":"{key} already exist in the LayoutMap with value {self._layout_map[key]}. Please make sure to not use duplicated keys.","messagePattern":"(.+?) already exist in the LayoutMap with value (.+?)\\. Please make sure to not use duplicated keys\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/distribution/distribution_lib.py","lineNumber":765,"sourceCode":"                f\"Path '{key}' matches multiple layout \"\n                f\"specification keys: {matching_keys}. Please make \"\n                \"sure each tensor/variable path only matches at most \"\n                \"one layout specification key in the LayoutMap.\"\n            )\n        elif len(matching_keys) == 1:\n            return self._layout_map[matching_keys[0]]\n        return None\n\n    def __setitem__(self, key, layout):\n        \"\"\"Insert TensorLayout to the LayoutMap.\n\n        Args:\n            key: String key for the `TensorLayout`.\n            layout: The `TensorLayout`. As a shortcut, tuple of string and None\n                are also acceptable, and will be converted to `TensorLayout`.\n        \"\"\"\n        if key in self._layout_map:\n            raise ValueError(\n                f\"{key} already exist in the LayoutMap with \"\n                f\"value {self._layout_map[key]}. Please make sure to \"\n                \"not use duplicated keys.\"\n            )\n        if isinstance(layout, tuple):\n            layout = TensorLayout(axes=layout, device_mesh=None)\n\n        if not isinstance(layout, TensorLayout):\n            raise ValueError(\n                f\"{layout} should be a TensorLayout type, got {type(layout)}\"\n            )\n        self._maybe_populate_device_mesh(layout)\n        self._layout_map[key] = layout\n\n    def __delitem__(self, key):\n        # let the dict to handle the key missing error\n        return self._layout_map.pop(key)\n","sourceCodeStart":747,"sourceCodeEnd":783,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/distribution/distribution_lib.py#L747-L783","documentation":"Raised by LayoutMap.__setitem__ in keras/src/distribution/distribution_lib.py: the map forbids re-assigning an existing key, and the key being inserted already has an entry (with the value shown). Inserting again would silently overwrite the previous TensorLayout, so the guard raises instead.","triggerScenarios":"Thrown at keras/src/distribution/distribution_lib.py:765 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a distinct key/pattern for the new layout","Delete or rebuild the LayoutMap if you truly need to replace a mapping","Check loops that insert layouts for re-visited keys"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}