docstr: Computes the gradient error for float16 inputs and/or outputs.
  
  This returns the same value as gradient_checker.compute_gradient_error. The
  difference is that gradient_checker.compute_gradient_error does not
  numerically compute the gradients in a numerically stable way for float16
  tensors. To fix this, this function requires float32 versions of x and y to
  numerically compute the gradients, to compare with the float16 symbolically
  computed gradients.
  
  Args:
    x: The input tensor.
    x32: A float32 version of x.
    x_shape: The shape of x.
    y: The output tensor.
    y32: A float32 version of y. Must be calculated based on x32, not x.
    y_shape: The shape of y.
    x_dtype: The type of x, float16 or bfloat16.
  
  Returns:
    The maximum error in between the two Jacobians, as in
    gradient_checker.compute_gradient_error.
docstr_tok: ["Computes","the","gradient","error","for","float16","inputs","and\/or","outputs",".","This","returns","the","same","value","as","gradient_checker.compute_gradient_error",".","The","difference","is","that","gradient_checker.compute_gradient_error","does","not","numerically","compute","the","gradients","in","a","numerically","stable","way","for","float16","tensors",".","To","fix","this",",","this","function","requires","float32","versions","of","x","and","y","to","numerically","compute","the","gradients",",","to","compare","with","the","float16","symbolically","computed","gradients",".","Args",":","x",":","The","input","tensor",".","x32",":","A","float32","version","of","x.","x_shape",":","The","shape","of","x.","y",":","The","output","tensor",".","y32",":","A","float32","version","of","y",".","Must","be","calculated","based","on","x32",",","not","x.","y_shape",":","The","shape","of","y.","x_dtype",":","The","type","of","x",",","float16","or","bfloat16",".","Returns",":","The","maximum","error","in","between","the","two","Jacobians",",","as","in","gradient_checker.compute_gradient_error","."]
code: def _compute_gradient_error_float16(
      self, x, x32, x_shape, y, y32, y_shape, x_dtype
  ):
      """Computes the gradient error for float16 inputs and/or outputs.
  
      This returns the same value as gradient_checker.compute_gradient_error. The
      difference is that gradient_checker.compute_gradient_error does not
      numerically compute the gradients in a numerically stable way for float16
      tensors. To fix this, this function requires float32 versions of x and y to
      numerically compute the gradients, to compare with the float16 symbolically
      computed gradients.
  
      Args:
        x: The input tensor.
        x32: A float32 version of x.
        x_shape: The shape of x.
        y: The output tensor.
        y32: A float32 version of y. Must be calculated based on x32, not x.
        y_shape: The shape of y.
        x_dtype: The type of x, float16 or bfloat16.
  
      Returns:
        The maximum error in between the two Jacobians, as in
        gradient_checker.compute_gradient_error.
      """
      x_init_val = np.random.random_sample(x_shape).astype(x_dtype)
      x32_init_val = x_init_val.astype(np.float32)
  
      # TODO(reedwm): Do not perform the unnecessary computations in
      # compute_gradient, since they double the computation time of this function.
      theoretical_grad, _ = gradient_checker.compute_gradient(
          x, x_shape, y, y_shape, delta=1e-3, x_init_value=x_init_val
      )
      _, numerical_grad = gradient_checker.compute_gradient(
          x32,
          x_shape,
          y32,
          y_shape,
          delta=1e-3,
          x_init_value=x32_init_val,
      )
  
      # If grad is empty, no error.
      if theoretical_grad.size == 0 and numerical_grad.size == 0:
          return 0
      return np.fabs(theoretical_grad - numerical_grad).max()
  
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 7 for calling the BatchNormalizationTest obj's underlying member method code with example usage: obj._compute_gradient_error_float16(x, x32, x_shape, y, y32, y_shape, x_dtype) and returns: np, int