code: def add_class(
      classname: str,
      cls: Type[_T],
      decl_class_registry: _ClsRegistryType,
  ) -> None:
      """Add a class to the _decl_class_registry associated with the
      given declarative class.
  
      """
      if classname in decl_class_registry:
          # class already exists.
          existing = decl_class_registry[classname]
          if not isinstance(existing, _MultipleClassMarker):
              existing = decl_class_registry[
                  classname
              ] = _MultipleClassMarker(
                  [cls, cast("Type[Any]", existing)]
              )
      else:
          decl_class_registry[classname] = cls
  
      try:
          root_module = cast(
              _ModuleMarker, decl_class_registry["_sa_module_registry"]
          )
      except KeyError:
          decl_class_registry[
              "_sa_module_registry"
          ] = root_module = _ModuleMarker("_sa_module_registry", None)
  
      tokens = cls.__module__.split(".")
  
      # build up a tree like this:
      # modulename:  myapp.snacks.nuts
      #
      # myapp->snack->nuts->(classes)
      # snack->nuts->(classes)
      # nuts->(classes)
      #
      # this allows partial token paths to be used.
      while tokens:
          token = tokens.pop(0)
          module = root_module.get_module(token)
          for token in tokens:
              module = module.get_module(token)
  
          try:
              module.add_class(classname, cls)
          except AttributeError as ae:
              if not isinstance(module, _ModuleMarker):
                  raise exc.InvalidRequestError(
                      f'name "{classname}" matches both a '
                      "class name and a module name"
                  ) from ae
              else:
                  raise
  
imports: from __future__ import annotations
  import re
  from typing import Any
  from typing import Callable
  from typing import cast
  from typing import Dict
  from typing import Generator
  from typing import Iterable
  from typing import List
  from typing import Mapping
  from typing import MutableMapping
  from typing import NoReturn
  from typing import Optional
  from typing import Set
  from typing import Tuple
  from typing import Type
  from typing import TYPE_CHECKING
  from typing import TypeVar
  from typing import Union
  import weakref
  from .None import attributes
  from .None import interfaces
  from .descriptor_props import SynonymProperty
  from .properties import ColumnProperty
  from .util import class_mapper
  from ..None import exc
  from ..None import inspection
  from ..None import util
  from ..sql.schema import _get_table_key
  from ..util.typing import CallableReference
label_desc: Use image node_id 1 for calling a global function with example usage: add_class(classname, cls, decl_class_registry) without return types