code: def key_value_rule(
      src: str,
      pos: Pos,
      out: Output,
      header: Key,
      parse_float: ParseFloat,
  ) -> Pos:
      pos, key, value = parse_key_value_pair(src, pos, parse_float)
      key_parent, key_stem = key[:-1], key[-1]
      abs_key_parent = header + key_parent
  
      relative_path_cont_keys = (
          header + key[:i] for i in range(1, len(key))
      )
      for cont_key in relative_path_cont_keys:
          # Check that dotted key syntax does not redefine an existing table
          if out.flags.is_(cont_key, Flags.EXPLICIT_NEST):
              raise suffixed_err(
                  src, pos, f"Cannot redefine namespace {cont_key}"
              )
          # Containers in the relative path can't be opened with the table syntax or
          # dotted key/value syntax in following table sections.
          out.flags.add_pending(cont_key, Flags.EXPLICIT_NEST)
  
      if out.flags.is_(abs_key_parent, Flags.FROZEN):
          raise suffixed_err(
              src,
              pos,
              f"Cannot mutate immutable namespace {abs_key_parent}",
          )
  
      try:
          nest = out.data.get_or_create_nest(abs_key_parent)
      except KeyError:
          raise suffixed_err(
              src, pos, "Cannot overwrite a value"
          ) from None
      if key_stem in nest:
          raise suffixed_err(src, pos, "Cannot overwrite a value")
      # Mark inline table and array namespaces recursively immutable
      if isinstance(value, (dict, list)):
          out.flags.set(header + key, Flags.FROZEN, recursive=True)
      nest[key_stem] = value
      return pos
  
imports: from __future__ import annotations
  from collections.abc import Iterable
  import string
  from types import MappingProxyType
  from typing import Any, BinaryIO, NamedTuple
  from ._re import RE_DATETIME, RE_LOCALTIME, RE_NUMBER, match_to_datetime, match_to_localtime, match_to_number
  from ._types import Key, ParseFloat, Pos
label_desc: Use image node_id 9 for calling a global function with example usage: key_value_rule(src, pos, out, header, parse_float) and returns: pos