class_docstr: Test determinism-related functionality of tf.nn.depthwise_conv2d.
class_docstr_tok: ["Test","determinism-related","functionality","of","tf.nn.depthwise_conv2d","."]
code: def _testBackwardDeterminismCase(
      self,
      using_gpu=False,
      use_cudnn=False,
      data_format="NHWC",
      dtype=dtypes.float32,
  ):
      p = self._genParams(use_cudnn, data_format, dtype, seed=123)
      input_data, filter_data, strides, padding, output_shape = p
  
      def Gradients(upstream_gradients):
          with backprop.GradientTape() as tape:
              tape.watch(input_data)
              tape.watch(filter_data)
              op_output = nn_impl.depthwise_conv2d_v2(
                  input_data, filter_data, strides, padding, data_format
              )
              gradient_injector_output = op_output * upstream_gradients
          return tape.gradient(
              gradient_injector_output, [input_data, filter_data]
          )
  
      # Test only two seeds, since testing takes a long time
      for seed in (987, 988):
          upstream_gradients = random_ops.random_normal(
              output_shape, dtype=dtype, seed=seed
          )
          input_gradients_a, filter_gradients_a = Gradients(
              upstream_gradients
          )
          input_gradients_b, filter_gradients_b = Gradients(
              upstream_gradients
          )
          self.assertAllEqual(input_gradients_a, input_gradients_b)
          self.assertAllEqual(filter_gradients_a, filter_gradients_b)
  
file_path: tensorflow/tensorflow/python/kernel_tests/nn_ops/depthwise_conv_op_d9m_test.py
imports: from tensorflow.python.eager import backprop
  from tensorflow.python.framework import config
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import random_seed
  from tensorflow.python.framework import test_util
  from tensorflow.python.kernel_tests.nn_ops import depthwise_conv_op_base
  from tensorflow.python.ops import nn_impl
  from tensorflow.python.ops import random_ops
  from tensorflow.python.ops.nn_grad import _DepthwiseConv2dNativeBackpropFilterGrad
  from tensorflow.python.ops.nn_grad import _DepthwiseConv2dNativeBackpropInputGrad
  from tensorflow.python.platform import test
label_desc: Use image node_id 5 for calling the DepthwiseConv2DDeterministicTest obj's underlying member method code with example usage: obj._testBackwardDeterminismCase(using_gpu, use_cudnn, data_format, dtype) and returns: tape