code: def testVqaAttentionBaseline(self):
      batch_size = 3
      image_size = 448
      vocab_size = 100
      num_classes = 10
      question_length = 5
      answer_length = 10
      x = 2 * np.random.rand(batch_size, image_size, image_size, 3) - 1
      q = np.random.randint(
          1, high=vocab_size, size=(batch_size, question_length, 1, 1)
      )
      a = np.random.randint(
          num_classes + 1, size=(batch_size, answer_length, 1, 1)
      )
      hparams = vqa_attention.vqa_attention_base()
      p_hparams = problem_hparams.test_problem_hparams(
          vocab_size, num_classes + 1, hparams
      )
      p_hparams.modality["inputs"] = modalities.ModalityType.IMAGE
      p_hparams.modality[
          "targets"
      ] = modalities.ModalityType.MULTI_LABEL
      p_hparams.modality["question"] = modalities.ModalityType.SYMBOL
      p_hparams.vocab_size["question"] = vocab_size
      with self.test_session() as session:
          features = {
              "inputs": tf.constant(x, dtype=tf.float32),
              "question": tf.constant(q, dtype=tf.int32),
              "targets": tf.constant(a, dtype=tf.int32),
          }
          model = vqa_attention.VqaAttentionBaseline(
              hparams, tf_estimator.ModeKeys.TRAIN, p_hparams
          )
          logits, losses = model(features)
          session.run(tf.global_variables_initializer())
          logits_, losses_ = session.run([logits, losses])
  
      self.assertEqual(
          logits_.shape, (batch_size, 1, 1, 1, num_classes + 1)
      )
      self.assertEqual(losses_["training"].shape, ())
  
file_path: tensor2tensor/tensor2tensor/models/research/vqa_attention_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  from tensor2tensor.data_generators import problem_hparams
  from tensor2tensor.layers import modalities
  from tensor2tensor.models.research import vqa_attention
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
label_desc: Use image node_id 1 for calling the VqaAttentionBaselineTest obj's underlying member method code with example usage: obj.testVqaAttentionBaseline() without return types