Skip to content

Commit b49369d

Browse files
committed
check if trasnformers has PreTrainedTokenizerBase
1 parent 10f86dd commit b49369d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/nlp/utils/py_utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,12 @@ def _no_cache_fields(obj):
345345
try:
346346
import transformers as tr
347347

348-
if isinstance(obj, tr.PreTrainedTokenizerBase) and hasattr(obj, "cache") and isinstance(obj.cache, dict):
348+
if (
349+
hasattr(tr, "PreTrainedTokenizerBase")
350+
and isinstance(obj, tr.PreTrainedTokenizerBase)
351+
and hasattr(obj, "cache")
352+
and isinstance(obj.cache, dict)
353+
):
349354
with temporary_assignment(obj, "cache", {}):
350355
yield
351356
else:

0 commit comments

Comments
 (0)