code: def restore_token_case(word, word_tokens):
      # remove repeated "▁" and "_" from word as that is what the tokenizer will do
      while "▁▁" in word:
          word = word.replace("▁▁", "▁")
  
      while "__" in word:
          word = word.repalce("__", "_")
  
      word_tokens_cased = []
      word_char_pointer = 0
  
      for token in word_tokens:
          token_cased = ""
  
          for token_char in token:
              if token_char == word[word_char_pointer]:
                  token_cased += token_char
                  word_char_pointer += 1
  
              else:
                  if token_char.upper() == word[
                      word_char_pointer
                  ] or is_sub_or_superscript_pair(
                      token_char, word[word_char_pointer]
                  ):
                      token_cased += token_char.upper()
                      word_char_pointer += 1
                  else:
                      if token_char == "▁" or token_char == "_":
                          if (
                              word[word_char_pointer] == "▁"
                              or word[word_char_pointer] == "_"
                          ):
                              token_cased += token_char
                              word_char_pointer += 1
                          elif word_char_pointer == 0:
                              token_cased += token_char
  
                      else:
                          raise RuntimeError(
                              f"Unexpected error - failed to recover capitalization of tokens for word {word}"
                          )
  
          word_tokens_cased.append(token_cased)
  
      return word_tokens_cased
  
imports: import json
  from dataclasses import dataclass, field
  from pathlib import Path
  from typing import List, Union
  import soundfile
  import torch
  from tqdm.auto import tqdm
  from utils.constants import BLANK_TOKEN, SPACE_TOKEN, V_NEGATIVE_NUM
  from nemo.utils import logging
label_desc: Use image node_id 8 for calling a global function with example usage: restore_token_case(word, word_tokens) and returns: word_tokens_cased