From 9d216017be9cb416f41c4a6be71af69f44849dca Mon Sep 17 00:00:00 2001 From: Arthur <48595927+ArthurZucker@users.noreply.github.com> Date: Thu, 14 Dec 2023 08:46:10 +0100 Subject: [PATCH] [`SeamlessM4TTokenizer`] Safe import (#28026) safe import --- .../seamless_m4t/tokenization_seamless_m4t_fast.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/transformers/models/seamless_m4t/tokenization_seamless_m4t_fast.py b/src/transformers/models/seamless_m4t/tokenization_seamless_m4t_fast.py index 8ca03ac6747bb7..b7bedfb38a6295 100644 --- a/src/transformers/models/seamless_m4t/tokenization_seamless_m4t_fast.py +++ b/src/transformers/models/seamless_m4t/tokenization_seamless_m4t_fast.py @@ -25,11 +25,13 @@ TextInput, ) from ...tokenization_utils_fast import PreTrainedTokenizerFast -from ...utils import PaddingStrategy, logging -from .tokenization_seamless_m4t import ( - SeamlessM4TTokenizer, -) +from ...utils import PaddingStrategy, is_sentencepiece_available, logging + +if is_sentencepiece_available(): + from .tokenization_seamless_m4t import SeamlessM4TTokenizer +else: + SeamlessM4TTokenizer = None logger = logging.get_logger(__name__)