code: def shard_chooser(mapper, instance, clause=None):
      """shard chooser.
  
      looks at the given instance and returns a shard id
      note that we need to define conditions for
      the WeatherLocation class, as well as our secondary Report class which will
      point back to its WeatherLocation via its 'location' attribute.
  
      """
      if isinstance(instance, WeatherLocation):
          return shard_lookup[instance.continent]
      else:
          return shard_chooser(mapper, instance.location)
  
imports: from __future__ import annotations
  import datetime
  from sqlalchemy import Column
  from sqlalchemy import create_engine
  from sqlalchemy import ForeignKey
  from sqlalchemy import inspect
  from sqlalchemy import Integer
  from sqlalchemy import select
  from sqlalchemy import Table
  from sqlalchemy.ext.horizontal_shard import set_shard_id
  from sqlalchemy.ext.horizontal_shard import ShardedSession
  from sqlalchemy.orm import DeclarativeBase
  from sqlalchemy.orm import Mapped
  from sqlalchemy.orm import mapped_column
  from sqlalchemy.orm import relationship
  from sqlalchemy.orm import sessionmaker
  from sqlalchemy.sql import operators
  from sqlalchemy.sql import visitors
label_desc: Use image node_id 2 for calling a global function with example usage: shard_chooser(mapper, instance, clause) and returns: shard_lookup, shard_chooser