Skip to content

Commit 58a03a6

Browse files
HaukurPallCopilot
andauthored
Update src/icebert_pos/interface.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 85115a7 commit 58a03a6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/icebert_pos/interface.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,13 @@ def batch_sentences(
158158
Returns:
159159
Batched input tensors
160160
"""
161-
from torch.nn.utils.rnn import pad_sequence
161+
try:
162+
from torch.nn.utils.rnn import pad_sequence
163+
except ModuleNotFoundError as e:
164+
raise ImportError(
165+
"The 'torch' library is required for this function. Please install it using "
166+
"'pip install icebert-pos[torch]'."
167+
) from e
162168

163169
# Unzip the list of tuples into separate lists
164170
input_ids, attention_mask, word_mask = zip(*sentence_tensors, strict=True)

0 commit comments

Comments
 (0)