MCPcopy Create free account
hub / github.com/modelscope/modelscope / _findall

Function _findall

modelscope/preprocessors/templates/template.py:1662–1675  ·  view source on GitHub ↗

Find the index of a token in the token_list.

(token_list: List[int], sub_token_list: Union[int, List[int]])

Source from the content-addressed store, hash-verified

1660
1661
1662def _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
1678class DeepseekVLTemplate(Template):

Callers 10

_encodeMethod · 0.70
_encodeMethod · 0.70
_encodeMethod · 0.70
_encodeMethod · 0.70
_encodeMethod · 0.70
_encodeMethod · 0.70
_encodeMethod · 0.70
_encodeMethod · 0.70
_encodeMethod · 0.70
_encodeMethod · 0.70

Calls 2

indexMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…