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: Sequence of :tf:`Variable`\ s owned by this module and it's submodules.
  
  See :tf:`Module.trainable_variables` for implementation details.
  
  NOTE: Most Sonnet modules create variables lazily (e.g. the first time they
  are called). As such just after construction there are typically no
  variables. To mitigate a common error (calling ``.variables`` or
  ``.trainable_variables`` before any variables are created) these properties
  will raise an exception if their result is empty. See
  :func:`allow_empty_variables` if you want to suppress this error.
  
  Returns:
    A sequence of variables for the current module (sorted by attribute
    name) followed by variables from all submodules recursively (breadth
    first).
docstr_tok: ["Sequence","of",":","tf",":","`","Variable","`","\\","s","owned","by","this","module","and","it","'s","submodules",".","See",":","tf",":","`","Module.trainable_variables","`","for","implementation","details",".","NOTE",":","Most","Sonnet","modules","create","variables","lazily","(","e.g",".","the","first","time","they","are","called",")",".","As","such","just","after","construction","there","are","typically","no","variables",".","To","mitigate","a","common","error","(","calling","``",".variables","``","or","``",".trainable_variables","``","before","any","variables","are","created",")","these","properties","will","raise","an","exception","if","their","result","is","empty",".","See",":","func",":","`","allow_empty_variables","`","if","you","want","to","suppress","this","error",".","Returns",":","A","sequence","of","variables","for","the","current","module","(","sorted","by","attribute","name",")","followed","by","variables","from","all","submodules","recursively","(","breadth","first",")","."]
code: def trainable_variables(self):
      r"""Sequence of :tf:`Variable`\ s owned by this module and it's submodules.
  
      See :tf:`Module.trainable_variables` for implementation details.
  
      NOTE: Most Sonnet modules create variables lazily (e.g. the first time they
      are called). As such just after construction there are typically no
      variables. To mitigate a common error (calling ``.variables`` or
      ``.trainable_variables`` before any variables are created) these properties
      will raise an exception if their result is empty. See
      :func:`allow_empty_variables` if you want to suppress this error.
  
      Returns:
        A sequence of variables for the current module (sorted by attribute
        name) followed by variables from all submodules recursively (breadth
        first).
      """
      trainable_variables = super().trainable_variables
      if not trainable_variables and not getattr(
          self, ALLOW_EMPTY_RESULT, False
      ):
          # Raise a useful error if the collection is empty. Typically this
          # indicates that the user has requested the property before the module has
          # been connected. In many situations this can cause hard to diagnose
          # problems (eg. if you are trying to copy the initial state from one
          # module to another by zipping both module variables and assigning one to
          # the other).
          raise ValueError(
              NO_VARIABLES_ERROR.format(
                  module=self, property="trainable_variables"
              )
          )
      return trainable_variables
  
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 3 for calling the Module obj's underlying member method code with example usage: obj.trainable_variables() and returns: trainable_variables