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"]
code: def filter_notebook(self, nb, metadata):
      self.update_fmt_with_notebook_options(nb.metadata)
      unsupported_keys = set()
      metadata = insert_jupytext_info_and_filter_metadata(
          metadata,
          self.fmt,
          self.implementation,
          unsupported_keys=unsupported_keys,
      )
  
      cells = []
      for cell in nb.cells:
          cell_metadata = filter_metadata(
              cell.metadata,
              self.fmt.get("cell_metadata_filter"),
              _IGNORE_CELL_METADATA,
              unsupported_keys=unsupported_keys,
          )
          if cell.cell_type == "code":
              cells.append(
                  new_code_cell(
                      source=cell.source, metadata=cell_metadata
                  )
              )
          else:
              cells.append(
                  NotebookNode(
                      source=cell.source,
                      metadata=cell_metadata,
                      cell_type=cell.cell_type,
                  )
              )
  
      _warn_on_unsupported_keys(unsupported_keys)
  
      return NotebookNode(
          nbformat=nb.nbformat,
          nbformat_minor=nb.nbformat_minor,
          metadata=metadata,
          cells=cells,
      )
  
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 4 for calling the TextNotebookConverter obj's underlying member method code with example usage: obj.filter_notebook(nb, metadata) and returns: NotebookNode