def vqa_example(image):
  """Convert visual qa data into an Example proto.

  Args:
    image: An ImageMetadata instance.

  Returns:
    example: An Example proto with serialized tensor data.
  """
  # Collect image object information from metadata.
  image_features, positions = read_object(image.objects, image.image_id)

  # Serialize multi-dimensional tensor data.
  captions_proto = tf.make_tensor_proto(np.array(image.captions))
  question_ids_proto = tf.make_tensor_proto(np.array(image.question_ids))
  questions_proto = tf.make_tensor_proto(np.array(image.questions))
  features_proto = tf.make_tensor_proto(image_features)
  positions_proto = tf.make_tensor_proto(positions)

  # Take the first answer always for simplicity.
  # This is only used for training and unofficial eval.
  answers = copy.deepcopy(image.answers)
  for i, answer in enumerate(answers):
    answers[i] = answer[0]
  answers_proto = tf.make_tensor_proto(np.array(answers))

  # Create final features dict.
  features = dict(
      image_id=int64_feature(image.image_id),
      question_ids=bytes_feature(question_ids_proto.SerializeToString()),
      questions=bytes_feature(questions_proto.SerializeToString()),
      answers=bytes_feature(answers_proto.SerializeToString()),
      captions=bytes_feature(captions_proto.SerializeToString()),
      object_features=bytes_feature(features_proto.SerializeToString()),
      object_positions=bytes_feature(positions_proto.SerializeToString()))
  return tf.train.Example(features=tf.train.Features(feature=features))
Convert visual qa data into an Example proto.

  Args:
    image: An ImageMetadata instance.

  Returns:
    example: An Example proto with serialized tensor data.
  
language/capwap/utils/io_utils.py