class_docstr: Raw GPT2 Transformer for decoding sequences. Please see
  :class:`~texar.tf.modules.PretrainedGPT2Mixin` for a brief description
  of GPT2.
  
  This module basically stacks
  :class:`~texar.tf.modules.WordEmbedder`,
  :class:`~texar.tf.modules.PositionEmbedder`,
  :class:`~texar.tf.modules.TransformerDecoder`.
  
  This module supports the architecture first proposed
  in `(Radford et al.)` GPT2.
  
  Args:
      pretrained_model_name (optional): a `str`, the name
          of pre-trained model (e.g., ``gpt2-small``). Please refer to
          :class:`~texar.tf.modules.PretrainedGPT2Mixin` 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
code: def __init__(
      self, pretrained_model_name=None, cache_dir=None, hparams=None
  ):
      super().__init__(hparams=hparams)
  
      self.load_pretrained_config(pretrained_model_name, cache_dir)
  
      with tf.variable_scope(self.variable_scope):
          # Word embedding
          self.word_embedder = WordEmbedder(
              vocab_size=self._hparams.vocab_size,
              hparams=self._hparams.embed,
          )
  
          # Position embedding
          self.position_embedder = PositionEmbedder(
              position_size=self._hparams.position_size,
              hparams=self._hparams.position_embed,
          )
  
          # The GPT2 decoder (a TransformerDecoder)
          self.decoder = TransformerDecoder(
              vocab_size=self._hparams.vocab_size,
              output_layer=tf.transpose(
                  self.word_embedder.embedding, (1, 0)
              ),
              hparams=self._hparams.decoder,
          )
  
file_path: texar/texar/tf/modules/decoders/gpt2_decoder.py
imports: import tensorflow
  from texar.tf.modules.decoders.transformer_decoders import TransformerDecoder
  from texar.tf.modules.embedders import PositionEmbedder, WordEmbedder
  from texar.tf.modules.pretrained.gpt2 import PretrainedGPT2Mixin
label_desc: Use image node_id 1 to create a new GPT2Decoder object from inherited base classes: PretrainedGPT2Mixin with example: obj = GPT2Decoder(pretrained_model_name, cache_dir, hparams)