code: def _register_accessor(name, cls):
      def decorator(accessor):
          if hasattr(cls, name):
              warnings.warn(
                  "registration of accessor {!r} under name {!r} for type "
                  "{!r} is overriding a preexisting attribute with the same "
                  "name.".format(accessor, name, cls),
                  UserWarning,
                  stacklevel=2,
              )
          setattr(cls, name, CachedAccessor(name, accessor))
          cls._accessors.add(name)
          return accessor
  
      return decorator
  
imports: import warnings
  from pandas.util._decorators import Appender
label_desc: Use image node_id 2 for calling a global function with example usage: _register_accessor(name, cls) and returns: decorator, accessor