Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
841f0715
Unverified
Commit
841f0715
authored
Aug 25, 2020
by
Yohei Tamura
Committed by
GitHub
Aug 25, 2020
Browse files
Add typing.overload for convert_ids_tokens (#6637)
* add overload for type checker * black
parent
0f16dd0a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
1 deletion
+9
-1
src/transformers/tokenization_utils.py
src/transformers/tokenization_utils.py
+9
-1
No files found.
src/transformers/tokenization_utils.py
View file @
841f0715
...
@@ -20,7 +20,7 @@ import itertools
...
@@ -20,7 +20,7 @@ import itertools
import
logging
import
logging
import
re
import
re
import
unicodedata
import
unicodedata
from
typing
import
Any
,
Dict
,
List
,
Optional
,
Tuple
,
Union
from
typing
import
Any
,
Dict
,
List
,
Optional
,
Tuple
,
Union
,
overload
from
.file_utils
import
add_end_docstrings
from
.file_utils
import
add_end_docstrings
from
.tokenization_utils_base
import
(
from
.tokenization_utils_base
import
(
...
@@ -657,6 +657,14 @@ class PreTrainedTokenizer(PreTrainedTokenizerBase):
...
@@ -657,6 +657,14 @@ class PreTrainedTokenizer(PreTrainedTokenizerBase):
"""
"""
return
[
0
]
*
((
len
(
token_ids_1
)
if
token_ids_1
else
0
)
+
len
(
token_ids_0
))
return
[
0
]
*
((
len
(
token_ids_1
)
if
token_ids_1
else
0
)
+
len
(
token_ids_0
))
@
overload
def
convert_ids_to_tokens
(
self
,
ids
:
int
,
skip_special_tokens
:
bool
=
False
)
->
str
:
...
@
overload
def
convert_ids_to_tokens
(
self
,
ids
:
List
[
int
],
skip_special_tokens
:
bool
=
False
)
->
List
[
str
]:
...
def
convert_ids_to_tokens
(
def
convert_ids_to_tokens
(
self
,
ids
:
Union
[
int
,
List
[
int
]],
skip_special_tokens
:
bool
=
False
self
,
ids
:
Union
[
int
,
List
[
int
]],
skip_special_tokens
:
bool
=
False
)
->
Union
[
str
,
List
[
str
]]:
)
->
Union
[
str
,
List
[
str
]]:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment