code: def downgrade():
      bind = op.get_bind()
      session = db.Session(bind=bind)
  
      slices = (
          session.query(Slice)
          .filter(
              and_(
                  Slice.viz_type == "pie",
                  Slice.params.like("%label_type%"),
              )
          )
          .all()
      )
      changes = 0
      for slc in slices:
          try:
              params = json.loads(slc.params)
              label_type = params.pop("label_type", None)
              if label_type:
                  changes += 1
                  params["pie_label_type"] = label_type
                  slc.params = json.dumps(params, sort_keys=True)
          except Exception as e:
              print(e)
              print(f"Parsing params for slice {slc.id} failed.")
              pass
  
      session.commit()
      session.close()
      print(f"Updated {changes} pie chart labels.")
  
file_path: superset/superset/migrations/versions/2021-02-10_12-32_41ce8799acc3_rename_pie_label_type.py
imports: import json
  from alembic import op
  from sqlalchemy import and_, Column, Integer, String, Text
  from sqlalchemy.ext.declarative import declarative_base
  from superset import db
label_desc: Use image node_id 2 for calling a global function with example usage: downgrade() without return types