code: def register(
      alias: str,
      modulename: str,
      deepname: str,
      validator: Optional[Callable] = None,
  ) -> Callable:
      """
      Register a global settings.
  
      This should be declared in the module where the setting is defined.
  
      This can be used either as a declaration::
  
          settings.register("my_setting", __name__, "MY_SETTING")
  
      or as a decorator on a user-defined validator function::
  
          @settings.register("my_setting", __name__, "MY_SETTING")
          def _validate_my_setting(value):
              assert isinstance(value, float)
              assert 0 < value
  
      :param str alias: A valid python identifier serving as a settings alias.
          Lower snake case preferred, e.g. ``my_setting``.
      :param str modulename: The module name where the setting is declared,
          typically ``__name__``.
      :param str deepname: A ``.``-separated string of names. E.g. for a module
          constant, use ``MY_CONSTANT``. For a class attributue, use
          ``MyClass.my_attribute``.
      :param callable validator: Optional validator that inputs a value,
          possibly raises validation errors, and returns None.
      """
      global __doc__
      assert isinstance(alias, str)
      assert alias.isidentifier()
      assert isinstance(modulename, str)
      assert isinstance(deepname, str)
      _REGISTRY[alias] = modulename, deepname, validator
  
      # Add default value to module docstring.
      __doc__ = _doc_template.format(
          defaults="\n".join(
              f"- {a} = {get(a)}" for a in sorted(_REGISTRY)
          )
      )
  
      # Support use as a decorator on an optional user-provided validator.
      if validator is None:
          # Return a decorator, but its fine if user discards this.
          return functools.partial(
              register, alias, modulename, deepname
          )
      else:
          # Test current value passes validation.
          validator(get(alias))
          return validator
  
file_path: pyro/pyro/settings.py
imports: import functools
  from contextlib import contextmanager
  from importlib import import_module
  from typing import Any, Callable, Dict, Iterator, Optional, Tuple
label_desc: Use image node_id 4 for calling a global function with example usage: register(alias, modulename, deepname, validator) and returns: functools, validator