code: def _testGlobalGradient(self, from_y="mean"):
      with self.cached_session():
          x_shape = [3, 5, 4, 2]
          x_val = np.random.random_sample(x_shape).astype(np.float64)
          x = constant_op.constant(x_val)
          x.set_shape(x_shape)
  
          axes = [0, 1, 2]
          y_shape = [2]  # Depth of x
  
          inputs_to_compute_gradients_for = [x]
  
          out_mean, out_var = self._unweighted_moments(
              x, axes, extra_out_grads=inputs_to_compute_gradients_for
          )
          if from_y == "mean":
              y = out_mean
          elif from_y == "var":
              y = out_var
  
          for i, v in enumerate(inputs_to_compute_gradients_for):
              err = gradient_checker.compute_gradient_error(
                  v, v.get_shape().as_list(), y, y_shape
              )
              print(
                  "Moments %s gradient err vs input %d = %g"
                  % (from_y, i, err)
              )
              self.assertLess(err, 1e-11)
  
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 7 for calling the MomentsTest obj's underlying member method code with example usage: obj._testGlobalGradient(from_y) without return types