{"record":{"id":"9efbac1960937de8","repo":"tensorflow/models","slug":"function-or-class-registered-multiple-times","errorCode":null,"errorMessage":"Function or class {} registered multiple times.","messagePattern":"Function or class (.+?) registered multiple times\\.","errorType":"exception","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"official/core/registry.py","lineNumber":57,"sourceCode":"    \"\"\"Put fn_or_cls in the dictionary.\"\"\"\n    if isinstance(reg_key, str):\n      hierarchy = reg_key.split(\"/\")\n      collection = registered_collection\n      for h_idx, entry_name in enumerate(hierarchy[:-1]):\n        if entry_name not in collection:\n          collection[entry_name] = {}\n        collection = collection[entry_name]\n        if not isinstance(collection, dict):\n          raise KeyError(\n              \"Collection path {} at position {} already registered as \"\n              \"a function or class.\".format(entry_name, h_idx))\n      leaf_reg_key = hierarchy[-1]\n    else:\n      collection = registered_collection\n      leaf_reg_key = reg_key\n\n    if leaf_reg_key in collection:\n      raise KeyError(\"Function or class {} registered multiple times.\".format(\n          leaf_reg_key))\n\n    collection[leaf_reg_key] = fn_or_cls\n    return fn_or_cls\n  return decorator\n\n\ndef lookup(registered_collection, reg_key):\n  \"\"\"Lookup and return decorated function or class in the collection.\n\n  Lookup decorated function or class in registered_collection, in a\n  hierarchical order. For example, when\n  reg_key=\"my_model/my_exp/my_config_0\",\n  this function will return\n  registered_collection[\"my_model\"][\"my_exp\"][\"my_config_0\"].\n\n  Args:\n    registered_collection: a dictionary. The decorated function or class will be","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/core/registry.py#L39-L75","documentation":"Error \"Function or class {} registered multiple times.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/core/registry.py:57 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"}