class_docstr: A kernel for discrete indices. Kernel is defined by a lookup table.
  
  .. math::
  
      \begin{equation}
          k(i, j) = \left(BB^\top + \text{diag}(\mathbf v) \right)_{i, j}
      \end{equation}
  
  where :math:`B` is a low-rank matrix, and :math:`\mathbf v` is a  non-negative vector.
  These parameters are learned.
  
  Args:
      num_tasks (int):
          Total number of indices.
      batch_shape (torch.Size, optional):
          Set if the MultitaskKernel is operating on batches of data (and you want different
          parameters for each batch)
      rank (int):
          Rank of :math:`B` matrix. Controls the degree of
          correlation between the outputs. With a rank of 1 the
          outputs are identical except for a scaling factor.
      prior (:obj:`gpytorch.priors.Prior`):
          Prior for :math:`B` matrix.
      var_constraint (Constraint, optional):
          Constraint for added diagonal component. Default: `Positive`.
  
  Attributes:
      covar_factor:
          The :math:`B` matrix.
      raw_var:
          The element-wise log of the :math:`\mathbf v` vector.
code: def __init__(
      self,
      num_tasks: int,
      rank: Optional[int] = 1,
      prior: Optional[Prior] = None,
      var_constraint: Optional[Interval] = None,
      **kwargs,
  ):
      if rank > num_tasks:
          raise RuntimeError(
              "Cannot create a task covariance matrix larger than the number of tasks"
          )
      super().__init__(**kwargs)
  
      if var_constraint is None:
          var_constraint = Positive()
  
      self.register_parameter(
          name="covar_factor",
          parameter=torch.nn.Parameter(
              torch.randn(*self.batch_shape, num_tasks, rank)
          ),
      )
      self.register_parameter(
          name="raw_var",
          parameter=torch.nn.Parameter(
              torch.randn(*self.batch_shape, num_tasks)
          ),
      )
      if prior is not None:
          if not isinstance(prior, Prior):
              raise TypeError(
                  "Expected gpytorch.priors.Prior but got "
                  + type(prior).__name__
              )
          self.register_prior(
              "IndexKernelPrior",
              prior,
              lambda m: m._eval_covar_matrix(),
          )
  
      self.register_constraint("raw_var", var_constraint)
  
file_path: gpytorch/gpytorch/kernels/index_kernel.py
imports: from typing import Optional
  import torch
  from linear_operator.operators import DiagLinearOperator, InterpolatedLinearOperator, PsdSumLinearOperator, RootLinearOperator
  from ..constraints import Interval, Positive
  from ..priors import Prior
  from .kernel import Kernel
label_desc: Use image node_id 1 to create a new IndexKernel object from inherited base classes: Kernel with example: obj = IndexKernel(num_tasks, rank, prior, var_constraint)