code: def separate_compare_overwrite(
      file_name, separator, action, new_middle, label
  ):
      with open(file_name, "r+") as f:
          file_contents = f.read()
          parts = file_contents.split(separator)
  
          if len(parts) != 3:
              code_block = textwrap.indent(separator.strip(), "    ")
              error(
                  f"expected exactly two instances of the separator on their own lines in `{file_name}`, found {len(parts) - 1} instances. Separator should be:\n\n{code_block}"
              )
  
          prefix, current_middle, suffix = parts
          if action == "compare" and new_middle != current_middle:
              diff = difflib.unified_diff(
                  current_middle.splitlines(keepends=True),
                  new_middle.splitlines(keepends=True),
                  fromfile=file_name,
                  tofile="autogenerated expected contents",
              )
              sys.stdout.writelines(diff)
  
              error(
                  f"existing {label} in `{file_name}` differs to generated {label}; was it edited manually?",
                  edit_fixit=True,
              )
          elif action == "overwrite":
              f.seek(0)
              f.write(
                  "".join(
                      [prefix, separator, new_middle, separator, suffix]
                  )
              )
              # delete any remaining content
              f.truncate()
  
imports: import abc
  import argparse
  import contextlib
  import difflib
  import enum
  import glob
  import itertools
  import json
  import nbformat
  import os.path
  import re
  import subprocess
  import sys
  import textwrap
label_desc: Use image node_id 10 for calling a global function with example usage: separate_compare_overwrite(file_name, separator, action, new_middle, label) without return types