code: def cleanup(
      all_: bool,  # pylint: disable=unused-argument
      dashboard_ids: tuple[int, ...],
  ) -> None:
      """
      Cleanup obsolete legacy filter-box charts and interim metadata.
  
      Note this operation is irreversible.
      """
  
      slice_ids: set[int] = set()
  
      # Cleanup the dashboard which contains legacy fields used for downgrading.
      for dashboard in (
          db.session.query(Dashboard)
          .filter(
              *[Dashboard.id.in_(dashboard_ids)]
              if dashboard_ids
              else []
          )
          .all()
      ):
          click.echo(f"Cleaning up {str(dashboard)}")
  
          try:
              json_metadata = json.loads(
                  dashboard.json_metadata or "{}"
              )
              position_json = json.loads(
                  dashboard.position_json or "{}"
              )
  
              # Remove the saved filter configurations.
              if "native_filter_migration" in json_metadata:
                  del json_metadata["native_filter_migration"]
                  dashboard.json_metadata = json.dumps(json_metadata)
  
              for value in position_json.values():
                  if (
                      isinstance(value, dict)
                      and value["type"] == "MARKDOWN"
                      and (meta := value.get("meta"))
                      and "native_filter_migration" in meta
                  ):
                      slice_ids.add(
                          meta["native_filter_migration"]["chartId"]
                      )
                      del meta["native_filter_migration"]
  
              dashboard.json_metadata = json.dumps(json_metadata)
              dashboard.position_json = json.dumps(position_json)
          except Exception:  # pylint: disable=broad-except
              click.echo(f"Unable to cleanup {str(dashboard)}")
  
      # Delete the obsolete filter-box charts associated with the dashboards.
      db.session.query(slice_user).filter(
          slice_user.c.slice_id.in_(slice_ids)
      ).delete()
      db.session.query(Slice).filter(Slice.id.in_(slice_ids)).delete()
  
      db.session.commit()
      db.session.close()
  
file_path: superset/superset/cli/native_filters.py
imports: import json
  from copy import deepcopy
  from textwrap import dedent
  import click
  from click_option_group import optgroup, RequiredMutuallyExclusiveOptionGroup
  from flask.cli import with_appcontext
  from sqlalchemy import Column, ForeignKey, Integer, String, Table, Text
  from sqlalchemy.ext.declarative import declarative_base
  from sqlalchemy.orm import relationship
  from superset import db, is_feature_enabled
label_desc: Use image node_id 4 for calling a global function with example usage: cleanup(all_, dashboard_ids) without return types