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: Split channels (dimension 2) into multiple heads,
  becomes dimension 1).
  
  Must ensure `x.shape[-1]` can be deviced by num_heads
docstr_tok: ["Split","channels","(","dimension","2",")","into","multiple","heads",",","becomes","dimension","1",")",".","Must","ensure","`","x.shape","[","-1","]","`","can","be","deviced","by","num_heads"]
code: def _split_heads(self, x):
      """Split channels (dimension 2) into multiple heads,
      becomes dimension 1).
  
      Must ensure `x.shape[-1]` can be deviced by num_heads
      """
      depth = shape_list(x)[-1]
      splitted_x = tf.reshape(
          x,
          [
              tf.shape(x)[0],
              tf.shape(x)[1],
              self._hparams.num_heads,
              depth // self._hparams.num_heads,
          ],
      )
      return tf.transpose(splitted_x, [0, 2, 1, 3])
  
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 4 for calling the MultiheadAttentionEncoder obj's underlying member method code with example usage: obj._split_heads(x) and returns: tf