code: def estimator_to_html(estimator) -> ET.Element:
      from river import compose
  
      details = ET.Element(
          "details", attrib={"class": "river-component river-estimator"}
      )
  
      summary = ET.Element("summary", attrib={"class": "river-summary"})
      details.append(summary)
  
      pre = ET.Element("pre", attrib={"class": "river-estimator-name"})
      str_estimator = str(estimator)
      parts = str_estimator.split(" ")
      pre.text = (
          textwrap.shorten(str_estimator, width=20)
          if len(parts[0]) < 20
          else (parts[0] + (" [...]" if len(parts) > 1 else ""))
      )
      summary.append(pre)
  
      code = ET.Element(
          "code", attrib={"class": "river-estimator-params"}
      )
      if isinstance(estimator, compose.FuncTransformer):
          code.text = f"\n{inspect.getsource(estimator.func)}\n"
      else:
          code.text = f"{repr(estimator)}\n"
      details.append(code)
  
      return details
  
file_path: river/river/base/viz.py
imports: from __future__ import annotations
  import inspect
  import textwrap
  from xml.etree import ElementTree
label_desc: Use image node_id 2 for calling a global function with example usage: estimator_to_html(estimator) and returns: details