code: def metadata_filter_as_dict(metadata_config):
      """Return the metadata filter represented as either None (no filter),
      or a dictionary with at most two keys: 'additional' and 'excluded',
      which contain either a list of metadata names, or the string 'all'
      """
  
      if metadata_config is None:
          return {}
  
      if metadata_config is True:
          return {"additional": "all"}
  
      if metadata_config is False:
          return {"excluded": "all"}
  
      if isinstance(metadata_config, dict):
          assert set(metadata_config) <= {"additional", "excluded"}
          return metadata_config
  
      metadata_keys = metadata_config.split(",")
  
      metadata_config = {}
  
      for key in metadata_keys:
          key = key.strip()
          if key.startswith("-"):
              metadata_config.setdefault("excluded", []).append(
                  key[1:].strip()
              )
          elif key.startswith("+"):
              metadata_config.setdefault("additional", []).append(
                  key[1:].strip()
              )
          else:
              metadata_config.setdefault("additional", []).append(key)
  
      for section in metadata_config:
          if "all" in metadata_config[section]:
              metadata_config[section] = "all"
          else:
              metadata_config[section] = [
                  k for k in metadata_config[section] if k
              ]
  
      return metadata_config
  
file_path: jupytext/src/jupytext/metadata_filter.py
imports: from copy import copy
  from .cell_metadata import _JUPYTEXT_CELL_METADATA, is_valid_metadata_key
label_desc: Use image node_id 1 for calling a global function with example usage: metadata_filter_as_dict(metadata_config) and returns: metadata_config, dict, dict, dict, metadata_config