class_docstr: Compute relative multi-head attention for XLNet encoder.
  
  This module computes relative multi-head attention as explained in
  `Transformer-XL, (Zihang et. al)` and in `XLNet (Zhiling et. al)`.
  
  Args:
      r_r_bias: A tensor of shape `(num_heads, head_dim)`.
          The bias value added to query head while computing position based
          attention score.
  
      r_w_bias: A tensor of shape `(num_heads, head_dim)`.
          The bias value added to query head while computing content based
          attention score.
  
      r_s_bias (optional): A tensor of shape `(num_heads, head_dim)`.
          The bias value added to query head while computing segment based
          attention score.
  
      segment_embed (optional): A tensor of shape `(2, num_heads, head_dim)`
          if use_segments is True. Otherwise, this is set to None.
  
      hparams (dict or HParams, optional): Hyperparameters. Missing
          hyperparameter will be set to default values. See
          :meth:`default_hparams` for the hyperparameter sturcture
          and default values.
class_docstr_tok: ["Compute","relative","multi-head","attention","for","XLNet","encoder",".","This","module","computes","relative","multi-head","attention","as","explained","in","`","Transformer-XL",",","(","Zihang","et",".","al",")","`","and","in","`","XLNet","(","Zhiling","et",".","al",")","`",".","Args",":","r_r_bias",":","A","tensor","of","shape","`","(","num_heads",",","head_dim",")","`",".","The","bias","value","added","to","query","head","while","computing","position","based","attention","score",".","r_w_bias",":","A","tensor","of","shape","`","(","num_heads",",","head_dim",")","`",".","The","bias","value","added","to","query","head","while","computing","content","based","attention","score",".","r_s_bias","(","optional",")",":","A","tensor","of","shape","`","(","num_heads",",","head_dim",")","`",".","The","bias","value","added","to","query","head","while","computing","segment","based","attention","score",".","segment_embed","(","optional",")",":","A","tensor","of","shape","`","(","2",",","num_heads",",","head_dim",")","`","if","use_segments","is","True",".","Otherwise",",","this","is","set","to","None",".","hparams","(","dict","or","HParams",",","optional",")",":","Hyperparameters",".","Missing","hyperparameter","will","be","set","to","default","values",".","See",":","meth",":","`","default_hparams","`","for","the","hyperparameter","sturcture","and","default","values","."]
docstr: Returns a dictionary of hyperparameters with default values.
  
  .. code-block:: python
  
      {
          "name": "rel_attn",
          "initializer": None,
          "num_heads": 12,
          "hidden_dim": 768,
          "head_dim": 64,
          "dropout": 0.1,
          "attention_dropout": 0.1,
          "use_segments": True
      }
  
  
  
  Here:
  
  The default parameters are values for cased XLNet-Base model.
  
  "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 in the attention
  
  "hidden_dim": int
      Hidden dimension of the embeddings
  
  "head_dim": int
      Size of the vectors after head projection.
  
  "dropout": float
      Dropout rate for layers
  
  "attention_dropout": float
      Dropout rate for attention layers
  
  "use_segments": bool
      Boolean to indicate if the input has segments
  
  "name": str
      Name of the module.
docstr_tok: ["Returns","a","dictionary","of","hyperparameters","with","default","values",".","..","code-block",":",":","python","{","``","name","''",":","``","rel_attn","''",",","``","initializer","''",":","None",",","``","num_heads","''",":","12",",","``","hidden_dim","''",":","768",",","``","head_dim","''",":","64",",","``","dropout","''",":","0.1",",","``","attention_dropout","''",":","0.1",",","``","use_segments","''",":","True","}","Here",":","The","default","parameters","are","values","for","cased","XLNet-Base","model",".","``","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","in","the","attention","''","hidden_dim","''",":","int","Hidden","dimension","of","the","embeddings","''","head_dim","''",":","int","Size","of","the","vectors","after","head","projection",".","``","dropout","''",":","float","Dropout","rate","for","layers","''","attention_dropout","''",":","float","Dropout","rate","for","attention","layers","''","use_segments","''",":","bool","Boolean","to","indicate","if","the","input","has","segments","''","name","''",":","str","Name","of","the","module","."]
code: def default_hparams():
      r"""Returns a dictionary of hyperparameters with default values.
  
      .. code-block:: python
  
          {
              "name": "rel_attn",
              "initializer": None,
              "num_heads": 12,
              "hidden_dim": 768,
              "head_dim": 64,
              "dropout": 0.1,
              "attention_dropout": 0.1,
              "use_segments": True
          }
  
  
  
      Here:
  
      The default parameters are values for cased XLNet-Base model.
  
      "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 in the attention
  
      "hidden_dim": int
          Hidden dimension of the embeddings
  
      "head_dim": int
          Size of the vectors after head projection.
  
      "dropout": float
          Dropout rate for layers
  
      "attention_dropout": float
          Dropout rate for attention layers
  
      "use_segments": bool
          Boolean to indicate if the input has segments
  
      "name": str
          Name of the module.
      """
      return {
          "name": "rel_attn",
          "initializer": None,
          "num_heads": 12,
          "hidden_dim": 768,
          "head_dim": 64,
          "dropout": 0.1,
          "attention_dropout": 0.1,
          "use_segments": True,
      }
  
imports: import tensorflow
  from texar.tf.core import layers
  from texar.tf.module_base import ModuleBase
  from texar.tf.utils.mode import is_train_mode
label_desc: Use image node_id 2 for calling the RelativeMutiheadAttention obj's underlying member method code with example usage: obj.default_hparams() and returns: dict