(text)
| 421 | **kwargs |
| 422 | ) -> BatchEncoding: |
| 423 | def get_input_ids(text): |
| 424 | if isinstance(text, str): |
| 425 | tokens = self.tokenize(text, **kwargs) |
| 426 | return self.convert_tokens_to_ids(tokens) |
| 427 | elif isinstance(text, (list, tuple)) and len(text) > 0 and isinstance(text[0], str): |
| 428 | if is_pretokenized: |
| 429 | tokens = list(itertools.chain(*(self.tokenize(t, is_pretokenized=True, **kwargs) for t in text))) |
| 430 | return self.convert_tokens_to_ids(tokens) |
| 431 | else: |
| 432 | return self.convert_tokens_to_ids(text) |
| 433 | elif isinstance(text, (list, tuple)) and len(text) > 0 and isinstance(text[0], int): |
| 434 | return text |
| 435 | else: |
| 436 | if is_pretokenized: |
| 437 | raise ValueError( |
| 438 | f"Input {text} is not valid. Should be a string or a list/tuple of strings when `is_pretokenized=True`." |
| 439 | ) |
| 440 | else: |
| 441 | raise ValueError( |
| 442 | f"Input {text} is not valid. Should be a string, a list/tuple of strings or a list/tuple of integers." |
| 443 | ) |
| 444 | |
| 445 | if return_offsets_mapping: |
| 446 | raise NotImplementedError( |
nothing calls this directly
no test coverage detected