MCPcopy
hub / github.com/google-deepmind/penzai / select

Method select

penzai/core/struct.py:551–568  ·  view source on GitHub ↗

Wraps this struct in a selection, enabling functional-style mutations. This is a convenience wrapper around selectors.select to enable easier selection, using syntax like:: struct.select().at(lambda b: b.foo[3].bar).apply(baz) struct.select().at_instances_of(Sequential).at_chil

(self)

Source from the content-addressed store, hash-verified

549
550 @typing.final
551 def select(self) -> selectors.Selection[Struct]:
552 """Wraps this struct in a selection, enabling functional-style mutations.
553
554 This is a convenience wrapper around selectors.select to enable easier
555 selection, using syntax like::
556
557 struct.select().at(lambda b: b.foo[3].bar).apply(baz)
558 struct.select().at_instances_of(Sequential).at_children().apply(qux)
559
560 See documentation for `selectors.Selection` for supported attributes.
561
562 Returns:
563 A singleton selection containing this struct.
564 """
565 # Dynamic import to avoid circular import issues.
566 from penzai.core import selectors # pylint: disable=import-outside-toplevel
567
568 return selectors.select(self)
569
570 def key_for_field(self, field_name: str) -> Hashable:
571 """Generates a JAX PyTree key for a given field name.

Callers 15

freeze_variablesFunction · 0.80
_stepFunction · 0.80
__call__Method · 0.80
bodyMethod · 0.80
goMethod · 0.80
from_uncachedMethod · 0.80
from_pretrainedMethod · 0.80
from_uncachedMethod · 0.80
__call__Method · 0.80
handlingMethod · 0.80

Calls

no outgoing calls