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: Returns a dictionary of hyperparameters with default values.
  
  .. code-block:: python
  
      {
          "initializer": None,
          'num_heads': 8,
          'output_dim': 512,
          'num_units': 512,
          'dropout_rate': 0.1,
          'use_bias': False,
          "name": "multihead_attention"
      }
  
  Here:
  
  "initializer": dict, optional
      Hyperparameters of the default initializer that initializes
      variables created in this module.
      See :func:`~texar.tf.core.get_initializer` for details.
  
  "num_heads": int
      Number of heads for attention calculation.
  
  "output_dim": int
      Output dimension of the returned tensor.
  
  "num_units": int
      Hidden dimension of the unsplitted attention space.
      Should be devisible by `num_heads`.
  
  "dropout_rate: : float
      Dropout rate in the attention.
  
  "use_bias": bool
      Use bias when projecting the key, value and query.
  
  "name": str
      Name of the module.
docstr_tok: ["Returns","a","dictionary","of","hyperparameters","with","default","values",".","..","code-block",":",":","python","{","``","initializer","''",":","None",",","'num_heads","'",":","8",",","'output_dim","'",":","512",",","'num_units","'",":","512",",","'dropout_rate","'",":","0.1",",","'use_bias","'",":","False",",","``","name","''",":","``","multihead_attention","''","}","Here",":","''","initializer","''",":","dict",",","optional","Hyperparameters","of","the","default","initializer","that","initializes","variables","created","in","this","module",".","See",":","func",":","`","~texar.tf.core.get_initializer","`","for","details",".","``","num_heads","''",":","int","Number","of","heads","for","attention","calculation",".","``","output_dim","''",":","int","Output","dimension","of","the","returned","tensor",".","``","num_units","''",":","int","Hidden","dimension","of","the","unsplitted","attention","space",".","Should","be","devisible","by","`","num_heads","`",".","``","dropout_rate",":",":","float","Dropout","rate","in","the","attention",".","``","use_bias","''",":","bool","Use","bias","when","projecting","the","key",",","value","and","query",".","``","name","''",":","str","Name","of","the","module","."]
code: def default_hparams():
      """Returns a dictionary of hyperparameters with default values.
  
      .. code-block:: python
  
          {
              "initializer": None,
              'num_heads': 8,
              'output_dim': 512,
              'num_units': 512,
              'dropout_rate': 0.1,
              'use_bias': False,
              "name": "multihead_attention"
          }
  
      Here:
  
      "initializer": dict, optional
          Hyperparameters of the default initializer that initializes
          variables created in this module.
          See :func:`~texar.tf.core.get_initializer` for details.
  
      "num_heads": int
          Number of heads for attention calculation.
  
      "output_dim": int
          Output dimension of the returned tensor.
  
      "num_units": int
          Hidden dimension of the unsplitted attention space.
          Should be devisible by `num_heads`.
  
      "dropout_rate: : float
          Dropout rate in the attention.
  
      "use_bias": bool
          Use bias when projecting the key, value and query.
  
      "name": str
          Name of the module.
      """
      return {
          "initializer": None,
          "num_heads": 8,
          "output_dim": 512,
          "num_units": 512,
          "dropout_rate": 0.1,
          "use_bias": False,
          "name": "multihead_attention",
      }
  
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 2 for calling the MultiheadAttentionEncoder obj's underlying member method code with example usage: obj.default_hparams() and returns: dict