code: def testWordErrorRateMetric(self):
      # Ensure availability of the WER metric function in the dictionary.
      assert metrics.Metrics.WORD_ERROR_RATE in metrics.METRICS_FNS
  
      # Test if WER is computed correctly.
      ref = np.asarray(
          [
              # a b c
              [97, 34, 98, 34, 99],
              [97, 34, 98, 34, 99],
              [97, 34, 98, 34, 99],
              [97, 34, 98, 34, 99],
          ]
      )
  
      hyp = np.asarray(
          [
              [97, 34, 98, 34, 99],  # a b c
              [97, 34, 98, 0, 0],  # a b
              [97, 34, 98, 34, 100],  # a b d
              [0, 0, 0, 0, 0],  # empty
          ]
      )
  
      labels = np.reshape(ref, ref.shape + (1, 1))
      predictions = np.zeros(
          (len(ref), np.max([len(s) for s in hyp]), 1, 1, 256)
      )
  
      for i, sample in enumerate(hyp):
          for j, idx in enumerate(sample):
              predictions[i, j, 0, 0, idx] = 1
  
      with self.test_session() as session:
          actual_wer, unused_actual_ref_len = session.run(
              metrics.word_error_rate(predictions, labels)
          )
  
      expected_wer = 0.417
      places = 3
      self.assertAlmostEqual(
          round(actual_wer, places), expected_wer, places
      )
  
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 11 for calling the MetricsTest obj's underlying member method code with example usage: obj.testWordErrorRateMetric() without return types