def _active_renderer_extended_with_penzai_repr() -> (
    treescope.renderers.TreescopeRenderer
):
  """Extends the default renderer to support __penzai_repr__."""
  return treescope.active_renderer.get().extended_with(
      handlers=[
          functools.partial(
              treescope.handlers.handle_via_treescope_repr_method,
              method_name="__penzai_repr__",
          ),
      ]
  )
Extends the default renderer to support __penzai_repr__.
penzai/treescope/_compatibility_setup.py