class_docstr: Tests :class:`~texar.tf.modules.BERTClassifier` class.
      
docstr: Tests encoding.
          
code: def test_encode(self):
      """Tests encoding."""
      max_time = 8
      batch_size = 16
      inputs = tf.random_uniform(
          [batch_size, max_time], maxval=30521, dtype=tf.int32
      )
      # case 1
      hparams = {
          "pretrained_model_name": None,
      }
      clas = BERTClassifier(hparams=hparams)
      logits, pred = clas(inputs)
  
      with self.test_session() as sess:
          sess.run(tf.global_variables_initializer())
          logits_, pred_ = sess.run([logits, pred])
          self.assertEqual(
              logits_.shape, (batch_size, clas.hparams.num_classes)
          )
          self.assertEqual(pred_.shape, (batch_size,))
  
      # case 2
      hparams = {
          "pretrained_model_name": None,
          "num_classes": 10,
          "clas_strategy": "time_wise",
      }
      clas = BERTClassifier(hparams=hparams)
      logits, pred = clas(inputs)
  
      with self.test_session() as sess:
          sess.run(tf.global_variables_initializer())
          logits_, pred_ = sess.run([logits, pred])
          self.assertEqual(
              logits_.shape,
              (batch_size, max_time, clas.hparams.num_classes),
          )
          self.assertEqual(pred_.shape, (batch_size, max_time))
  
      # case 3
      hparams = {
          "pretrained_model_name": None,
          "num_classes": 0,
          "clas_strategy": "time_wise",
      }
      clas = BERTClassifier(hparams=hparams)
      logits, pred = clas(inputs)
  
      with self.test_session() as sess:
          sess.run(tf.global_variables_initializer())
          logits_, pred_ = sess.run([logits, pred])
          self.assertEqual(
              logits_.shape,
              (batch_size, max_time, clas.hparams.encoder.dim),
          )
          self.assertEqual(pred_.shape, (batch_size, max_time))
  
      # case 4
      hparams = {
          "pretrained_model_name": None,
          "num_classes": 10,
          "clas_strategy": "all_time",
          "max_seq_length": max_time,
      }
      inputs = tf.placeholder(tf.int32, shape=[batch_size, 6])
      clas = BERTClassifier(hparams=hparams)
      logits, pred = clas(inputs)
  
      with self.test_session() as sess:
          sess.run(tf.global_variables_initializer())
          logits_, pred_ = sess.run(
              [logits, pred],
              feed_dict={
                  inputs: np.random.randint(30521, size=(batch_size, 6))
              },
          )
          self.assertEqual(
              logits_.shape, (batch_size, clas.hparams.num_classes)
          )
          self.assertEqual(pred_.shape, (batch_size,))
  
file_path: texar/tests/modules/classifiers/bert_classifier_test.py
imports: import numpy
  import tensorflow
  from texar.tf.modules.classifiers.bert_classifier import BERTClassifier
  from texar.tf.utils.test import pretrained_test
label_desc: Use image node_id 3 for calling the BERTClassifierTest obj's underlying member method code with example usage: obj.test_encode() without return types