code: def insert_jupytext_info_and_filter_metadata(
      metadata, fmt, text_format, unsupported_keys
  ):
      """Update the notebook metadata to include Jupytext information, and filter
      the notebook metadata according to the default or user filter"""
      if insert_or_test_version_number():
          metadata.setdefault("jupytext", {})["text_representation"] = {
              "extension": fmt["extension"],
              "format_name": text_format.format_name,
              "format_version": text_format.current_version_number,
              "jupytext_version": __version__,
          }
  
      if "jupytext" in metadata and not metadata["jupytext"]:
          del metadata["jupytext"]
  
      notebook_metadata_filter = fmt.get("notebook_metadata_filter")
      return filter_metadata(
          metadata,
          notebook_metadata_filter,
          _DEFAULT_NOTEBOOK_METADATA,
          unsupported_keys=unsupported_keys,
      )
  
file_path: jupytext/src/jupytext/header.py
imports: import re
  import nbformat
  import yaml
  from nbformat.v4.nbbase import new_raw_cell
  from yaml.representer import SafeRepresenter
  from .languages import _SCRIPT_EXTENSIONS, comment_lines, default_language_from_metadata_and_ext
  from .metadata_filter import _DEFAULT_NOTEBOOK_METADATA, filter_metadata
  from .pep8 import pep8_lines_between_cells
  from .version import __version__
label_desc: Use image node_id 4 for calling a global function with example usage: insert_jupytext_info_and_filter_metadata(metadata, fmt, text_format, unsupported_keys) and returns: filter_metadata