class_docstr: Raw XLNet module for encoding sequences. Please see
  :class:`~texar.tf.modules.PretrainedXLNetMixin` for a brief description
  of XLNet.
  
  Args:
      pretrained_model_name (optional): a `str`, the name
          of pre-trained model (e.g., ``xlnet-based-cased``). Please refer to
          :class:`~texar.tf.modules.PretrainedXLNetMixin` for
          all supported models.
          If `None`, the model name in :attr:`hparams` is used.
      cache_dir (optional): the path to a folder in which the
          pre-trained models will be cached. If `None` (default),
          a default directory (``texar_data`` folder under user's home
          directory) will be used.
      hparams (dict or HParams, optional): Hyperparameters. Missing
          hyperparameter will be set to default values. See
          :meth:`default_hparams` for the hyperparameter structure
          and default values.
  
  .. document private functions
  .. automethod:: _build
class_docstr_tok: ["Raw","XLNet","module","for","encoding","sequences",".","Please","see",":","class",":","`","~texar.tf.modules.PretrainedXLNetMixin","`","for","a","brief","description","of","XLNet",".","Args",":","pretrained_model_name","(","optional",")",":","a","`","str","`",",","the","name","of","pre-trained","model","(","e.g.",",","``","xlnet-based-cased","``",")",".","Please","refer","to",":","class",":","`","~texar.tf.modules.PretrainedXLNetMixin","`","for","all","supported","models",".","If","`","None","`",",","the","model","name","in",":","attr",":","`","hparams","`","is","used",".","cache_dir","(","optional",")",":","the","path","to","a","folder","in","which","the","pre-trained","models","will","be","cached",".","If","`","None","`","(","default",")",",","a","default","directory","(","``","texar_data","``","folder","under","user","'s","home","directory",")","will","be","used",".","hparams","(","dict","or","HParams",",","optional",")",":","Hyperparameters",".","Missing","hyperparameter","will","be","set","to","default","values",".","See",":","meth",":","`","default_hparams","`","for","the","hyperparameter","structure","and","default","values",".","..","document","private","functions","..","automethod",":",":","_build"]
docstr: Create causal attention mask.
docstr_tok: ["Create","causal","attention","mask","."]
code: def _create_mask(
      self, qlen, mlen, dtype=tf.float32, same_length=False
  ):
      r"""Create causal attention mask."""
      attn_mask = tf.ones([qlen, qlen], dtype=dtype)
      mask_u = tf.matrix_band_part(attn_mask, 0, -1)
      mask_dia = tf.matrix_band_part(attn_mask, 0, 0)
      attn_mask_pad = tf.zeros([qlen, mlen], dtype=dtype)
      ret = tf.concat([attn_mask_pad, mask_u - mask_dia], axis=1)
      if same_length:
          mask_l = tf.matrix_band_part(attn_mask, -1, 0)
          ret = tf.concat(
              [ret[:, :qlen] + mask_l - mask_dia, ret[:, qlen:]], axis=1
          )
  
      return ret
  
imports: import tensorflow
  from texar.tf.utils.mode import is_train_mode
  from texar.tf.core.layers import get_initializer, get_layer
  from texar.tf.modules.embedders.embedders import WordEmbedder
  from texar.tf.modules.encoders.encoder_base import EncoderBase
  from texar.tf.modules.pretrained.xlnet import PretrainedXLNetMixin
  from texar.tf.modules.pretrained.xlnet_utils import PositionWiseFF, RelativePositionalEncoding, RelativeMutiheadAttention
  from texar.tf.utils.utils import dict_fetch
label_desc: Use image node_id 7 for calling the XLNetEncoder obj's underlying member method code with example usage: obj._create_mask(qlen, mlen, dtype, same_length) and returns: ret