docstr: Test TorchScriptable code for splitting tokens against reference subword BPE
  version.
docstr_tok: ["Test","TorchScriptable","code","for","splitting","tokens","against","reference","subword","BPE","version","."]
code: def test_subword_bpe_token_splitter(self):
      """
      Test TorchScriptable code for splitting tokens against reference subword BPE
      version.
      """
  
      from parlai.scripts.torchscript import TorchScript
      from parlai.torchscript.tokenizer import (
          ScriptableSubwordBpeHelper,
      )
  
      # Params
      tasks = ["dialogue_safety:standard"]
      splitter = regex.compile(r"\w+|[^\w\s]", regex.UNICODE)
  
      for task in tasks:
          opt = TorchScript.setup_args().parse_kwargs(
              task=task, datatype="train:ordered"
          )
          agent = RepeatLabelAgent(opt)
          teacher = create_task(opt, agent).get_task_agent()
          num_examples = teacher.num_examples()
  
          print(
              f"\nStarting to test {num_examples:d} examples for the "
              f"{task} task."
          )
          for idx, message in enumerate(teacher):
              if idx % 10000 == 0:
                  print(f"Testing example #{idx:d}.")
              text = message["text"]
              canonical_tokens = splitter.findall(text)
              scriptable_tokens = ScriptableSubwordBpeHelper.findall(
                  text
              )
              self.assertEqual(canonical_tokens, scriptable_tokens)
              if idx + 1 == num_examples:
                  break
  
file_path: ParlAI/tests/nightly/gpu/test_torchscript.py
imports: import os
  import regex
  import unittest
  import parlai.utils.testing
  from parlai.agents.repeat_label.repeat_label import RepeatLabelAgent
  from parlai.core.agents import create_agent
  from parlai.core.params import ParlaiParser
  from parlai.core.worlds import create_task
  from parlai.utils.bpe import Gpt2BpeHelper
label_desc: Use image node_id 2 for calling the TestTorchScript obj's underlying member method code with example usage: obj.test_subword_bpe_token_splitter() without return types