class_docstr: Cross-covariance loss.
code: def backward(self, indexes, grad_outputs):
      y, z = self.get_retained_inputs()
      (gcost,) = grad_outputs
  
      y_mean = chainer.functions.mean(y, axis=0, keepdims=True)
      z_mean = chainer.functions.mean(z, axis=0, keepdims=True)
      y_centered = y - chainer.functions.broadcast_to(y_mean, y.shape)
      z_centered = z - chainer.functions.broadcast_to(z_mean, z.shape)
      gcost_div_n = gcost / gcost.dtype.type(len(y))
  
      ret = []
      if self.reduce == "half_squared_sum":
          covariance = chainer.functions.matmul(
              y_centered.T, z_centered
          )
          covariance /= len(y)
          if 0 in indexes:
              gy = chainer.functions.matmul(z_centered, covariance.T)
              gy *= chainer.functions.broadcast_to(
                  gcost_div_n, gy.shape
              )
              ret.append(gy)
          if 1 in indexes:
              gz = chainer.functions.matmul(y_centered, covariance)
              gz *= chainer.functions.broadcast_to(
                  gcost_div_n, gz.shape
              )
              ret.append(gz)
      else:
          if 0 in indexes:
              gy = chainer.functions.matmul(z_centered, gcost_div_n.T)
              ret.append(gy)
          if 1 in indexes:
              gz = chainer.functions.matmul(y_centered, gcost_div_n)
              ret.append(gz)
      return ret
  
file_path: chainer/chainer/functions/loss/cross_covariance.py
imports: import chainer
  from chainer import backend
  from chainer import function_node
  from chainer import utils
  from chainer.utils import type_check
label_desc: Use image node_id 4 for calling the CrossCovariance obj's underlying member method code with example usage: obj.backward(indexes, grad_outputs) and returns: ret