code: def test_root_level_metadata_as_raw_cell(
      tmpdir,
      root_level_metadata_as_raw_cell,
      rmd="""---
  author: R Markdown document author
  title: R Markdown notebook title
  ---
  
  ```{r}
  1 + 1
  ```
  """,
  ):
      nb_file = tmpdir.join("notebook.ipynb")
      rmd_file = tmpdir.join("notebook.Rmd")
      cfg_file = tmpdir.join("jupytext.toml")
  
      cfg_file.write(
          "root_level_metadata_as_raw_cell = {}".format(
              "true" if root_level_metadata_as_raw_cell else "false"
          )
      )
      rmd_file.write(rmd)
  
      jupytext_cli([str(rmd_file), "--to", "ipynb"])
  
      nb = nbformat.read(str(nb_file), as_version=4)
  
      if root_level_metadata_as_raw_cell:
          compare_cells(
              nb.cells,
              [
                  new_raw_cell(
                      """---
  author: R Markdown document author
  title: R Markdown notebook title
  ---"""
                  ),
                  new_code_cell("1 + 1"),
              ],
              compare_ids=False,
          )
      else:
          compare_cells(
              nb.cells, [new_code_cell("1 + 1")], compare_ids=False
          )
          assert nb.metadata["jupytext"]["root_level_metadata"] == {
              "title": "R Markdown notebook title",
              "author": "R Markdown document author",
          }
  
      # Writing back to Rmd should preserve the original document
      jupytext_cli([str(nb_file), "--to", "Rmd"])
      compare(rmd_file.read(), rmd)
  
imports: import re
  from time import sleep
  import nbformat
  import pytest
  from nbformat.v4.nbbase import new_code_cell, new_markdown_cell, new_notebook, new_raw_cell
  import jupytext
  from jupytext.cli import jupytext
  from jupytext.compare import compare, compare_cells, compare_notebooks
label_desc: Use image node_id 9 for calling a global function with example usage: test_root_level_metadata_as_raw_cell(tmpdir, root_level_metadata_as_raw_cell, rmd) without return types