code: def _find_and_replace(text, start_string, end_string, replace_fn):
      """Remove everything found between instances of start_string and end_string.
  
      Replace each such instance with replace_fn(removed_text)
  
      e.g. _find_and_replace("the [[fat]] cat [[sat]]", "[[", "]]", lambda x: x)
        = "the fat cat sat"
  
      Args:
        text: a string
        start_string: a string
        end_string: a string
        replace_fn: a unary function from string to string
  
      Returns:
        a string
      """
      ret = ""
      current_pos = 0
      while True:
          start_pos = text.find(start_string, current_pos)
          if start_pos == -1:
              ret += text[current_pos:]
              break
          ret += text[current_pos:start_pos]
          end_pos = text.find(end_string, start_pos + len(start_string))
          if end_pos == -1:
              break
          ret += replace_fn(
              text[start_pos + len(start_string) : end_pos]
          )
          current_pos = end_pos + len(end_string)
      return ret
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import math
  import os
  import random
  import re
  import subprocess
  from tensor2tensor.data_generators import generator_utils
  from tensor2tensor.data_generators import text_encoder
  import tensorflow.compat.v1
label_desc: Use image node_id 12 for calling a global function with example usage: _find_and_replace(text, start_string, end_string, replace_fn) and returns: ret