class_docstr: Kernels in GPyTorch are implemented as a :class:`gpytorch.Module` that, when called on two :class:`torch.Tensor`
  objects :math:`\mathbf x_1` and :math:`\mathbf x_2` returns either a :obj:`torch.Tensor` or a
  :obj:`~linear_operator.operators.LinearOperator` that represents the
  covariance matrix between :math:`\mathbf x_1` and :math:`\mathbf x_2`.
  
  In the typical use case, extend this class simply requires implementing a
  :py:meth:`~gpytorch.kernels.Kernel.forward` method.
  
  .. note::
      The :py:meth:`~gpytorch.kernels.Kernel.__call__` method does some additional internal work. In particular,
      all kernels are lazily evaluated so that we can index in to the kernel matrix before actually
      computing it. Furthermore, many built-in kernel modules return
      :class:`~linear_operator.LinearOperators` that allow for more efficient
      inference than if we explicitly computed the kernel matrix itself.
  
      As a result, if you want to get an actual
      :obj:`torch.tensor` representing the covariance matrix, you may need to call the
      :func:`~linear_operator.operators.LinearOperator.to_dense` method on the output.
  
  This base :class:`Kernel` class includes a lengthscale parameter
  :math:`\Theta`, which is used by many common kernel functions.
  There are a few options for the lengthscale:
  
  * Default: No lengthscale (i.e. :math:`\Theta` is the identity matrix).
  
  * Single lengthscale: One lengthscale can be applied to all input dimensions/batches
    (i.e. :math:`\Theta` is a constant diagonal matrix).
    This is controlled by setting the attribute `has_lengthscale=True`.
  
  * ARD: Each input dimension gets its own separate lengthscale
    (i.e. :math:`\Theta` is a non-constant diagonal matrix).
    This is controlled by the `ard_num_dims` keyword argument (as well as `has_lengthscale=True`).
  
  In batch mode (i.e. when :math:`\mathbf x_1` and :math:`\mathbf x_2` are batches of input matrices), each
  batch of data can have its own lengthscale parameter by setting the `batch_shape`
  keyword argument to the appropriate number of batches.
  
  .. note::
  
      You can set a prior on the lengthscale parameter using the lengthscale_prior argument.
  
  :param ard_num_dims: Set this if you want a separate lengthscale for each input
      dimension. It should be `D` if :math:`\mathbf x` is a `... x N x D` matrix. (Default: `None`.)
  :param batch_shape: Set this if you want a separate lengthscale for each batch of input
      data. It should be :math:`B_1 \times \ldots \times B_k` if :math:`\mathbf x_1` is
      a :math:`B_1 \times \ldots \times B_k \times N \times D` tensor.
  :param active_dims: Set this if you want to compute the covariance of only
      a few input dimensions. The ints corresponds to the indices of the
      dimensions. (Default: `None`.)
  :param lengthscale_prior: Set this if you want to apply a prior to the
      lengthscale parameter. (Default: `None`.)
  :param lengthscale_constraint: Set this if you want to apply a constraint
      to the lengthscale parameter. (Default: :class:`~gpytorch.constraints.Positive`.)
  :param eps: A small positive value added to the lengthscale to prevent
      divide by zero errors. (Default: `1e-6`.)
  
  :ivar torch.Size batch_shape:
      The (minimum) number of batch dimensions supported by this kernel.
      Typically, this captures the batch shape of the lengthscale and other parameters,
      and is usually set by the `batch_shape` argument in the constructor.
  :ivar torch.dtype dtype:
      The dtype supported by this kernel.
      Typically, this depends on the dtype of the lengthscale and other parameters.
  :ivar bool is_stationary:
      Set to True if the Kernel represents a stationary function
      (one that depends only on :math:`\mathbf x_1 - \mathbf x_2`).
  :ivar torch.Tensor lengthscale:
      The lengthscale parameter. Size/shape of parameter depends on the
      `ard_num_dims` and `batch_shape` arguments.
  
  Example:
      >>> covar_module = gpytorch.kernels.LinearKernel()
      >>> x1 = torch.randn(50, 3)
      >>> lazy_covar_matrix = covar_module(x1) # Returns a RootLinearOperator
      >>> tensor_covar_matrix = lazy_covar_matrix.to_dense() # Gets the actual tensor for this kernel matrix
