code: def test_metadata_from_custom_model(model_class: t.Any) -> None:
      if model_class is not Model:
          # In 2.x, SQLAlchemy creates the metadata attribute
          base = model_class
      else:
          # For 1.x, our extension creates the metadata attribute
          base = sa_orm.declarative_base(
              cls=Model, metaclass=DefaultMeta
          )
      metadata = base.metadata
      db = SQLAlchemy(model_class=base)
      assert db.Model.metadata is metadata
      assert db.Model.metadata is db.metadata
  
imports: from __future__ import annotations
  import typing
  import pytest
  import sqlalchemy
  import sqlalchemy.exc
  import sqlalchemy.orm
  from flask import Flask
  from flask_sqlalchemy import SQLAlchemy
  from flask_sqlalchemy.model import DefaultMeta
  from flask_sqlalchemy.model import Model
label_desc: Use image node_id 5 for calling a global function with example usage: test_metadata_from_custom_model(model_class) without return types