class_docstr: Regressor based on XLNet modules. Please see
  :class:`~texar.tf.modules.PretrainedXLNetMixin` for a brief description
  of XLNet.
  
  This is a combination of the :class:`~texar.tf.modules.XLNetEncoder` with a
  classification layer. Both step-wise classification and sequence-level
  classification are supported, specified in :attr:`hparams`.
  
  Arguments are the same as in :class:`~texar.tf.modules.XLNetEncoder`.
  
  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
          hyperparameters 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: ["Regressor","based","on","XLNet","modules",".","Please","see",":","class",":","`","~texar.tf.modules.PretrainedXLNetMixin","`","for","a","brief","description","of","XLNet",".","This","is","a","combination","of","the",":","class",":","`","~texar.tf.modules.XLNetEncoder","`","with","a","classification","layer",".","Both","step-wise","classification","and","sequence-level","classification","are","supported",",","specified","in",":","attr",":","`","hparams","`",".","Arguments","are","the","same","as","in",":","class",":","`","~texar.tf.modules.XLNetEncoder","`",".","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","hyperparameters","will","be","set","to","default","values",".","See",":","meth",":","`","default_hparams","`","for","the","hyperparameter","structure","and","default","values",".","..","document","private","functions","..","automethod",":",":","_build"]
docstr: Feeds the inputs through the network and makes regression.
  
  Args:
      token_ids: Shape `[batch_size, max_time]`.
      segment_ids: Shape `[batch_size, max_time]`.
      input_mask: Float tensor of shape `[batch_size, max_time]`. Note
          that positions with value 1 are masked out.
      mode (optional): A tensor taking value in
          :tf_main:`tf.estimator.ModeKeys <estimator/ModeKeys>`,
          including `TRAIN`, `EVAL`, and `PREDICT`. Used to toggle
          dropout.
          If `None` (default), :func:`texar.tf.global_mode` is used.
  
  Returns:
      Regression predictions.
  
      - If ``regr_strategy`` is ``cls_time`` or ``all_time``, predictions
        have shape `[batch_size]`.
  
      - If ``clas_strategy`` is ``time_wise``, predictions have shape
        `[batch_size, max_time]`.
docstr_tok: ["Feeds","the","inputs","through","the","network","and","makes","regression",".","Args",":","token_ids",":","Shape","`","[","batch_size",",","max_time","]","`",".","segment_ids",":","Shape","`","[","batch_size",",","max_time","]","`",".","input_mask",":","Float","tensor","of","shape","`","[","batch_size",",","max_time","]","`",".","Note","that","positions","with","value","1","are","masked","out",".","mode","(","optional",")",":","A","tensor","taking","value","in",":","tf_main",":","`","tf.estimator.ModeKeys","<","estimator\/ModeKeys",">","`",",","including","`","TRAIN","`",",","`","EVAL","`",",","and","`","PREDICT","`",".","Used","to","toggle","dropout",".","If","`","None","`","(","default",")",",",":","func",":","`","texar.tf.global_mode","`","is","used",".","Returns",":","Regression","predictions",".","-","If","``","regr_strategy","``","is","``","cls_time","``","or","``","all_time","``",",","predictions","have","shape","`","[","batch_size","]","`",".","-","If","``","clas_strategy","``","is","``","time_wise","``",",","predictions","have","shape","`","[","batch_size",",","max_time","]","`","."]
code: def _build(
      self, token_ids, segment_ids=None, input_mask=None, mode=None
  ):
      r"""Feeds the inputs through the network and makes regression.
  
      Args:
          token_ids: Shape `[batch_size, max_time]`.
          segment_ids: Shape `[batch_size, max_time]`.
          input_mask: Float tensor of shape `[batch_size, max_time]`. Note
              that positions with value 1 are masked out.
          mode (optional): A tensor taking value in
              :tf_main:`tf.estimator.ModeKeys <estimator/ModeKeys>`,
              including `TRAIN`, `EVAL`, and `PREDICT`. Used to toggle
              dropout.
              If `None` (default), :func:`texar.tf.global_mode` is used.
  
      Returns:
          Regression predictions.
  
          - If ``regr_strategy`` is ``cls_time`` or ``all_time``, predictions
            have shape `[batch_size]`.
  
          - If ``clas_strategy`` is ``time_wise``, predictions have shape
            `[batch_size, max_time]`.
      """
      is_training = is_train_mode(mode)
      output, _ = self._encoder(
          token_ids, segment_ids, input_mask=input_mask, mode=mode
      )
  
      strategy = self._hparams.regr_strategy
      if strategy == "time_wise":
          summary = output
      elif strategy == "cls_time":
          summary = output[:, -1]
      elif strategy == "all_time":
          length_diff = (
              self._hparams.max_seq_len - tf.shape(token_ids)[1]
          )
          summary_input = tf.pad(
              output, paddings=[[0, 0], [0, length_diff], [0, 0]]
          )
          summary_input_dim = (
              self._encoder.output_size * self._hparams.max_seq_len
          )
          summary = tf.reshape(
              summary_input, shape=[-1, summary_input_dim]
          )
      else:
          raise ValueError(
              "Unknown classification strategy: {}".format(strategy)
          )
  
      if self._hparams.use_projection:
          summary = tf.tanh(self.projection(summary))
  
      # summary: (batch_size, hidden_dim)
      summary = self._dropout_layer(summary, training=is_training)
  
      logits = tf.squeeze(self._logit_layer(summary), -1)
  
      if not self._built:
          self._add_internal_trainable_variables()
          if self._logit_layer:
              self._add_trainable_variable(
                  self._logit_layer.trainable_variables
              )
          self._built = True
  
      return logits
  
file_path: texar/texar/tf/modules/regressors/xlnet_regressor.py
imports: import tensorflow
  from texar.tf.utils.mode import is_train_mode
  from texar.tf.core.layers import get_layer, get_initializer
  from texar.tf.modules.regressors.regressor_base import RegressorBase
  from texar.tf.modules.encoders.xlnet_encoder import XLNetEncoder
  from texar.tf.hyperparams import HParams
  from texar.tf.modules.pretrained.xlnet import PretrainedXLNetMixin
  from texar.tf.utils.utils import dict_fetch
label_desc: Use image node_id 4 for calling the XLNetRegressor obj's underlying member method code with example usage: obj._build(token_ids, segment_ids, input_mask, mode) and returns: logits