class_docstr: Base class for Sonnet modules.
  
  A Sonnet 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. For
  example::
  
      >>> class MultiplyModule(snt.Module):
      ...   def __call__(self, x):
      ...     if not hasattr(self, 'w'):
      ...       self.w = tf.Variable(2., name='w')
      ...     return x * self.w
  
      >>> mod = MultiplyModule()
      >>> mod(1.)
      <tf.Tensor: ... numpy=2.0>
  
  Sonnet modules are a layer on top of :tf:`Module`, implementing automatic name
  scoping as described in the original RFC :cite:`agarwal2019stateful`.
class_docstr_tok: ["Base","class","for","Sonnet","modules",".","A","Sonnet","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",".","For","example",":",":",">",">",">","class","MultiplyModule","(","snt.Module",")",":","...","def","__call__","(","self",",","x",")",":","...","if","not","hasattr","(","self",",","'","w","'",")",":","...","self.w","=","tf.Variable","(","2.",",","name=","'","w","'",")","...","return","x","*","self.w",">",">",">","mod","=","MultiplyModule","(",")",">",">",">","mod","(","1",".",")","<","tf.Tensor",":","...","numpy=2.0",">","Sonnet","modules","are","a","layer","on","top","of",":","tf",":","`","Module","`",",","implementing","automatic","name","scoping","as","described","in","the","original","RFC",":","cite",":","`","agarwal2019stateful","`","."]
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.
      """
      assert_tf2()
  
      super().__init__(name=name)
  
      if getattr(self.__init__, APPLY_NAME_SCOPE, True):
          # Enter the name scope so subsequent code in the contructor (e.g. creating
          # submodules) happens inside the modules name scope. This is exited when
          # the subclass __init__ returns (this is implemented in ModuleMetaclass).
          self._ctor_name_scope = self.name_scope
          self._ctor_name_scope.__enter__()
  
imports: import abc
  import functools
  import inspect
  import os
  import pprint
  import sys
  from typing import Any, Callable, Dict, Optional, Sequence, Tuple, Type, TypeVar
  from sonnet.src import once
  from sonnet.src import types
  from sonnet.src import utils
  import tensorflow
label_desc: Use image node_id 1 to create a new Module object from inherited base classes: tf with example: obj = Module(name)