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: Convert token to BPE.
  
  :param word:
      token to convert
  
  :return bpe_encoding:
      string bpe encoding
docstr_tok: ["Convert","token","to","BPE",".",":","param","word",":","token","to","convert",":","return","bpe_encoding",":","string","bpe","encoding"]
code: def bpe(self, orig: str) -> List[str]:
      """
      Convert token to BPE.
  
      :param word:
          token to convert
  
      :return bpe_encoding:
          string bpe encoding
      """
      if self.version == (0, 2):
          word = list(orig[:-1]) + [orig[-1] + "</w>"]
      else:
          raise NotImplementedError
  
      pairs = self.get_pairs(word)
      if len(pairs) == 0:
          return [orig]
  
      while True:
          min_rank = self.bpe_codes.get(
              "\n".join(pairs[0]), float("inf")
          )
          bigram = pairs[0]
          for pair in pairs[1:]:
              current_rank = self.bpe_codes.get(
                  "\n".join(pair), float("inf")
              )
              if current_rank < min_rank:
                  min_rank = current_rank
                  bigram = pair
          if "\n".join(bigram) not in self.bpe_codes:
              break
          first, second = bigram
          new_word: List[str] = []
          i = 0
          while i < len(word):
              found = False
              for j in range(i, len(word)):
                  if word[j] == first:
                      new_word.extend(word[i:j])
                      i = j
                      found = True
                      break
              if not found:
                  new_word.extend(word[i:])
                  break
  
              if (
                  word[i] == first
                  and i < len(word) - 1
                  and word[i + 1] == second
              ):
                  new_word.append(first + second)
                  i += 2
              else:
                  new_word.append(word[i])
                  i += 1
          word = new_word.copy()
          if len(word) == 1:
              break
          else:
              pairs = self.get_pairs(word)
  
      # don't print end-of-word symbols
      if word[-1] == "</w>":
          word = word[:-1]
      elif word[-1].endswith("</w>"):
          word = word[:-1] + [word[-1].replace("</w>", "")]
      return word
  
imports: from typing import Dict, List, Tuple
  import torch.jit
label_desc: Use image node_id 5 for calling the ScriptableSubwordBpeHelper obj's underlying member method code with example usage: obj.bpe(orig) and returns: word, list