class_docstr: A kernel for the linear model of coregionalization
  :math:`k(x,z) = x^T (W W^T + D) z` where :math:`W` is an
  ``input_dim``-by-``rank`` matrix and typically ``rank < input_dim``,
  and ``D`` is a diagonal matrix.
  
  This generalizes the
  :class:`~pyro.contrib.gp.kernels.dot_product.Linear` kernel to multiple
  features with a low-rank-plus-diagonal weight matrix. The typical use case
  is for modeling correlations among outputs of a multi-output GP, where
  outputs are coded as distinct data points with one-hot coded features
  denoting which output each datapoint represents.
  
  If only ``rank`` is specified, the kernel ``(W W^T + D)`` will be
  randomly initialized to a matrix with expected value the identity matrix.
  
  References:
  
  [1] Mauricio A. Alvarez, Lorenzo Rosasco, Neil D. Lawrence (2012)
      Kernels for Vector-Valued Functions: a Review
  
  :param int input_dim: Number of feature dimensions of inputs.
  :param int rank: Optional rank. This is only used if ``components`` is
      unspecified. If neigher ``rank`` nor ``components`` is specified,
      then ``rank`` defaults to ``input_dim``.
  :param torch.Tensor components: An optional ``(input_dim, rank)`` shaped
      matrix that maps features to ``rank``-many components. If unspecified,
      this will be randomly initialized.
  :param torch.Tensor diagonal: An optional vector of length ``input_dim``.
      If unspecified, this will be set to constant ``0.5``.
  :param list active_dims: List of feature dimensions of the input which the
      kernel acts on.
  :param str name: Name of the kernel.
code: def forward(self, X, Z=None, diag=False):
      X = self._slice_input(X)
      Xc = X.matmul(self.components)
  
      if diag:
          return (Xc**2).sum(-1) + (X**2).mv(self.diagonal)
  
      if Z is None:
          Z = X
          Zc = Xc
      else:
          Z = self._slice_input(Z)
          Zc = Z.matmul(self.components)
  
      return Xc.matmul(Zc.t()) + (X * self.diagonal).matmul(Z.t())
  
file_path: pyro/pyro/contrib/gp/kernels/coregionalize.py
imports: import torch
  from torch.distributions import constraints
  from torch.nn import Parameter
  from pyro.contrib.gp.kernels.kernel import Kernel
  from pyro.nn.module import PyroParam
label_desc: Use image node_id 2 for calling the Coregionalize obj's underlying member method code with example usage: obj.forward(X, Z, diag) and returns: unknown, unknown