class_docstr: Base class inherited by modules that create Variables and are
  configurable through hyperparameters.
  
  A Texar module inheriting :class:`~texar.tf.ModuleBase` has following key
  features:
  
      - **Convenient variable re-use**: A module instance creates         its own sets of variables, and automatically re-uses its variables on         subsequent calls. Hence TF variable/name scope is         transparent to users. For example:
  
          .. code-block:: python
  
              encoder = UnidirectionalRNNEncoder(hparams) # create instance
              output_1 = encoder(inputs_1) # variables are created
              output_2 = encoder(inputs_2) # variables are re-used
  
              print(encoder.trainable_variables) # access trainable variables
              # [ ... ]
  
      - **Configurable through hyperparameters**: Each module defines         allowed hyperparameters and default values. Hyperparameters not         specified by users will take default values.
  
      - **Callable**: As the above example, a module instance is "called"         with input tensors and returns output tensors. Every call of a module         will add ops to the Graph to perform the module's logic.
  
  Args:
      hparams (dict, optional): Hyperparameters of the module. See
          :meth:`default_hparams` for the structure and default values.
  
  
  .. document private functions
  .. automethod:: _build
docstr: Adds a trainable variable to the trainable variable list of the
  module.
  
  Args:
      variable: a (list of) trainable variable(s) constructed either
          internally in the module or constructured outside but used
          inside the module.
docstr_tok: ["Adds","a","trainable","variable","to","the","trainable","variable","list","of","the","module",".","Args",":","variable",":","a","(","list","of",")","trainable","variable","(","s",")","constructed","either","internally","in","the","module","or","constructured","outside","but","used","inside","the","module","."]
code: def _add_trainable_variable(self, variable):
      """Adds a trainable variable to the trainable variable list of the
      module.
  
      Args:
          variable: a (list of) trainable variable(s) constructed either
              internally in the module or constructured outside but used
              inside the module.
      """
      if isinstance(variable, (list, tuple)):
          for var in variable:
              self._add_trainable_variable(var)
      else:
          if variable not in self._trainable_variables:
              self._trainable_variables.append(variable)
  
file_path: texar/texar/tf/module_base.py
imports: import re
  import tensorflow
  from texar.tf.utils.exceptions import TexarError
  from texar.tf.hyperparams import HParams
label_desc: Use image node_id 6 for calling the ModuleBase obj's underlying member method code with example usage: obj._add_trainable_variable(variable) without return types