code: def identity_chooser(mapper, primary_key, *, lazy_loaded_from, **kw):
      """identity chooser.
  
      given a primary key identity, return which shard we should look at.
  
      in this case, we only want to support this for lazy-loaded items;
      any primary query should have shard id set up front.
  
      """
      if lazy_loaded_from:
          # if we are in a lazy load, we can look at the parent object
          # and limit our search to that same shard, assuming that's how we've
          # set things up.
          return [lazy_loaded_from.identity_token]
      else:
          raise NotImplementedError()
  
imports: from __future__ import annotations
  import datetime
  import os
  from sqlalchemy import create_engine
  from sqlalchemy import ForeignKey
  from sqlalchemy import inspect
  from sqlalchemy import select
  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
label_desc: Use image node_id 2 for calling a global function with example usage: identity_chooser(mapper, primary_key) and returns: list