code: def _check_averaging(self, metric, y_true, y_pred):
      n_classes = tf.squeeze(tf.shape(y_true)[-1]).eval()
      class_scores = [
          metric(y_true[i], y_pred[i]) for i in range(n_classes)
      ]
  
      # No averaging
      no_average = metric(y_true, y_pred, average=None)
      expected_no_average = tf.stack(class_scores)
      self.assertAllEqual(no_average.eval(), expected_no_average.eval())
  
      # Macro-averaging
      macro_average = metric(y_true, y_pred, average="macro")
      expected_macro_average = tf.reduce_mean(tf.stack(class_scores))
      self.assertAllEqual(
          macro_average.eval(), expected_macro_average.eval()
      )
  
      # Micro-averaging
      micro_average = metric(y_true, y_pred, average="micro")
      expected_micro_average = metric(
          tf.reshape(y_true, [1, -1]), tf.reshape(y_pred, [1, -1])
      )
      self.assertAllEqual(
          micro_average.eval(), expected_micro_average.eval()
      )
  
file_path: edward/tests/criticisms/metrics_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import tensorflow
  from edward.criticisms.evaluate import *
label_desc: Use image node_id 1 for calling the test_metrics_class obj's underlying member method code with example usage: obj._check_averaging(metric, y_true, y_pred) without return types