Expose Module._flatten to allow subclasses to implement gathering.
I've made this "private" since this exposes the implementation of modules, which
in typical Python code does not represent part of the classes public API. As
such I think having the leading _ makes it clear (at least to the linter) that
you're using an "internal" method. As always this is a "sign" not a cop.
As a concrete example, I strongly encourage the following usage:
>>> class FooModule(...):
... @property
... def hash_tables(self):
... return tuple(self._flatten(predicate=IS_HASH_TABLE))
But in general we should discourage usage outside of modules:
>>> m = FooModule()
>>> hash_tables = tuple(m._flatten(predicate=IS_HASH_TABLE)) # Naughty.
c.f. tensorflow/community#56
PiperOrigin-RevId: 232246092
Loading
Please sign in to comment