code: def sanitize_ptb_tokenized_string(text: str) -> str:
      """
      Sanitizes string that was tokenized using PTBTokenizer
      """
      tokens = text.split(" ")
      if len(tokens) == 0:
          return text
  
      # Replace quotation marks and parentheses
      token_map = {
          "``": '"',
          "''": '"',
          "-lrb-": "(",
          "-rrb-": ")",
          "-lsb-": "[",
          "-rsb-": "]",
          "-lcb-": "{",
          "-rcb-": "}",
          "<s>": "",
          "</s>": "",
      }
  
      # Merge punctuation with previous tokens
      punct_forward = {"`", "$", "#"}
      punct_backward = {".", ",", "!", "?", ":", ";", "%", "'"}
  
      # Exact matches that get merged forward or backward
      em_forward = {"(", "[", "{"}
      em_backward = {"n't", "na", ")", "]", "}"}
  
      new_tokens: List[str] = []
  
      merge_fwd = False
      for i, orig_token in enumerate(tokens):
          tokens[i] = (
              token_map[orig_token.lower()]
              if orig_token.lower() in token_map
              else orig_token
          )
          new_token = tokens[i].lower()
  
          # merge_fwd was set by previous token, so it should be prepended to current token
          if merge_fwd:
              tokens[i] = tokens[i - 1] + tokens[i]
  
          if len(tokens[i]) == 0:
              continue
  
          # Special cases for `` and '', those tells us if " is the start or end of a quotation.
          # Also always merge tokens starting with ' backward and don't merge back if we just merged forward
          merge_bckwd = not merge_fwd and (
              orig_token == "''"
              or new_token in em_backward
              or new_token.startswith("'")
              or all(c in punct_backward for c in new_token)
          )
          merge_fwd = (
              orig_token == "``"
              or new_token in em_forward
              or all(c in punct_forward for c in new_token)
          )
  
          if merge_bckwd and new_tokens:
              new_tokens[-1] += tokens[i]
          elif not new_tokens or not merge_fwd or i == len(tokens) - 1:
              new_tokens.append(tokens[i])
  
      return " ".join(new_tokens)
  
imports: import hashlib
  import io
  from datetime import timedelta
  import importlib
  import json
  import logging
  import os
  import pkgutil
  import random
  import sys
  import signal
  from contextlib import contextmanager
  from itertools import islice, zip_longest
  from pathlib import Path
  from typing import Any, Callable, Dict, Generator, Iterable, Iterator, List, Optional, Tuple, TypeVar, Union, Sequence, Set
  import dill
  import numpy
  import spacy
  import torch
  import torch.distributed
  from spacy.cli.download import download
  from spacy.language import Language
  import base58
  from allennlp.common.checks import log_pytorch_version_info
  from allennlp.common.params import Params
label_desc: Use image node_id 24 for calling a global function with example usage: sanitize_ptb_tokenized_string(text) and returns: str, text