class_docstr_tok: ["Kernels","in","GPyTorch","are","implemented","as","a",":","class",":","`","gpytorch.Module","`","that",",","when","called","on","two",":","class",":","`","torch.Tensor","`","objects",":","math",":","`","\\mathbf","x_1","`","and",":","math",":","`","\\mathbf","x_2","`","returns","either","a",":","obj",":","`","torch.Tensor","`","or","a",":","obj",":","`","~linear_operator.operators.LinearOperator","`","that","represents","the","covariance","matrix","between",":","math",":","`","\\mathbf","x_1","`","and",":","math",":","`","\\mathbf","x_2","`",".","In","the","typical","use","case",",","extend","this","class","simply","requires","implementing","a",":","py",":","meth",":","`","~gpytorch.kernels.Kernel.forward","`","method",".","..","note",":",":","The",":","py",":","meth",":","`","~gpytorch.kernels.Kernel.__call__","`","method","does","some","additional","internal","work",".","In","particular",",","all","kernels","are","lazily","evaluated","so","that","we","can","index","in","to","the","kernel","matrix","before","actually","computing","it",".","Furthermore",",","many","built-in","kernel","modules","return",":","class",":","`","~linear_operator.LinearOperators","`","that","allow","for","more","efficient","inference","than","if","we","explicitly","computed","the","kernel","matrix","itself",".","As","a","result",",","if","you","want","to","get","an","actual",":","obj",":","`","torch.tensor","`","representing","the","covariance","matrix",",","you","may","need","to","call","the",":","func",":","`","~linear_operator.operators.LinearOperator.to_dense","`","method","on","the","output",".","This","base",":","class",":","`","Kernel","`","class","includes","a","lengthscale","parameter",":","math",":","`","\\Theta","`",",","which","is","used","by","many","common","kernel","functions",".","There","are","a","few","options","for","the","lengthscale",":","*","Default",":","No","lengthscale","(","i.e",".",":","math",":","`","\\Theta","`","is","the","identity","matrix",")",".","*","Single","lengthscale",":","One","lengthscale","can","be","applied","to","all","input","dimensions\/batches","(","i.e",".",":","math",":","`","\\Theta","`","is","a","constant","diagonal","matrix",")",".","This","is","controlled","by","setting","the","attribute","`","has_lengthscale=True","`",".","*","ARD",":","Each","input","dimension","gets","its","own","separate","lengthscale","(","i.e",".",":","math",":","`","\\Theta","`","is","a","non-constant","diagonal","matrix",")",".","This","is","controlled","by","the","`","ard_num_dims","`","keyword","argument","(","as","well","as","`","has_lengthscale=True","`",")",".","In","batch","mode","(","i.e",".","when",":","math",":","`","\\mathbf","x_1","`","and",":","math",":","`","\\mathbf","x_2","`","are","batches","of","input","matrices",")",",","each","batch","of","data","can","have","its","own","lengthscale","parameter","by","setting","the","`","batch_shape","`","keyword","argument","to","the","appropriate","number","of","batches",".","..","note",":",":","You","can","set","a","prior","on","the","lengthscale","parameter","using","the","lengthscale_prior","argument",".",":","param","ard_num_dims",":","Set","this","if","you","want","a","separate","lengthscale","for","each","input","dimension",".","It","should","be","`","D","`","if",":","math",":","`","\\mathbf","x","`","is","a","`","...","x","N","x","D","`","matrix",".","(","Default",":","`","None","`",".",")",":","param","batch_shape",":","Set","this","if","you","want","a","separate","lengthscale","for","each","batch","of","input","data",".","It","should","be",":","math",":","`","B_1","\\times","\\ldots","\\times","B_k","`","if",":","math",":","`","\\mathbf","x_1","`","is","a",":","math",":","`","B_1","\\times","\\ldots","\\times","B_k","\\times","N","\\times","D","`","tensor",".",":","param","active_dims",":","Set","this","if","you","want","to","compute","the","covariance","of","only","a","few","input","dimensions",".","The","ints","corresponds","to","the","indices","of","the","dimensions",".","(","Default",":","`","None","`",".",")",":","param","lengthscale_prior",":","Set","this","if","you","want","to","apply","a","prior","to","the","lengthscale","parameter",".","(","Default",":","`","None","`",".",")",":","param","lengthscale_constraint",":","Set","this","if","you","want","to","apply","a","constraint","to","the","lengthscale","parameter",".","(","Default",":",":","class",":","`","~gpytorch.constraints.Positive","`",".",")",":","param","eps",":","A","small","positive","value","added","to","the","lengthscale","to","prevent","divide","by","zero","errors",".","(","Default",":","`","1e-6","`",".",")",":","ivar","torch.Size","batch_shape",":","The","(","minimum",")","number","of","batch","dimensions","supported","by","this","kernel",".","Typically",",","this","captures","the","batch","shape","of","the","lengthscale","and","other","parameters",",","and","is","usually","set","by","the","`","batch_shape","`","argument","in","the","constructor",".",":","ivar","torch.dtype","dtype",":","The","dtype","supported","by","this","kernel",".","Typically",",","this","depends","on","the","dtype","of","the","lengthscale","and","other","parameters",".",":","ivar","bool","is_stationary",":","Set","to","True","if","the","Kernel","represents","a","stationary","function","(","one","that","depends","only","on",":","math",":","`","\\mathbf","x_1","-","\\mathbf","x_2","`",")",".",":","ivar","torch.Tensor","lengthscale",":","The","lengthscale","parameter",".","Size\/shape","of","parameter","depends","on","the","`","ard_num_dims","`","and","`","batch_shape","`","arguments",".","Example",":",">",">",">","covar_module","=","gpytorch.kernels.LinearKernel","(",")",">",">",">","x1","=","torch.randn","(","50",",","3",")",">",">",">","lazy_covar_matrix","=","covar_module","(","x1",")","#","Returns","a","RootLinearOperator",">",">",">","tensor_covar_matrix","=","lazy_covar_matrix.to_dense","(",")","#","Gets","the","actual","tensor","for","this","kernel","matrix"]
code: def batch_shape(self) -> torch.Size:
      kernels = list(self.sub_kernels())
      if len(kernels):
          return torch.broadcast_shapes(
              self._batch_shape, *[k.batch_shape for k in kernels]
          )
      else:
          return self._batch_shape
  
imports: from __future__ import annotations
  import warnings
  from abc import abstractmethod
  from copy import deepcopy
  from typing import Callable, Dict, Iterable, Optional, Tuple, Union
  import torch
  from linear_operator import to_dense, to_linear_operator
  from linear_operator.operators import LinearOperator, ZeroLinearOperator
  from torch import Tensor
  from torch.nn import ModuleList
  from ..None import settings
  from ..constraints import Interval, Positive
  from ..distributions import MultivariateNormal
  from ..lazy import LazyEvaluatedKernelTensor
  from ..likelihoods import GaussianLikelihood
  from ..models import exact_prediction_strategies
  from ..module import Module
  from ..priors import Prior
label_desc: Use image node_id 6 for calling the Kernel obj's underlying member method code with example usage: obj.batch_shape() and returns: torch, self