code: def register_option(
      key: str,
      defval: object,
      doc: str = "",
      validator: Callable[[object], Any] | None = None,
      cb: Callable[[str], Any] | None = None,
  ) -> None:
      """
      Register an option in the package-wide pandas config object
  
      Parameters
      ----------
      key : str
          Fully-qualified key, e.g. "x.y.option - z".
      defval : object
          Default value of the option.
      doc : str
          Description of the option.
      validator : Callable, optional
          Function of a single argument, should raise `ValueError` if
          called with a value which is not a legal value for the option.
      cb
          a function of a single argument "key", which is called
          immediately after an option value is set/reset. key is
          the full name of the option.
  
      Raises
      ------
      ValueError if `validator` is specified and `defval` is not a valid value.
  
      """
      import keyword
      import tokenize
  
      key = key.lower()
  
      if key in _registered_options:
          raise OptionError(
              f"Option '{key}' has already been registered"
          )
      if key in _reserved_keys:
          raise OptionError(f"Option '{key}' is a reserved key")
  
      # the default value should be legal
      if validator:
          validator(defval)
  
      # walk the nested dict, creating dicts as needed along the path
      path = key.split(".")
  
      for k in path:
          if not re.match("^" + tokenize.Name + "$", k):
              raise ValueError(f"{k} is not a valid identifier")
          if keyword.iskeyword(k):
              raise ValueError(f"{k} is a python keyword")
  
      cursor = _global_config
      msg = "Path prefix to option '{option}' is already an option"
  
      for i, p in enumerate(path[:-1]):
          if not isinstance(cursor, dict):
              raise OptionError(msg.format(option=".".join(path[:i])))
          if p not in cursor:
              cursor[p] = {}
          cursor = cursor[p]
  
      if not isinstance(cursor, dict):
          raise OptionError(msg.format(option=".".join(path[:-1])))
  
      cursor[path[-1]] = defval  # initialize
  
      # save the option metadata
      _registered_options[key] = RegisteredOption(
          key=key, defval=defval, doc=doc, validator=validator, cb=cb
      )
  
imports: from __future__ import annotations
  from contextlib import ContextDecorator, contextmanager
  import re
  from typing import TYPE_CHECKING, Any, Callable, Generic, NamedTuple, cast
  import warnings
  from pandas._typing import F, T
  from pandas.util._exceptions import find_stack_level
label_desc: Use image node_id 7 for calling a global function with example usage: register_option(key, defval, doc, validator, cb) without return types