code: def add_favorites(metadata: MetaData) -> None:
      """
      Tag every object that was favorited:
  
        INSERT INTO tagged_object (tag_id, object_id, object_type)
        SELECT
          tag.id AS tag_id,
          favstar.obj_id AS object_id,
          LOWER(favstar.class_name) AS object_type
        FROM favstar
        JOIN tag
        ON tag.name = CONCAT('favorited_by:', favstar.user_id)
        LEFT OUTER JOIN tagged_object
          ON tagged_object.tag_id = tag.id
          AND tagged_object.object_id = favstar.obj_id
          AND tagged_object.object_type = LOWER(favstar.class_name)
        WHERE tagged_object.tag_id IS NULL;
  
      """
  
      tag = metadata.tables["tag"]
      tagged_object = metadata.tables["tagged_object"]
      users = metadata.tables["ab_user"]
      favstar = metadata.tables["favstar"]
      columns = ["tag_id", "object_id", "object_type"]
  
      # create a custom tag for each user
      ids = select([users.c.id])
      insert = tag.insert()
      for (id_,) in db.session.execute(ids):
          with contextlib.suppress(IntegrityError):  # already exists
              db.session.execute(
                  insert, name=f"favorited_by:{id_}", type=TagType.type
              )
      favstars = (
          select(
              [
                  tag.c.id.label("tag_id"),
                  favstar.c.obj_id.label("object_id"),
                  func.lower(favstar.c.class_name).label("object_type"),
              ]
          )
          .select_from(
              join(
                  join(
                      favstar,
                      tag,
                      tag.c.name == "favorited_by:" + favstar.c.user_id,
                  ),
                  tagged_object,
                  and_(
                      tagged_object.c.tag_id == tag.c.id,
                      tagged_object.c.object_id == favstar.c.obj_id,
                      tagged_object.c.object_type
                      == func.lower(favstar.c.class_name),
                  ),
                  isouter=True,
                  full=False,
              )
          )
          .where(tagged_object.c.tag_id.is_(None))
      )
      query = tagged_object.insert().from_select(columns, favstars)
      db.session.execute(query)
  
file_path: superset/superset/common/tags.py
imports: import contextlib
  from typing import Any
  from sqlalchemy import MetaData
  from sqlalchemy.exc import IntegrityError
  from sqlalchemy.sql import and_, func, join, literal, select
  from superset.extensions import db
  from superset.tags.models import ObjectType, TagType
label_desc: Use image node_id 11 for calling a global function with example usage: add_favorites(metadata) without return types