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"]
docstr: Args:
      x: A Tensor of shape `[batch, num_heads, seq_len, dim]`
  
  Returns:
      A Tensor of shape `[batch, seq_len, num_heads * dim]`
docstr_tok: ["Args",":","x",":","A","Tensor","of","shape","`","[","batch",",","num_heads",",","seq_len",",","dim","]","`","Returns",":","A","Tensor","of","shape","`","[","batch",",","seq_len",",","num_heads","*","dim","]","`"]
code: def _combine_heads(self, x):
      """
      Args:
          x: A Tensor of shape `[batch, num_heads, seq_len, dim]`
  
      Returns:
          A Tensor of shape `[batch, seq_len, num_heads * dim]`
      """
      t = tf.transpose(
          x, [0, 2, 1, 3]
      )  # [batch, seq_len, num_heads, dim]
      num_heads, dim = shape_list(t)[-2:]
      assert num_heads == self._hparams.num_heads
      return tf.reshape(
          t, [tf.shape(t)[0], tf.shape(t)[1], num_heads * dim]
      )
  
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 5 for calling the MultiheadAttentionEncoder obj's underlying member method code with example usage: obj._combine_heads(x) and returns: tf