docstr: Test for tf.nn.moments(..., keep_dims=True / False).
  
  Make sure that parameters with shape (1, 1, 1, depth) yield the same
  result as parameters with shape (depth)
code: def testBatchNormKeepDims(self):
      """Test for tf.nn.moments(..., keep_dims=True / False).
  
      Make sure that parameters with shape (1, 1, 1, depth) yield the same
      result as parameters with shape (depth)
      """
      x_shape = (3, 5, 4, 2)
      param_shape = 2
      keep_dims_param_shape = (1, 1, 1, 2)
      x_val = np.random.random_sample(x_shape).astype(np.float32)
      m_val = np.random.random_sample(param_shape).astype(np.float32)
      v_val = np.random.random_sample(param_shape).astype(np.float32)
      beta_val = np.random.random_sample(param_shape).astype(np.float32)
      gamma_val = np.random.random_sample(param_shape).astype(
          np.float32
      )
      for use_gpu in [True, False]:
          with self.cached_session(use_gpu=use_gpu) as sess:
              x = constant_op.constant(x_val, name="x")
              m = constant_op.constant(m_val, name="m")
              v = constant_op.constant(v_val, name="v")
              beta = constant_op.constant(beta_val, name="beta")
              gamma = constant_op.constant(gamma_val, name="gamma")
              keep_dims_m = array_ops.reshape(
                  m, keep_dims_param_shape, name="keep_dims_m"
              )
              keep_dims_v = array_ops.reshape(
                  v, keep_dims_param_shape, name="keep_dims_v"
              )
              keep_dims_beta = array_ops.reshape(
                  beta, keep_dims_param_shape, name="keep_dims_beta"
              )
              keep_dims_gamma = array_ops.reshape(
                  gamma, keep_dims_param_shape, name="keep_dims_gamma"
              )
              epsilon = 0.001
              for scale_after_normalization in [True, False]:
                  for shift_after_normalization in [True, False]:
                      bn = self._tfBatchNormV2(
                          x,
                          m,
                          v,
                          beta,
                          gamma,
                          epsilon,
                          scale_after_normalization,
                          shift_after_normalization,
                      )
                      keep_dims_bn = self._tfBatchNormV2(
                          x,
                          keep_dims_m,
                          keep_dims_v,
                          keep_dims_beta,
                          keep_dims_gamma,
                          epsilon,
                          scale_after_normalization,
                          shift_after_normalization,
                      )
                      tf_batch_norm, keep_dims_tf_batch_norm = sess.run(
                          [bn, keep_dims_bn]
                      )
                      self.assertEqual(x_shape, tf_batch_norm.shape)
                      self.assertEqual(
                          x_shape, keep_dims_tf_batch_norm.shape
                      )
                      self.assertAllClose(
                          tf_batch_norm,
                          keep_dims_tf_batch_norm,
                          atol=0.000001,
                      )
  
imports: import numpy
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  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 gradient_checker
  from tensorflow.python.ops import gradients_impl
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import nn_impl
  import tensorflow.python.ops.nn_grad
  from tensorflow.python.platform import test
label_desc: Use image node_id 15 for calling the BatchNormalizationTest obj's underlying member method code with example usage: obj.testBatchNormKeepDims() without return types