{"record":{"id":"eb8a9a26c978a510","repo":"keras-team/keras","slug":"layout-should-be-a-tensorlayout-type-got-type","errorCode":null,"errorMessage":"{layout} should be a TensorLayout type, got {type(layout)}","messagePattern":"(.+?) should be a TensorLayout type, got (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/distribution/distribution_lib.py","lineNumber":774,"sourceCode":"    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\n    def __len__(self):\n        return len(self._layout_map)\n\n    def __iter__(self):\n        return iter(self._layout_map)\n\n    @property\n    def device_mesh(self):\n        return self._device_mesh","sourceCodeStart":756,"sourceCodeEnd":792,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/distribution/distribution_lib.py#L756-L792","documentation":"Error \"{layout} should be a TensorLayout type, got {type(layout)}\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/distribution/distribution_lib.py:774 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":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}