code: def assert_conversion_same_as_mirror(
      nb_file, fmt, mirror_name, compare_notebook=False
  ):
      """This function is used in the tests"""
      dirname, basename = os.path.split(nb_file)
      file_name, org_ext = os.path.splitext(basename)
      fmt = long_form_one_format(fmt)
      notebook = read(nb_file, fmt=fmt)
      fmt = check_auto_ext(fmt, notebook.metadata, "")
      ext = fmt["extension"]
      mirror_file = os.path.join(
          dirname,
          "..",
          "..",
          "outputs",
          mirror_name,
          full_path(file_name, fmt),
      )
  
      # it's better not to have Jupytext metadata in test notebooks:
      if (
          fmt == "ipynb" and "jupytext" in notebook.metadata
      ):  # pragma: no cover
          notebook.metadata.pop("jupytext")
          write(nb_file, fmt=fmt)
  
      create_mirror_file_if_missing(mirror_file, notebook, fmt)
  
      # Compare the text representation of the two notebooks
      if compare_notebook:
          # Read and convert the mirror file to the latest nbformat version if necessary
          nb_mirror = read(mirror_file, as_version=notebook.nbformat)
          nb_mirror.nbformat_minor = notebook.nbformat_minor
          compare_notebooks(nb_mirror, notebook)
          return
      elif ext == ".ipynb":
          notebook = read(mirror_file)
          fmt.update({"extension": org_ext})
          actual = writes(notebook, fmt)
          with open(nb_file, encoding="utf-8") as fp:
              expected = fp.read()
      else:
          actual = writes(notebook, fmt)
          with open(mirror_file, encoding="utf-8") as fp:
              expected = fp.read()
  
      if not actual.endswith("\n"):
          actual = actual + "\n"
      compare(actual, expected)
  
      # Compare the two notebooks
      if ext != ".ipynb":
          notebook = read(nb_file)
          nb_mirror = read(mirror_file, fmt=fmt)
  
          if fmt.get("format_name") == "sphinx":
              nb_mirror.cells = nb_mirror.cells[1:]
              for cell in notebook.cells:
                  cell.metadata = {}
              for cell in nb_mirror.cells:
                  cell.metadata = {}
  
          compare_notebooks(nb_mirror, notebook, fmt)
  
          nb_mirror = combine_inputs_with_outputs(nb_mirror, notebook)
          compare_notebooks(
              nb_mirror, notebook, fmt, compare_outputs=True
          )
  
imports: import difflib
  import json
  import os
  import re
  from jupytext.paired_paths import full_path
  from .cell_metadata import _IGNORE_CELL_METADATA
  from .combine import combine_inputs_with_outputs
  from .formats import check_auto_ext, long_form_one_format
  from .header import _DEFAULT_NOTEBOOK_METADATA
  from .jupytext import read, reads, write, writes
  from .metadata_filter import filter_metadata
label_desc: Use image node_id 10 for calling a global function with example usage: assert_conversion_same_as_mirror(nb_file, fmt, mirror_name, compare_notebook) without return types