code: def unwrap_style_text_from_prompt(style_text, prompt):
      """
      Checks the prompt to see if the style text is wrapped around it. If so,
      returns True plus the prompt text without the style text. Otherwise, returns
      False with the original prompt.
  
      Note that the "cleaned" version of the style text is only used for matching
      purposes here. It isn't returned; the original style text is not modified.
      """
      stripped_prompt = prompt
      stripped_style_text = style_text
      if "{prompt}" in stripped_style_text:
          # Work out whether the prompt is wrapped in the style text. If so, we
          # return True and the "inner" prompt text that isn't part of the style.
          try:
              left, right = stripped_style_text.split("{prompt}", 2)
          except ValueError as e:
              # If the style text has multple "{prompt}"s, we can't split it into
              # two parts. This is an error, but we can't do anything about it.
              print(
                  f"Unable to compare style text to prompt:\n{style_text}"
              )
              print(f"Error: {e}")
              return False, prompt
          if stripped_prompt.startswith(
              left
          ) and stripped_prompt.endswith(right):
              prompt = stripped_prompt[
                  len(left) : len(stripped_prompt) - len(right)
              ]
              return True, prompt
      else:
          # Work out whether the given prompt ends with the style text. If so, we
          # return True and the prompt text up to where the style text starts.
          if stripped_prompt.endswith(stripped_style_text):
              prompt = stripped_prompt[
                  : len(stripped_prompt) - len(stripped_style_text)
              ]
              if prompt.endswith(", "):
                  prompt = prompt[:-2]
              return True, prompt
  
      return False, prompt
  
imports: import csv
  import fnmatch
  import os
  import os.path
  import typing
  import shutil
label_desc: Use image node_id 3 for calling a global function with example usage: unwrap_style_text_from_prompt(style_text, prompt) and returns: False,  prompt, True,  prompt, True,  prompt, False,  prompt