code: def testAccuracyMetric(self):
      predictions = np.random.randint(1, 5, size=(12, 12, 12, 1))
      targets = np.random.randint(1, 5, size=(12, 12, 12, 1))
      expected = np.mean((predictions == targets).astype(float))
      with self.test_session() as session:
          scores, _ = metrics.padded_accuracy(
              tf.one_hot(predictions, depth=5, dtype=tf.float32),
              tf.constant(targets, dtype=tf.int32),
          )
          a = tf.reduce_mean(scores)
          session.run(tf.global_variables_initializer())
          actual = session.run(a)
      self.assertAlmostEqual(actual, expected)
  
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 1 for calling the MetricsTest obj's underlying member method code with example usage: obj.testAccuracyMetric() without return types