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
code: def __init__(self, hparams=None):
      if not hasattr(self, "_hparams"):
          self._hparams = HParams(hparams, self.default_hparams())
      else:
          # Probably already parsed by subclasses. We rely on subclass
          # implementations to get this right.
          # As a sanity check, we require `hparams` to be `None` in this case.
          if hparams is not None:
              raise ValueError(
                  "`self._hparams` already exists. Argument `hparams` "
                  "must be set to `None` in this case."
              )
      self._template = tf.make_template(
          self._hparams.name, self._build, create_scope_now_=True
      )
      self._unique_name = self.variable_scope.name.split("/")[-1]
      self._trainable_variables = []
      self._built = False
  
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 1 to create a new ModuleBase object from inherited base classes: object with example: obj = ModuleBase(hparams)