code: def test_instance_norm_gradients(
      self,
      gc,
      dc,
      N,
      C,
      H,
      W,
      order,
      store_mean,
      store_inv_stdev,
      epsilon,
      seed,
  ):
      np.random.seed(seed)
  
      # force store_inv_stdev if store_mean to match existing forward pass
      # implementation
      store_inv_stdev |= store_mean
  
      op = self._get_op(
          device_option=gc,
          store_mean=store_mean,
          store_inv_stdev=store_inv_stdev,
          epsilon=epsilon,
          order=order,
      )
  
      input_data = np.arange(N * C * H * W).astype(np.float32)
      np.random.shuffle(input_data)
      if order == "NCHW":
          input_data = input_data.reshape(N, C, H, W)
      else:
          input_data = input_data.reshape(N, H, W, C)
      scale_data = np.random.randn(C).astype(np.float32)
      bias_data = np.random.randn(C).astype(np.float32)
      input_blobs = (input_data, scale_data, bias_data)
  
      output_indices = [0]
      # if store_inv_stdev is turned on, store_mean must also be forced on
      if store_mean or store_inv_stdev:
          output_indices += [1]
      if store_inv_stdev:
          output_indices += [2]
      self.assertDeviceChecks(dc, op, input_blobs, output_indices)
      # The gradient only flows from output #0 since the other two only
      # store the temporary mean and inv_stdev buffers.
      # Check dl/dinput
      self.assertGradientChecks(gc, op, input_blobs, 0, [0])
      # Check dl/dscale
      self.assertGradientChecks(gc, op, input_blobs, 1, [0])
      # Check dl/dbias
      self.assertGradientChecks(gc, op, input_blobs, 2, [0])
  
file_path: pytorch/caffe2/python/operator_test/instance_norm_test.py
imports: import numpy
  from hypothesis import given, assume, settings
  import hypothesis.strategies
  from caffe2.python import core, model_helper, brew, utils
  import caffe2.python.hypothesis_test_util
  import caffe2.python.serialized_test.serialized_test_util
  import unittest
label_desc: Use image node_id 4 for calling the TestInstanceNorm obj's underlying member method code with example usage: obj.test_instance_norm_gradients(gc, dc, N, C, H, W, order, store_mean, store_inv_stdev, epsilon, seed) without return types