class_docstr: Version of parlai.utils.bpe.SubwordBPEHelper that can be TorchScripted.
class_docstr_tok: ["Version","of","parlai.utils.bpe.SubwordBPEHelper","that","can","be","TorchScripted","."]
docstr: Split tokens in a manner that replicates parlai.utils.bpe.Gpt2BpeHelper.
docstr_tok: ["Split","tokens","in","a","manner","that","replicates","parlai.utils.bpe.Gpt2BpeHelper","."]
code: def findall(cls, text: str) -> List[str]:
      """
      Split tokens in a manner that replicates parlai.utils.bpe.Gpt2BpeHelper.
      """
      tokens: List[str] = []
      idx = 0
      num_passes = 0
      while idx < len(text):
          num_passes += 1
          if num_passes > 10000:
              raise RuntimeError(
                  "*** Infinite loop in ScriptableSubwordBpeHelper.findall()! ***"
              )
  
          if not text[idx].isspace():
              last_matching_idx = idx
              if is_alnum_or_underscore(text[last_matching_idx]):
                  while last_matching_idx + 1 < len(text) and (
                      text[last_matching_idx + 1].isalnum()
                      or text[last_matching_idx + 1] == "_"
                  ):
                      last_matching_idx += 1
              tokens.append(text[idx : last_matching_idx + 1])
              idx = last_matching_idx + 1
              continue
  
          # Capture runs of space characters
          last_space_idx = idx
          while (
              last_space_idx + 1 < len(text)
              and text[last_space_idx + 1].isspace()
          ):
              last_space_idx += 1
          idx = last_space_idx + 1
      return tokens
  
imports: from typing import Dict, List, Tuple
  import torch.jit
label_desc: Use image node_id 1 for calling the ScriptableSubwordBpeHelper obj's underlying member method code with example usage: obj.findall(cls, text) and returns: tokens