code: def testEagerShapeErrors(self):
      with context.eager_mode():
          x = array_ops.ones((2, 2, 2, 2))
          scale = array_ops.ones((3,))
          offset = array_ops.ones((2,))
          with self.assertRaisesRegex(
              errors_impl.InvalidArgumentError,
              "scale must have the same number of elements",
          ):
              nn_impl.fused_batch_norm(x, scale, offset)
  
          x = array_ops.ones((2, 2, 2, 2))
          scale = array_ops.ones((2,))
          offset = array_ops.ones((3,))
          with self.assertRaisesRegex(
              errors_impl.InvalidArgumentError,
              "offset must have the same number of elements",
          ):
              nn_impl.fused_batch_norm(x, scale, offset)
  
          x = array_ops.ones((2, 2, 2, 2))
          scale = array_ops.ones((2,))
          offset = array_ops.ones((2,))
          mean = array_ops.ones((0,))
          variance = array_ops.ones((2,))
          with self.assertRaisesRegex(
              errors_impl.InvalidArgumentError,
              "When is_training=false, mean must have the same number of elements",
          ):
              nn_impl.fused_batch_norm(
                  x,
                  scale,
                  offset,
                  mean=mean,
                  variance=variance,
                  is_training=False,
              )
  
          x = array_ops.ones((2, 2, 2, 2))
          scale = array_ops.ones((2,))
          offset = array_ops.ones((2,))
          mean = array_ops.ones((2,))
          variance = array_ops.ones((0,))
          with self.assertRaisesRegex(
              errors_impl.InvalidArgumentError,
              "When is_training=false, variance must have the same number of "
              "elements",
          ):
              nn_impl.fused_batch_norm(
                  x,
                  scale,
                  offset,
                  mean=mean,
                  variance=variance,
                  is_training=False,
              )
  
          x = array_ops.ones((2, 2, 2, 2))
          scale = array_ops.ones((2,))
          offset = array_ops.ones((2,))
          mean = array_ops.ones((0,))
          variance = array_ops.ones((2,))
          with self.assertRaisesRegex(
              errors_impl.InvalidArgumentError,
              "When exponential_avg_factor != 1, mean must have the same number of "
              "elements",
          ):
              nn_impl.fused_batch_norm(
                  x,
                  scale,
                  offset,
                  mean=mean,
                  variance=variance,
                  exponential_avg_factor=0.5,
              )
  
          x = array_ops.ones((2, 2, 2, 2))
          scale = array_ops.ones((2,))
          offset = array_ops.ones((2,))
          mean = array_ops.ones((2,))
          variance = array_ops.ones((0,))
          with self.assertRaisesRegex(
              errors_impl.InvalidArgumentError,
              "When exponential_avg_factor != 1, variance must have the same "
              "number of elements",
          ):
              nn_impl.fused_batch_norm(
                  x,
                  scale,
                  offset,
                  mean=mean,
                  variance=variance,
                  exponential_avg_factor=0.5,
              )
  
imports: import numpy
  from tensorflow.python.eager import context
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors_impl
  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_fused_batch_norm_grad
  from tensorflow.python.ops import nn_impl
  from tensorflow.python.ops import nn_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 47 for calling the BatchNormalizationTest obj's underlying member method code with example usage: obj.testEagerShapeErrors() without return types