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: Create parameter groups for optimizers. When
  :attr:`lr_layer_decay_rate` is not 1.0, parameters from each layer form
  separate groups with different base learning rates.
  
  This method should be called before applying gradients to the variables
  through the optimizer. Particularly, after calling the optimizer's
  `compute_gradients` method, the user can call this method to get
  variable-specific learning rates for the network. The gradients for each
  variables can then be scaled accordingly. These scaled gradients are
  finally applied by calling optimizer's `apply_gradients` method.
  
  Args:
      lr (float): The learning rate. Can be omitted if
          :attr:`lr_layer_decay_rate` is 1.0.
      lr_layer_scale (float): Per-layer LR scaling rate. The `i`-th layer
          will be scaled by `lr_layer_scale ^ (num_layers - i - 1)`.
      decay_base_params (bool): If `True`, treat non-layer parameters
          (e.g. embeddings) as if they're in layer 0. If `False`, these
          parameters are not scaled.
  
  Returns: A dict mapping tensorflow variables to their learning rates.
docstr_tok: ["Create","parameter","groups","for","optimizers",".","When",":","attr",":","`","lr_layer_decay_rate","`","is","not","1.0",",","parameters","from","each","layer","form","separate","groups","with","different","base","learning","rates",".","This","method","should","be","called","before","applying","gradients","to","the","variables","through","the","optimizer",".","Particularly",",","after","calling","the","optimizer's","`","compute_gradients","`","method",",","the","user","can","call","this","method","to","get","variable-specific","learning","rates","for","the","network",".","The","gradients","for","each","variables","can","then","be","scaled","accordingly",".","These","scaled","gradients","are","finally","applied","by","calling","optimizer","'s","`","apply_gradients","`","method",".","Args",":","lr","(","float",")",":","The","learning","rate",".","Can","be","omitted","if",":","attr",":","`","lr_layer_decay_rate","`","is","1.0.","lr_layer_scale","(","float",")",":","Per-layer","LR","scaling","rate",".","The","`","i","`","-th","layer","will","be","scaled","by","`","lr_layer_scale","^","(","num_layers","-","i","-","1",")","`",".","decay_base_params","(","bool",")",":","If","`","True","`",",","treat","non-layer","parameters","(","e.g",".","embeddings",")","as","if","they","'re","in","layer","0",".","If","`","False","`",",","these","parameters","are","not","scaled",".","Returns",":","A","dict","mapping","tensorflow","variables","to","their","learning","rates","."]
code: def param_groups(
      self, lr=None, lr_layer_scale=1.0, decay_base_params=False
  ):
      r"""Create parameter groups for optimizers. When
      :attr:`lr_layer_decay_rate` is not 1.0, parameters from each layer form
      separate groups with different base learning rates.
  
      This method should be called before applying gradients to the variables
      through the optimizer. Particularly, after calling the optimizer's
      `compute_gradients` method, the user can call this method to get
      variable-specific learning rates for the network. The gradients for each
      variables can then be scaled accordingly. These scaled gradients are
      finally applied by calling optimizer's `apply_gradients` method.
  
      Args:
          lr (float): The learning rate. Can be omitted if
              :attr:`lr_layer_decay_rate` is 1.0.
          lr_layer_scale (float): Per-layer LR scaling rate. The `i`-th layer
              will be scaled by `lr_layer_scale ^ (num_layers - i - 1)`.
          decay_base_params (bool): If `True`, treat non-layer parameters
              (e.g. embeddings) as if they're in layer 0. If `False`, these
              parameters are not scaled.
  
      Returns: A dict mapping tensorflow variables to their learning rates.
      """
      vars_to_learning_rates = {}
      if lr_layer_scale != 1.0:
          if lr is None:
              raise ValueError(
                  "lr must be specified when lr_layer_decay_rate is not 1.0"
              )
  
          scope = self.variable_scope.name
          projection_vars = tf.trainable_variables(
              scope=scope + "/dense"
          )
          logits_vars = tf.trainable_variables(
              scope=self.variable_scope.name + "/logit_layer"
          )
          finetune_vars = projection_vars + logits_vars
          for var in finetune_vars:
              vars_to_learning_rates[var] = lr
  
          vars_to_learning_rates.update(
              self._encoder.param_groups(
                  lr=lr,
                  lr_layer_scale=lr_layer_scale,
                  decay_base_params=decay_base_params,
              )
          )
      else:
          for variable in self.trainable_variables:
              vars_to_learning_rates[variable] = lr
  
      return vars_to_learning_rates
  
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 3 for calling the XLNetRegressor obj's underlying member method code with example usage: obj.param_groups(lr, lr_layer_scale, decay_base_params) and returns: vars_to_learning_rates