code: def test_sanitize_ptb_tokenized_string(self):
      def create_surrounding_test_case(
          start_ptb_token, end_ptb_token, start_token, end_token
      ):
          return (
              "a {} b c {} d".format(start_ptb_token, end_ptb_token),
              "a {}b c{} d".format(start_token, end_token),
          )
  
      def create_fwd_token_test_case(fwd_token):
          return "a {} b".format(fwd_token), "a {}b".format(fwd_token)
  
      def create_backward_token_test_case(backward_token):
          return "a {} b".format(backward_token), "a{} b".format(
              backward_token
          )
  
      punct_forward = {"`", "$", "#"}
      punct_backward = {".", ",", "!", "?", ":", ";", "%", "'"}
  
      test_cases = [
          # Parentheses
          create_surrounding_test_case("-lrb-", "-rrb-", "(", ")"),
          create_surrounding_test_case("-lsb-", "-rsb-", "[", "]"),
          create_surrounding_test_case("-lcb-", "-rcb-", "{", "}"),
          # Parentheses don't have to match
          create_surrounding_test_case("-lsb-", "-rcb-", "[", "}"),
          # Also check that casing doesn't matter
          create_surrounding_test_case("-LsB-", "-rcB-", "[", "}"),
          # Quotes
          create_surrounding_test_case("``", "''", '"', '"'),
          # Start/end tokens
          create_surrounding_test_case("<s>", "</s>", "", ""),
          # Tokens that merge forward
          *[create_fwd_token_test_case(t) for t in punct_forward],
          # Tokens that merge backward
          *[create_backward_token_test_case(t) for t in punct_backward],
          # Merge tokens starting with ' backwards
          ("I 'm", "I'm"),
          # Merge tokens backwards when matching (n't or na) (special cases, parentheses behave in the same way)
          ("I do n't", "I don't"),
          ("gon na", "gonna"),
          # Also make sure casing is preserved
          ("gon NA", "gonNA"),
          # This is a no op
          ("A b C d", "A b C d"),
      ]
  
      for ptb_string, expected in test_cases:
          actual = util.sanitize_ptb_tokenized_string(ptb_string)
          assert actual == expected
  
imports: from datetime import timedelta
  import sys
  from collections import OrderedDict
  import pytest
  import torch
  from allennlp.common import util
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.common.util import push_python_path
label_desc: Use image node_id 8 for calling the TestCommonUtils obj's underlying member method code with example usage: obj.test_sanitize_ptb_tokenized_string() and returns: str,  str, str,  str, str,  str