code: def backward(self, indexes, grad_outputs):
      F = chainer.functions
      x, gx_hat = self.get_retained_inputs()
      (gx,) = self.get_retained_outputs()
      (ggx,) = grad_outputs
  
      (x_hat,) = _XHat(
          self.eps, self.mean, self.inv_std, self.dummy_gamma
      ).apply((x,))
  
      ret = []
  
      if 0 in indexes:
          # -- sketch of gx2, which is grad of x through gx
          # gx = inv_std * gx_std
          # dgx = dinv_std * gx_std + inv_std * dgx_std
          #
          # -gx2l = (ggx * dinv_std * gx_std) / dx
          #       = sum(ggx * gx_std) * (dinv_std / dx)
          #       = -sum(ggx * gx_std) * inv_std^2 * x_hat / N
          #       = -inv_std * x_hat * mean(ggx * gx)
          #
          # By `gx_std = gx_hat - gx_hat_avg - x_hat * gx_hat_x_hat_avg`,
          # -gx_hat2r = (ggx * inv_std * dgx_std) / dx_hat
          #           = -inv_std * (ggx * mean(gx_hat * x_hat) +
          #                         gx_hat * mean(ggx * x_hat))
  
          gx2l_std = x_hat * F.mean(ggx * gx, axis=1, keepdims=True)
          (gx2l,) = _MulInvStd(
              self.eps, self.mean, self.inv_std, self.dummy_gamma
          ).apply((x, gx2l_std))
  
          gx_hat2r_std = ggx * F.mean(
              gx_hat * x_hat, axis=1, keepdims=True
          ) + gx_hat * F.mean(ggx * x_hat, axis=1, keepdims=True)
          (gx_hat2r,) = _MulInvStd(
              self.eps, self.mean, self.inv_std, self.dummy_gamma
          ).apply((x, gx_hat2r_std))
          (gx2r,) = _XHatGrad(
              self.eps,
              self.mean,
              self.inv_std,
              self.dummy_gamma,
              x_hat.array,
          ).apply((x, gx_hat2r))
  
          gx2 = -(gx2l + gx2r)
          ret.append(gx2)
  
      if 1 in indexes:
          (ggx_hat,) = _XHatGrad(
              self.eps,
              self.mean,
              self.inv_std,
              self.dummy_gamma,
              x_hat.array,
          ).apply((x, ggx))
          ret.append(ggx_hat)
  
      return ret
  
imports: import numpy
  import chainer
  from chainer import backend
  from chainer.backends import cuda
  from chainer import configuration
  from chainer import function_node
  from chainer.utils import type_check
label_desc: Use image node_id 4 for calling the _XHatGrad obj's underlying member method code with example usage: obj.backward(indexes, grad_outputs) and returns: ret