class_docstr: Base class for Haiku modules.
  
  A Haiku module is a lightweight container for variables and other modules.
  Modules typically define one or more "forward" methods (e.g. ``__call__``)
  which apply operations combining user input and module parameters.
  
  Modules must be initialized inside a :func:`transform` call.
  
  For example:
  
  >>> class AddModule(hk.Module):
  ...   def __call__(self, x):
  ...     w = hk.get_parameter("w", [], init=jnp.ones)
  ...     return x + w
  
  >>> def forward_fn(x):
  ...   mod = AddModule()
  ...   return mod(x)
  
  >>> forward = hk.transform(forward_fn)
  >>> x = 1.
  >>> rng = None
  >>> params = forward.init(rng, x)
  >>> print(forward.apply(params, None, x))
  2.0
class_docstr_tok: ["Base","class","for","Haiku","modules",".","A","Haiku","module","is","a","lightweight","container","for","variables","and","other","modules",".","Modules","typically","define","one","or","more","``","forward","''","methods","(","e.g",".","``","__call__","``",")","which","apply","operations","combining","user","input","and","module","parameters",".","Modules","must","be","initialized","inside","a",":","func",":","`","transform","`","call",".","For","example",":",">",">",">","class","AddModule","(","hk.Module",")",":","...","def","__call__","(","self",",","x",")",":","...","w","=","hk.get_parameter","(","``","w","''",",","[","]",",","init=jnp.ones",")","...","return","x","+","w",">",">",">","def","forward_fn","(","x",")",":","...","mod","=","AddModule","(",")","...","return","mod","(","x",")",">",">",">","forward","=","hk.transform","(","forward_fn",")",">",">",">","x","=","1",".",">",">",">","rng","=","None",">",">",">","params","=","forward.init","(","rng",",","x",")",">",">",">","print","(","forward.apply","(","params",",","None",",","x",")",")","2.0"]
docstr: Initializes the current module with the given name.
  
  Subclasses should call this constructor before creating other modules or
  variables such that those modules are named correctly.
  
  Args:
    name: An optional string name for the class. Must be a valid Python
      identifier. If ``name`` is not provided then the class name for the
      current instance is converted to ``lower_snake_case`` and used instead.
docstr_tok: ["Initializes","the","current","module","with","the","given","name",".","Subclasses","should","call","this","constructor","before","creating","other","modules","or","variables","such","that","those","modules","are","named","correctly",".","Args",":","name",":","An","optional","string","name","for","the","class",".","Must","be","a","valid","Python","identifier",".","If","``","name","``","is","not","provided","then","the","class","name","for","the","current","instance","is","converted","to","``","lower_snake_case","``","and","used","instead","."]
code: def __init__(self, name: Optional[str] = None):
      """Initializes the current module with the given name.
  
      Subclasses should call this constructor before creating other modules or
      variables such that those modules are named correctly.
  
      Args:
        name: An optional string name for the class. Must be a valid Python
          identifier. If ``name`` is not provided then the class name for the
          current instance is converted to ``lower_snake_case`` and used instead.
      """
      if name is None:
          if hasattr(self, "name") and self.name is not None:
              # Attribute assigned by @dataclass constructor.
              name = self.name
          else:
              name = utils.camel_to_snake(type(self).__name__)
  
      if name.startswith(OVERRIDE_PREFIX):
          name = name[len(OVERRIDE_PREFIX) :]
          for component in name.split("/"):
              check_name(component, name, allow_leading_tilde=True)
          reserve_module_name(name, check_unique=False)
      else:
          check_name(name, name)
          name = unique_and_canonical_name(name)
  
      self._submodules: set[str] = set()
      self.module_name = name
      self.name = self.module_name.split("/")[-1]
      self._creation_frame_id = base.current_frame().frame_id
  
imports: from collections.abc import Mapping
  import contextlib
  import functools
  import inspect
  import re
  from typing import Any, Callable, ContextManager, NamedTuple, Optional, Protocol, TypeVar
  from haiku._src import base
  from haiku._src import config
  from haiku._src import data_structures
  from haiku._src import utils
  import jax
  import jax.numpy
label_desc: Use image node_id 1 to create a new Module object  with example: obj = Module(name)