Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/transformers/configuration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,10 @@ def name_or_path(self, value):
self._name_or_path = str(value) # Make sure that name_or_path is a string (for JSON encoding)

@property
def num_labels(self) -> int:
def num_labels(self) -> int | None:
"""
`int`: The number of labels for classification models.
`int` or `None`: The number of labels for classification models, or
`None` when `id2label` is not set.
"""
return len(self.id2label) if self.id2label is not None else None

Expand Down
Loading