code: def _register_accessor(name: str, cls):
      """
      Register a custom accessor on {klass} objects.
  
      Parameters
      ----------
      name : str
          Name under which the accessor should be registered. A warning is issued
          if this name conflicts with a preexisting attribute.
  
      Returns
      -------
      callable
          A class decorator.
  
      See Also
      --------
      register_dataframe_accessor : Register a custom accessor on DataFrame objects.
      register_series_accessor : Register a custom accessor on Series objects.
      register_index_accessor : Register a custom accessor on Index objects.
  
      Notes
      -----
      When accessed, your accessor will be initialized with the pandas object
      the user is interacting with. So the signature must be
  
      .. code-block:: python
  
          def __init__(self, pandas_object):  # noqa: E999
              ...
  
      For consistency with pandas methods, you should raise an ``AttributeError``
      if the data passed to your accessor has an incorrect dtype.
  
      >>> pd.Series(['a', 'b']).dt
      Traceback (most recent call last):
      ...
      AttributeError: Can only use .dt accessor with datetimelike values
  
      Examples
      --------
      In your library code::
  
          import pandas as pd
  
          @pd.api.extensions.register_dataframe_accessor("geo")
          class GeoAccessor:
              def __init__(self, pandas_obj):
                  self._obj = pandas_obj
  
              @property
              def center(self):
                  # return the geographic center point of this DataFrame
                  lat = self._obj.latitude
                  lon = self._obj.longitude
                  return (float(lon.mean()), float(lat.mean()))
  
              def plot(self):
                  # plot this array's data on a map, e.g., using Cartopy
                  pass
  
      Back in an interactive IPython session:
  
          .. code-block:: ipython
  
              In [1]: ds = pd.DataFrame({{"longitude": np.linspace(0, 10),
                 ...:                    "latitude": np.linspace(0, 20)}})
              In [2]: ds.geo.center
              Out[2]: (5.0, 10.0)
              In [3]: ds.geo.plot()  # plots data on a map
      """
  
      def decorator(accessor):
          if hasattr(cls, name):
              warnings.warn(
                  f"registration of accessor {accessor!r} under name "
                  f"{name!r} for type {cls!r} is overriding a preexisting "
                  f"attribute with the same name.",
                  UserWarning,
                  stacklevel=find_stack_level(),
              )
          setattr(cls, name, CachedAccessor(name, accessor))
          cls._accessors.add(name)
          return accessor
  
      return decorator
  
imports: from __future__ import annotations
  from typing import Callable, final
  import warnings
  from pandas.util._decorators import doc
  from pandas.util._exceptions import find_stack_level
label_desc: Use image node_id 2 for calling a global function with example usage: _register_accessor(name, cls) and returns: decorator, accessor