code: def _training_ref(
      self,
      x,
      scale,
      offset,
      old_mean,
      old_var,
      exponential_avg_factor,
      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
          )
      use_4d_tensor = x.shape.ndims == 4
      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])
  
      mean_axis = [0, 1, 2] if use_4d_tensor else [0, 1, 2, 3]
      batch_mean, batch_var = nn_impl.moments(
          math_ops.cast(x, scale.dtype), mean_axis, keep_dims=False
      )
  
      y = self._batch_norm(
          x, batch_mean, batch_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])
  
      # This is for Bessel's correction. tf.nn.moments uses n, instead of n-1, as
      # the denominator in the formula to calculate variance, while
      # tf.compat.v1.nn.fused_batch_norm has Bessel's correction built in.
      sample_size = math_ops.cast(
          array_ops.size(x) / array_ops.size(scale), scale.dtype
      )
      batch_var_corrected = (
          batch_var
          * sample_size
          / (math_ops.maximum(sample_size - 1.0, 1.0))
      )
  
      mean = self._running_mean(
          old_mean, batch_mean, exponential_avg_factor
      )
      var = self._running_mean(
          old_var, batch_var_corrected, exponential_avg_factor
      )
      return self.evaluate(y), self.evaluate(mean), self.evaluate(var)
  
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 5 for calling the BatchNormalizationTest obj's underlying member method code with example usage: obj._training_ref(x, scale, offset, old_mean, old_var, exponential_avg_factor, epsilon, data_format) and returns: self,  self,  self