class_docstr: A class that can read or write a Jupyter notebook as text
class_docstr_tok: ["A","class","that","can","read","or","write","a","Jupyter","notebook","as","text"]
docstr: Update format options with the values in the notebook metadata, and record those
  options in the notebook metadata
docstr_tok: ["Update","format","options","with","the","values","in","the","notebook","metadata",",","and","record","those","options","in","the","notebook","metadata"]
code: def update_fmt_with_notebook_options(self, metadata, read=False):
      """Update format options with the values in the notebook metadata, and record those
      options in the notebook metadata"""
      # The settings in the Jupytext configuration file have precedence over the metadata in the notebook
      # when the notebook is saved. This is because the metadata in the notebook might not be visible
      # in the text representation when e.g. notebook_metadata_filter="-all", which makes them hard to edit.
      if not read and self.config is not None:
          self.config.set_default_format_options(self.fmt, read)
  
      # Use format options from the notebook if not already set by the config
      for opt in _VALID_FORMAT_OPTIONS:
          if opt in metadata.get("jupytext", {}):
              self.fmt.setdefault(opt, metadata["jupytext"][opt])
  
      # When we read the notebook we use the values of the config as defaults, as again the text representation
      # of the notebook might not store the format options when notebook_metadata_filter="-all"
      if read and self.config is not None:
          self.config.set_default_format_options(self.fmt, read=read)
  
      # We save the format options in the notebook metadata
      for opt in _VALID_FORMAT_OPTIONS:
          if opt in self.fmt:
              metadata.setdefault("jupytext", {})[opt] = self.fmt[opt]
  
      # Is this format the same as that documented in the YAML header? If so, we want to know the format version
      file_fmt = metadata.get("jupytext", {}).get(
          "text_representation", {}
      )
      if self.fmt.get("extension") == file_fmt.get(
          "extension"
      ) and self.fmt.get("format_name") == file_fmt.get("format_name"):
          self.fmt.update(file_fmt)
  
      # rST to md conversion should happen only once
      if metadata.get("jupytext", {}).get("rst2md") is True:
          metadata["jupytext"]["rst2md"] = False
  
imports: import logging
  import os
  import sys
  import warnings
  from copy import copy, deepcopy
  import nbformat
  from nbformat.v4.nbbase import NotebookNode, new_code_cell, new_notebook
  from nbformat.v4.rwbase import NotebookReader, NotebookWriter
  from .cell_metadata import _IGNORE_CELL_METADATA
  from .formats import _VALID_FORMAT_OPTIONS, divine_format, format_name_for_ext, get_format_implementation, guess_format, long_form_one_format, read_format_from_metadata, rearrange_jupytext_metadata, update_jupytext_formats_metadata
  from .header import encoding_and_executable, header_to_metadata_and_cell, insert_jupytext_info_and_filter_metadata, insert_or_test_version_number, metadata_and_cell_to_header
  from .languages import default_language_from_metadata_and_ext, set_main_and_cell_language
  from .metadata_filter import filter_metadata, update_metadata_filters
  from .myst import MYST_FORMAT_NAME, myst_extensions, myst_to_notebook, notebook_to_myst
  from .pandoc import md_to_notebook, notebook_to_md
  from .pep8 import pep8_lines_between_cells
  from .quarto import notebook_to_qmd, qmd_to_notebook
  from .version import __version__
label_desc: Use image node_id 2 for calling the TextNotebookConverter obj's underlying member method code with example usage: obj.update_fmt_with_notebook_options(metadata, read) without return types