def _repr_pretty_(self, p, cycle):
    """Pretty-prints this object for an IPython pretty-printer."""
    del cycle
    # Defer to Treescope.
    import treescope  # pylint: disable=import-outside-toplevel

    rendering = treescope.render_to_text(self, ignore_exceptions=True)
    for i, line in enumerate(rendering.split("\n")):
      if i:
        p.break_()
      p.text(line)
Pretty-prints this object for an IPython pretty-printer.
penzai/core/struct.py