code: def _inference_ref(
      self, x, scale, offset, mean, var, epsilon, data_format
  ):
      if data_format not in ["NHWC", "NCHW", "NDHWC", "NCDHW"]:
          raise ValueError(
              "data_format must be NCHW or NHWC for 4D tensors or"
              "NCDHW or NDHWC for 5D tensors, got %s." % data_format
          )
      if data_format == "NCHW":
          x = array_ops.transpose(x, [0, 2, 3, 1])
      elif data_format == "NCDHW":
          x = array_ops.transpose(x, [0, 2, 3, 4, 1])
      y = self._batch_norm(x, mean, var, offset, scale, epsilon)
      if data_format == "NCHW":
          y = array_ops.transpose(y, [0, 3, 1, 2])
      elif data_format == "NCDHW":
          y = array_ops.transpose(y, [0, 4, 1, 2, 3])
      return self.evaluate(y)
  
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 2 for calling the BatchNormalizationTest obj's underlying member method code with example usage: obj._inference_ref(x, scale, offset, mean, var, epsilon, data_format) and returns: self