class_docstr: Base for ORM mapped dictionary classes.
  
  Extends the ``dict`` type with additional methods needed by SQLAlchemy ORM
  collection classes. Use of :class:`_orm.KeyFuncDict` is most directly
  by using the :func:`.attribute_keyed_dict` or
  :func:`.column_keyed_dict` class factories.
  :class:`_orm.KeyFuncDict` may also serve as the base for user-defined
  custom dictionary classes.
  
  .. versionchanged:: 2.0 Renamed :class:`.MappedCollection` to
     :class:`.KeyFuncDict`.
  
  .. seealso::
  
      :func:`_orm.attribute_keyed_dict`
  
      :func:`_orm.column_keyed_dict`
  
      :ref:`orm_dictionary_collection`
  
      :ref:`orm_custom_collection`
class_docstr_tok: ["Base","for","ORM","mapped","dictionary","classes",".","Extends","the","``","dict","``","type","with","additional","methods","needed","by","SQLAlchemy","ORM","collection","classes",".","Use","of",":","class",":","`","_orm.KeyFuncDict","`","is","most","directly","by","using","the",":","func",":","`",".attribute_keyed_dict","`","or",":","func",":","`",".column_keyed_dict","`","class","factories",".",":","class",":","`","_orm.KeyFuncDict","`","may","also","serve","as","the","base","for","user-defined","custom","dictionary","classes",".","..","versionchanged",":",":","2.0","Renamed",":","class",":","`",".MappedCollection","`","to",":","class",":","`",".KeyFuncDict","`",".","..","seealso",":",":",":","func",":","`","_orm.attribute_keyed_dict","`",":","func",":","`","_orm.column_keyed_dict","`",":","ref",":","`","orm_dictionary_collection","`",":","ref",":","`","orm_custom_collection","`"]
code: def _raise_for_unpopulated(
      self,
      value: _KT,
      initiator: Union[
          AttributeEventToken, Literal[None, False]
      ] = None,
      *,
      warn_only: bool,
  ) -> None:
      mapper = base.instance_state(value).mapper
  
      attributes = util.preloaded.orm_attributes
  
      if not isinstance(initiator, attributes.AttributeEventToken):
          relationship = "unknown relationship"
      elif initiator.key in mapper.attrs:
          relationship = f"{mapper.attrs[initiator.key]}"
      else:
          relationship = initiator.key
  
      if warn_only:
          util.warn(
              f"Attribute keyed dictionary value for "
              f"attribute '{relationship}' was None; this will raise "
              "in a future release. "
              f"To skip this assignment entirely, "
              f'Set the "ignore_unpopulated_attribute=True" '
              f"parameter on the mapped collection factory."
          )
      else:
          raise sa_exc.InvalidRequestError(
              "In event triggered from population of "
              f"attribute '{relationship}' "
              "(potentially from a backref), "
              f"can't populate value in KeyFuncDict; "
              "dictionary key "
              f"derived from {base.instance_str(value)} is not "
              f"populated. Ensure appropriate state is set up on "
              f"the {base.instance_str(value)} object "
              f"before assigning to the {relationship} attribute. "
              f"To skip this assignment entirely, "
              f'Set the "ignore_unpopulated_attribute=True" '
              f"parameter on the mapped collection factory."
          )
  
imports: from __future__ import annotations
  import operator
  from typing import Any
  from typing import Callable
  from typing import Dict
  from typing import Generic
  from typing import List
  from typing import Optional
  from typing import Sequence
  from typing import Tuple
  from typing import Type
  from typing import TYPE_CHECKING
  from typing import TypeVar
  from typing import Union
  from .None import base
  from .collections import collection
  from .collections import collection_adapter
  from ..None import exc
  from ..None import util
  from ..sql import coercions
  from ..sql import expression
  from ..sql import roles
  from ..util.typing import Literal
label_desc: Use image node_id 4 for calling the KeyFuncDict obj's underlying member method code with example usage: obj._raise_for_unpopulated(value, initiator) without return types