pretty_keystr

Contents

pretty_keystr#

penzai.core.tree_util.pretty_keystr(keypath: tuple[Any, ...], tree: Any) str[source]#

Constructs a pretty name from a keypath and an object.

This can be used to construct human-readable names for locations inside a PyTree.

Parameters:
  • keypath – Keypath to process.

  • tree – Tree that this keypath indexes into.

Returns:

A human-readable string like “Foo.sublayers[0]/Bar.body/Baz.param/Parameter.value" instead of ".sublayers[0].body.param.value"