class_docstr: Base class of all stats
docstr: Return an instantiated stat object
  
  stats should not override this method.
  
  Parameters
  ----------
  geom :
      A geom object
  
  Returns
  -------
  stat
      A stat object
  
  Raises
  ------
  [](`~plotnine.exceptions.PlotnineError`) if unable to create a `stat`.
docstr_tok: ["Return","an","instantiated","stat","object","stats","should","not","override","this","method",".","Parameters","--","--","--","--","--","geom",":","A","geom","object","Returns","--","--","--","-","stat","A","stat","object","Raises","--","--","--","[","]","(","`","~plotnine.exceptions.PlotnineError","`",")","if","unable","to","create","a","`","stat","`","."]
code: def from_geom(geom: Geom) -> stat:
      """
      Return an instantiated stat object
  
      stats should not override this method.
  
      Parameters
      ----------
      geom :
          A geom object
  
      Returns
      -------
      stat
          A stat object
  
      Raises
      ------
      [](`~plotnine.exceptions.PlotnineError`) if unable to create a `stat`.
      """
      name = geom.params["stat"]
      kwargs = geom._kwargs
      # More stable when reloading modules than
      # using issubclass
      if not isinstance(name, type) and hasattr(name, "compute_layer"):
          return name
  
      if isinstance(name, stat):
          return name
      elif isinstance(name, type) and issubclass(name, stat):
          klass = name
      elif isinstance(name, str):
          if not name.startswith("stat_"):
              name = f"stat_{name}"
          klass = Registry[name]
      else:
          raise PlotnineError(f"Unknown stat of type {type(name)}")
  
      valid_kwargs = (
          klass.aesthetics() | klass.DEFAULT_PARAMS.keys()
      ) & kwargs.keys()
  
      params = {k: kwargs[k] for k in valid_kwargs}
      return klass(geom=geom, **params)
  
imports: from __future__ import annotations
  import typing
  from copy import deepcopy
  import pandas
  from .._utils import check_required_aesthetics, copy_keys, data_mapping_as_kwargs, groupby_apply, remove_missing, uniquecols
  from .._utils.registry import Register, Registry
  from ..exceptions import PlotnineError
  from ..layer import layer
  from ..mapping import aes
  from abc import ABC
label_desc: Use image node_id 2 for calling the stat obj's underlying member method code with example usage: obj.from_geom(geom) and returns: klass, name, name