class_docstr: Tests :class:`~texar.torch.modules.GPT2Decoder`
      
docstr: Tests the priority of the decoder arch parameters.
          
code: def test_hparams(self):
      r"""Tests the priority of the decoder arch parameters."""
  
      inputs = tf.placeholder(dtype=tf.int32, shape=[2, 3])
  
      # case 1: set "pretrained_mode_name" by constructor argument
      hparams = {
          "pretrained_model_name": "gpt2-medium",
      }
      decoder = GPT2Decoder(
          pretrained_model_name="gpt2-small", hparams=hparams
      )
      _ = decoder(inputs=inputs)
      self.assertEqual(decoder.hparams.decoder.num_blocks, 12)
  
      # case 2: set "pretrained_mode_name" by hparams
      hparams = {
          "pretrained_model_name": "gpt2-small",
          "decoder": {
              "num_blocks": 6,
          },
      }
      decoder = GPT2Decoder(hparams=hparams)
      _ = decoder(inputs=inputs)
      self.assertEqual(decoder.hparams.decoder.num_blocks, 12)
  
      # case 3: set to None in both hparams and constructor argument
      hparams = {
          "pretrained_model_name": None,
          "decoder": {
              "num_blocks": 6,
          },
      }
      decoder = GPT2Decoder(hparams=hparams)
      _ = decoder(inputs=inputs)
      self.assertEqual(decoder.hparams.decoder.num_blocks, 6)
  
      # case 4: using default hparams
      decoder = GPT2Decoder()
      _ = decoder(inputs=inputs)
      self.assertEqual(decoder.hparams.decoder.num_blocks, 12)
  
file_path: texar/tests/modules/decoders/gpt2_decoder_test.py
imports: import tensorflow
  from texar.tf.modules.decoders.gpt2_decoder import GPT2Decoder
  from texar.tf.modules.decoders.transformer_decoders import TransformerDecoderOutput
  from texar.tf.utils.test import pretrained_test
label_desc: Use image node_id 1 for calling the GPT2DecoderTest obj's underlying member method code with example usage: obj.test_hparams() without return types