code: def test_metrics_classification(self):
      with self.test_session():
          x = Bernoulli(probs=0.51)
          x_data = tf.constant(1)
          self.assertAllClose(
              1.0,
              ed.evaluate("binary_accuracy", {x: x_data}, n_samples=1),
          )
          x = Bernoulli(probs=0.51, sample_shape=5)
          x_data = tf.constant([1, 1, 1, 0, 0])
          self.assertAllClose(
              0.6,
              ed.evaluate("binary_accuracy", {x: x_data}, n_samples=1),
          )
          x = Bernoulli(probs=tf.constant([0.51, 0.49, 0.49]))
          x_data = tf.constant([1, 0, 1])
          self.assertAllClose(
              2.0 / 3,
              ed.evaluate("binary_accuracy", {x: x_data}, n_samples=1),
          )
  
          x = Categorical(probs=tf.constant([0.48, 0.51, 0.01]))
          x_data = tf.constant(1)
          self.assertAllClose(
              1.0,
              ed.evaluate(
                  "sparse_categorical_accuracy",
                  {x: x_data},
                  n_samples=1,
              ),
          )
          x = Categorical(
              probs=tf.constant([0.48, 0.51, 0.01]), sample_shape=5
          )
          x_data = tf.constant([1, 1, 1, 0, 2])
          self.assertAllClose(
              0.6,
              ed.evaluate(
                  "sparse_categorical_accuracy",
                  {x: x_data},
                  n_samples=1,
              ),
          )
          x = Categorical(
              probs=tf.constant(
                  [[0.48, 0.51, 0.01], [0.51, 0.48, 0.01]]
              )
          )
          x_data = tf.constant([1, 2])
          self.assertAllClose(
              0.5,
              ed.evaluate(
                  "sparse_categorical_accuracy",
                  {x: x_data},
                  n_samples=1,
              ),
          )
  
          x = Multinomial(
              total_count=1.0, probs=tf.constant([0.48, 0.51, 0.01])
          )
          x_data = tf.constant([0, 1, 0], dtype=x.dtype.as_numpy_dtype)
          self.assertAllClose(
              1.0,
              ed.evaluate(
                  "categorical_accuracy", {x: x_data}, n_samples=1
              ),
          )
          x = Multinomial(
              total_count=1.0,
              probs=tf.constant([0.48, 0.51, 0.01]),
              sample_shape=5,
          )
          x_data = tf.constant(
              [[0, 1, 0], [0, 1, 0], [0, 1, 0], [1, 0, 0], [0, 0, 1]],
              dtype=x.dtype.as_numpy_dtype,
          )
          self.assertAllClose(
              0.6,
              ed.evaluate(
                  "categorical_accuracy", {x: x_data}, n_samples=1
              ),
          )
  
          x = Multinomial(
              total_count=5.0, probs=tf.constant([0.4, 0.6, 0.0])
          )
          x_data = tf.constant([2, 3, 0], dtype=x.dtype.as_numpy_dtype)
          self.assertAllClose(
              1.0,
              ed.evaluate(
                  "multinomial_accuracy", {x: x_data}, n_samples=1
              ),
          )
  
file_path: edward/tests/criticisms/evaluate_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import edward
  import numpy
  import tensorflow
  from edward.models import Bernoulli, Categorical, Multinomial, Normal
label_desc: Use image node_id 2 for calling the test_evaluate_class obj's underlying member method code with example usage: obj.test_metrics_classification() without return types