"docs/vscode:/vscode.git/clone" did not exist on "3b4d3d09fd8cee2b4cc2fdd7c12ea51ca147c6cc"
Unverified Commit c35bb6de authored by Yih-Dar's avatar Yih-Dar Committed by GitHub
Browse files

Add `__len__` method to `_LazyAutoMapping` (#21522)



Add `__len__` method to `_LazyAutoMapping`
Co-authored-by: default avatarydshieh <ydshieh@users.noreply.github.com>
parent 9960506c
......@@ -582,6 +582,10 @@ class _LazyAutoMapping(OrderedDict):
self._extra_content = {}
self._modules = {}
def __len__(self):
common_keys = set(self._config_mapping.keys()).intersection(self._model_mapping.keys())
return len(common_keys) + len(self._extra_content)
def __getitem__(self, key):
if key in self._extra_content:
return self._extra_content[key]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment