code: def register_option(key, defval, doc="", validator=None, cb=None):
      """Register an option in the package-wide pandas config object
  
      Parameters
      ----------
      key       - a fully-qualified key, e.g. "x.y.option - z".
      defval    - the default value of the option
      doc       - a string description of the option
      validator - a 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.
  
      Returns
      -------
      Nothing.
  
      Raises
      ------
      ValueError if `validator` is specified and `defval` is not a valid value.
  
      """
      import tokenize
      import keyword
  
      key = key.lower()
  
      if key in _registered_options:
          msg = "Option '{key}' has already been registered"
          raise OptionError(msg.format(key=key))
      if key in _reserved_keys:
          msg = "Option '{key}' is a reserved key"
          raise OptionError(msg.format(key=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 bool(re.match("^" + tokenize.Name + "$", k)):
              raise ValueError(
                  "{k} is not a valid identifier".format(k=k)
              )
          if keyword.iskeyword(k):
              raise ValueError("{k} is a python keyword".format(k=k))
  
      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 collections import namedtuple
  from contextlib import contextmanager
  import re
  import warnings
  import pandas.compat
  from pandas.compat import lmap, map, u
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