Initializes a module method with variables and returns modified variables. ``init`` takes as first argument either a single ``PRNGKey``, or a dictionary mapping variable collections names to their ``PRNGKeys``, and will call ``method`` (which is the module's ``__call__`` function by
(
self,
rngs: PRNGKey | RNGSequences,
*args,
method: Callable[..., Any] | str | None = None,
mutable: CollectionFilter = DenyList('intermediates'),
capture_intermediates: (
bool | Callable[[flax.linen.Module, str], bool]
) = False,
**kwargs,
)
| 86 | INFO: ClassVar[ModelInfo] |
| 87 | |
| 88 | def init( |
| 89 | self, |
| 90 | rngs: PRNGKey | RNGSequences, |
| 91 | *args, |
| 92 | method: Callable[..., Any] | str | None = None, |
| 93 | mutable: CollectionFilter = DenyList('intermediates'), |
| 94 | capture_intermediates: ( |
| 95 | bool | Callable[[flax.linen.Module, str], bool] |
| 96 | ) = False, |
| 97 | **kwargs, |
| 98 | ) -> FrozenVariableDict | dict[str, Any]: |
| 99 | """Initializes a module method with variables and returns modified variables. |
| 100 | |
| 101 | ``init`` takes as first argument either a single ``PRNGKey``, or a |
| 102 | dictionary mapping variable collections names to their ``PRNGKeys``, and |
| 103 | will call ``method`` (which is the module's ``__call__`` function by |
| 104 | default) passing ``*args`` and ``**kwargs``, and returns |
| 105 | a dictionary of initialized variables. |
| 106 | |
| 107 | Args: |
| 108 | rngs: The PRNGKey or dictionary of PRNGKeys. |
| 109 | *args: Positional arguments to pass to the method. |
| 110 | method: The module method to initialize. Defaults to `__call__`. |
| 111 | mutable: A filter for which variable collections are mutable. |
| 112 | capture_intermediates: Whether to capture intermediate values. |
| 113 | **kwargs: Keyword arguments to pass to the method. |
| 114 | """ |
| 115 | ... |
| 116 | |
| 117 | @typechecked |
| 118 | @abc.abstractmethod |
no outgoing calls