Find the index of a token in the token_list.
(token_list: List[int], sub_token_list: Union[int, List[int]])
| 1660 | |
| 1661 | |
| 1662 | def _findall(token_list: List[int], sub_token_list: Union[int, List[int]]) -> List[int]: |
| 1663 | """Find the index of a token in the token_list.""" |
| 1664 | if isinstance(sub_token_list, int): |
| 1665 | sub_token_list = [sub_token_list] |
| 1666 | res = [] |
| 1667 | idx = -1 |
| 1668 | try: |
| 1669 | while True: |
| 1670 | idx = token_list.index(sub_token_list[0], idx + 1) |
| 1671 | if len(sub_token_list) == 1 or sub_token_list == token_list[idx:idx + len(sub_token_list)]: |
| 1672 | res.append(idx) |
| 1673 | except ValueError: |
| 1674 | pass |
| 1675 | return res |
| 1676 | |
| 1677 | |
| 1678 | class DeepseekVLTemplate(Template): |
no test coverage detected
searching dependent graphs…