code: def testPrefixAccuracy(self):
      vocab_size = 10
      predictions = tf.one_hot(
          tf.constant(
              [
                  [[1], [2], [3], [4], [9], [6], [7], [8]],
                  [[1], [2], [3], [4], [5], [9], [7], [8]],
                  [[1], [2], [3], [4], [5], [9], [7], [0]],
              ]
          ),
          vocab_size,
      )
      labels = tf.expand_dims(
          tf.constant(
              [
                  [[1], [2], [3], [4], [5], [6], [7], [8]],
                  [[1], [2], [3], [4], [5], [6], [7], [8]],
                  [[1], [2], [3], [4], [5], [6], [7], [0]],
              ]
          ),
          axis=-1,
      )
      expected_accuracy = np.average([4.0 / 8.0, 5.0 / 8.0, 5.0 / 7.0])
      accuracy, _ = metrics.prefix_accuracy(predictions, labels)
      with self.test_session() as session:
          accuracy_value = session.run(accuracy)
          self.assertAlmostEqual(expected_accuracy, accuracy_value)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  from tensor2tensor.utils import metrics
  import tensorflow.compat.v1
label_desc: Use image node_id 3 for calling the MetricsTest obj's underlying member method code with example usage: obj.testPrefixAccuracy() without return types