class_docstr: Benchmark batch normalization.
code: def benchmark_batch_norm(self):
      print("Forward convolution (lower layers).")
      shape = [8, 128, 128, 32]
      axes = [0, 1, 2]
      t1 = self._run_graph("cpu", shape, axes, 10, "op", True, False, 5)
      t2 = self._run_graph("cpu", shape, axes, 10, "py", True, False, 5)
      t3 = self._run_graph(
          "cpu", shape, axes, 10, "slow", True, False, 5
      )
      print_difference("op vs py", t1, t2)
      print_difference("py vs slow", t2, t3)
      if FLAGS.use_gpu:
          t1 = self._run_graph(
              "gpu", shape, axes, 10, "op", True, False, 50
          )
          t2 = self._run_graph(
              "gpu", shape, axes, 10, "py", True, False, 50
          )
          t3 = self._run_graph(
              "gpu", shape, axes, 10, "slow", True, False, 50
          )
          print_difference("op vs py", t1, t2)
          print_difference("py vs slow", t2, t3)
      print("Forward/backward convolution (lower layers).")
      t1 = self._run_graph("cpu", shape, axes, 10, "op", True, True, 5)
      t2 = self._run_graph("cpu", shape, axes, 10, "py", True, True, 5)
      t3 = self._run_graph(
          "cpu", shape, axes, 10, "slow", True, True, 5
      )
      print_difference("op vs py", t1, t2)
      print_difference("py vs slow", t2, t3)
      if FLAGS.use_gpu:
          t1 = self._run_graph(
              "gpu", shape, axes, 10, "op", True, True, 50
          )
          t2 = self._run_graph(
              "gpu", shape, axes, 10, "py", True, True, 50
          )
          t3 = self._run_graph(
              "gpu", shape, axes, 10, "slow", True, True, 50
          )
          print_difference("op vs py", t1, t2)
          print_difference("py vs slow", t2, t3)
      print("Forward convolution (higher layers).")
      shape = [256, 17, 17, 32]
      axes = [0, 1, 2]
      t1 = self._run_graph("cpu", shape, axes, 10, "op", True, False, 5)
      t2 = self._run_graph("cpu", shape, axes, 10, "py", True, False, 5)
      t3 = self._run_graph(
          "cpu", shape, axes, 10, "slow", True, False, 5
      )
      print_difference("op vs py", t1, t2)
      print_difference("py vs slow", t2, t3)
      if FLAGS.use_gpu:
          t1 = self._run_graph(
              "gpu", shape, axes, 10, "op", True, False, 50
          )
          t2 = self._run_graph(
              "gpu", shape, axes, 10, "py", True, False, 50
          )
          t3 = self._run_graph(
              "gpu", shape, axes, 10, "slow", True, False, 50
          )
          print_difference("op vs py", t1, t2)
          print_difference("py vs slow", t2, t3)
      print("Forward/backward convolution (higher layers).")
      t1 = self._run_graph("cpu", shape, axes, 10, "op", True, True, 5)
      t2 = self._run_graph("cpu", shape, axes, 10, "py", True, True, 5)
      t3 = self._run_graph(
          "cpu", shape, axes, 10, "slow", True, True, 5
      )
      print_difference("op vs py", t1, t2)
      print_difference("py vs slow", t2, t3)
      if FLAGS.use_gpu:
          t1 = self._run_graph(
              "gpu", shape, axes, 10, "op", True, True, 50
          )
          t2 = self._run_graph(
              "gpu", shape, axes, 10, "py", True, True, 50
          )
          t3 = self._run_graph(
              "gpu", shape, axes, 10, "slow", True, True, 50
          )
          print_difference("op vs py", t1, t2)
          print_difference("py vs slow", t2, t3)
      print("Forward fully-connected.")
      shape = [1024, 32]
      axes = [0]
      t1 = self._run_graph("cpu", shape, axes, 10, "py", True, False, 5)
      t2 = self._run_graph(
          "cpu", shape, axes, 10, "slow", True, False, 5
      )
      print_difference("py vs slow", t1, t2)
      if FLAGS.use_gpu:
          t1 = self._run_graph(
              "gpu", shape, axes, 10, "py", True, False, 50
          )
          t2 = self._run_graph(
              "gpu", shape, axes, 10, "slow", True, False, 50
          )
          print_difference("py vs slow", t1, t2)
      print("Forward/backward fully-connected.")
      t1 = self._run_graph("cpu", shape, axes, 10, "py", True, True, 50)
      t2 = self._run_graph(
          "cpu", shape, axes, 10, "slow", True, True, 50
      )
      print_difference("py vs slow", t1, t2)
      if FLAGS.use_gpu:
          t1 = self._run_graph(
              "gpu", shape, axes, 10, "py", True, True, 5
          )
          t2 = self._run_graph(
              "gpu", shape, axes, 10, "slow", True, True, 5
          )
          print_difference("py vs slow", t1, t2)
  
imports: import argparse
  import sys
  import time
  from tensorflow.python.client import session
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gen_nn_ops
  from tensorflow.python.ops import gradients_impl
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import nn_impl
  from tensorflow.python.ops import random_ops
  from tensorflow.python.ops import variables
  import tensorflow.python.ops.nn_grad
  from tensorflow.python.platform import test
label_desc: Use image node_id 2 for calling the BatchNormBenchmark obj's underlying member method code with example usage: obj.benchmark_batch_norm() without return types