class_docstr: Gradient-checking for ExtractImagePatches op.
class_docstr_tok: ["Gradient-checking","for","ExtractImagePatches","op","."]
docstr: Use test_shape_pattern to infer which dimensions are of
  
  variable size.
docstr_tok: ["Use","test_shape_pattern","to","infer","which","dimensions","are","of","variable","size","."]
code: def _VariableShapeGradient(self, test_shape_pattern):
      """Use test_shape_pattern to infer which dimensions are of
  
      variable size.
      """
      # Testing shape gradient requires graph mode.
      with ops.Graph().as_default():
          # Set graph seed for determinism.
          random_seed = 42
          random_seed_lib.set_random_seed(random_seed)
  
          with self.test_session():
              for test_case in self._TEST_CASES:
                  np.random.seed(random_seed)
                  in_shape = test_case["in_shape"]
                  test_shape = [
                      x if x is None else y
                      for x, y in zip(test_shape_pattern, in_shape)
                  ]
                  in_val = array_ops.placeholder(
                      shape=test_shape, dtype=dtypes.float32
                  )
  
                  feed_dict = {in_val: np.random.random(in_shape)}
                  for padding in ["VALID", "SAME"]:
                      out_val = array_ops.extract_image_patches(
                          in_val,
                          test_case["ksizes"],
                          test_case["strides"],
                          test_case["rates"],
                          padding,
                      )
                      out_val_tmp = out_val.eval(feed_dict=feed_dict)
                      out_shape = out_val_tmp.shape
  
                      err = gradient_checker.compute_gradient_error(
                          in_val, in_shape, out_val, out_shape
                      )
                      self.assertLess(err, 1e-4)
  
imports: from absl.testing import parameterized
  import numpy
  from tensorflow.python.eager import context
  from tensorflow.python.eager.polymorphic_function import polymorphic_function
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import random_seed
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gradient_checker
  from tensorflow.python.ops import gradient_checker_v2
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
label_desc: Use image node_id 3 for calling the ExtractImagePatchesGradTest obj's underlying member method code with example usage: obj._VariableShapeGradient(test_shape_pattern) without return types