class_docstr: Multihead Attention Encoder
  
  Args:
      hparams (dict or HParams, optional): Hyperparameters. Missing
          hyperparamerter will be set to default values. See
          :meth:`default_hparams` for the hyperparameter sturcture and
          default values.
  
  .. document private functions
  .. automethod:: _build
class_docstr_tok: ["Multihead","Attention","Encoder","Args",":","hparams","(","dict","or","HParams",",","optional",")",":","Hyperparameters",".","Missing","hyperparamerter","will","be","set","to","default","values",".","See",":","meth",":","`","default_hparams","`","for","the","hyperparameter","sturcture","and","default","values",".","..","document","private","functions","..","automethod",":",":","_build"]
code: def __init__(self, hparams=None):
      EncoderBase.__init__(self, hparams)
      use_bias = self._hparams.use_bias
  
      with tf.variable_scope(self.variable_scope):
          if self._hparams.initializer:
              tf.get_variable_scope().set_initializer(
                  layers.get_initializer(self._hparams.initializer)
              )
  
          self.Q_dense = tf.layers.Dense(
              self._hparams.num_units, use_bias=use_bias, name="query"
          )
          self.K_dense = tf.layers.Dense(
              self._hparams.num_units, use_bias=use_bias, name="key"
          )
          self.V_dense = tf.layers.Dense(
              self._hparams.num_units, use_bias=use_bias, name="value"
          )
          self.O_dense = tf.layers.Dense(
              self._hparams.output_dim, use_bias=use_bias, name="output"
          )
  
file_path: texar/texar/tf/modules/encoders/multihead_attention.py
imports: import tensorflow
  from texar.tf.core import layers
  from texar.tf.modules.encoders.encoder_base import EncoderBase
  from texar.tf.utils.shapes import shape_list
  from texar.tf.utils.mode import is_train_mode
  from texar.tf.utils import transpose_batch_time
label_desc: Use image node_id 1 to create a new MultiheadAttentionEncoder object from inherited base classes: EncoderBase with example: obj = MultiheadAttentionEncoder(hparams)