mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-31 02:02:21 +06:00
Add __len__
method to _LazyAutoMapping
(#21522)
Add `__len__` method to `_LazyAutoMapping` Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
parent
9960506cbe
commit
c35bb6de54
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user