code: def _replace_sentence(sentence: str, word: str, new_word: str) -> str:
      """
      Searches for a given token in the sentence and returns the sentence where the given token has been replaced by
      `new_word`.
  
      Parameters
      ----------
      sentence:
          a sentence where the word is searched
  
      word:
          keyword to find in `sentence`. Assumes the word exists in the sentence.
  
      new_word:
          the word to replace the keyword with
  
      Returns
      ---------
      new_sentence:
          `sentence` where the every occurrence of the word is replaced by `colored_word`
      """
  
      new_sentence, number_of_substitions = re.subn(
          r"\b{}\b".format(re.escape(word)), new_word, sentence
      )
      if number_of_substitions == 0:
          # Use basic string manipulation if regex fails
          new_sentence = sentence.replace(word, new_word)
      return new_sentence
  
file_path: cleanlab/cleanlab/internal/token_classification_utils.py
imports: from __future__ import annotations
  import re
  import string
  import numpy
  from termcolor import colored
  from typing import List, Optional, Callable, Tuple, TypeVar, TYPE_CHECKING
label_desc: Use image node_id 7 for calling a global function with example usage: _replace_sentence(sentence, word, new_word) and returns: new_sentence