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
docstr: Performs decoding. Has exact the same interfaces with
  :meth:`texar.tf.modules.TransformerDecoder._build` except inputs
  which is a tensor with shape `[batch_size, max_time]`. Please refer to
  it for the detailed usage.
code: def _build(
      self,
      decoding_strategy="train_greedy",
      inputs=None,
      memory=None,
      memory_sequence_length=None,
      memory_attention_bias=None,
      beam_width=None,
      length_penalty=0.0,
      start_tokens=None,
      end_token=None,
      context=None,
      context_sequence_length=None,
      softmax_temperature=None,
      max_decoding_length=None,
      impute_finished=False,
      helper=None,
      mode=None,
  ):
      r"""Performs decoding. Has exact the same interfaces with
      :meth:`texar.tf.modules.TransformerDecoder._build` except inputs
      which is a tensor with shape `[batch_size, max_time]`. Please refer to
      it for the detailed usage.
      """
      if inputs is not None:
          batch_size, max_time = inputs.shape.as_list()
          time = tf.expand_dims(tf.range(max_time), 0)
          time = tf.broadcast_to(time, [batch_size, max_time])
          inputs = self.embed_tokens(inputs, time)
  
      outputs = self.decoder._build(
          decoding_strategy=decoding_strategy,
          inputs=inputs,
          memory=memory,
          memory_sequence_length=memory_sequence_length,
          memory_attention_bias=memory_attention_bias,
          beam_width=beam_width,
          length_penalty=length_penalty,
          start_tokens=start_tokens,
          end_token=end_token,
          context=context,
          context_sequence_length=context_sequence_length,
          softmax_temperature=softmax_temperature,
          max_decoding_length=max_decoding_length,
          impute_finished=impute_finished,
          embedding=lambda a, b: self.embed_tokens(a, b),
          helper=helper,
          mode=mode,
      )
  
      if not self._built:
          self._add_internal_trainable_variables()
          self._built = True
  
          self.init_pretrained_weights(
              self.variable_scope.name, load_output_layer=True
          )
  
      return outputs
  
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 4 for calling the GPT2Decoder obj's underlying member method code with example usage: obj._build(decoding_strategy, inputs, memory, memory_sequence_length, memory_attention_bias, beam_width, length_penalty, start_tokens, end_token, context, context_sequence_length, softmax_temperature, max_decoding_length, impute_finished, helper, mode) and returns: outputs