class_docstr: Orthogonal Additive Kernels (OAKs) were introduced in [Lu2022additive]_, though
  only for the case of Gaussian base kernels with a Gaussian input data distribution.
  
  The implementation here generalizes OAKs to arbitrary base kernels by using a
  Gauss-Legendre quadrature approximation to the required one-dimensional integrals
  involving the base kernels.
  
  .. [Lu2022additive]
      X. Lu, A. Boukouvalas, and J. Hensman. Additive Gaussian processes revisited.
      Proceedings of the 39th International Conference on Machine Learning. Jul 2022.
class_docstr_tok: ["Orthogonal","Additive","Kernels","(","OAKs",")","were","introduced","in","[","Lu2022additive","]","_",",","though","only","for","the","case","of","Gaussian","base","kernels","with","a","Gaussian","input","data","distribution",".","The","implementation","here","generalizes","OAKs","to","arbitrary","base","kernels","by","using","a","Gauss-Legendre","quadrature","approximation","to","the","required","one-dimensional","integrals","involving","the","base","kernels",".","..","[","Lu2022additive","]","X.","Lu",",","A.","Boukouvalas",",","and","J.","Hensman",".","Additive","Gaussian","processes","revisited",".","Proceedings","of","the","39th","International","Conference","on","Machine","Learning",".","Jul","2022","."]
docstr: Computes the kernel matrix k(x1, x2).
  
  Args:
      x1: `batch_shape x n1 x d`-dim Tensor in [0, 1]^dim.
      x2: `batch_shape x n2 x d`-dim Tensor in [0, 1]^dim.
      diag: If True, only returns the diagonal of the kernel matrix.
      last_dim_is_batch: Not supported by this kernel.
  
  Returns:
      A `batch_shape x n1 x n2`-dim Tensor of kernel matrices.
docstr_tok: ["Computes","the","kernel","matrix","k","(","x1",",","x2",")",".","Args",":","x1",":","`","batch_shape","x","n1","x","d","`","-dim","Tensor","in","[","0",",","1","]","^dim",".","x2",":","`","batch_shape","x","n2","x","d","`","-dim","Tensor","in","[","0",",","1","]","^dim",".","diag",":","If","True",",","only","returns","the","diagonal","of","the","kernel","matrix",".","last_dim_is_batch",":","Not","supported","by","this","kernel",".","Returns",":","A","`","batch_shape","x","n1","x","n2","`","-dim","Tensor","of","kernel","matrices","."]
code: def forward(
      self,
      x1: Tensor,
      x2: Tensor,
      diag: bool = False,
      last_dim_is_batch: bool = False,
  ) -> Tensor:
      """Computes the kernel matrix k(x1, x2).
  
      Args:
          x1: `batch_shape x n1 x d`-dim Tensor in [0, 1]^dim.
          x2: `batch_shape x n2 x d`-dim Tensor in [0, 1]^dim.
          diag: If True, only returns the diagonal of the kernel matrix.
          last_dim_is_batch: Not supported by this kernel.
  
      Returns:
          A `batch_shape x n1 x n2`-dim Tensor of kernel matrices.
      """
      if last_dim_is_batch:
          raise UnsupportedError(
              "OrthogonalAdditiveKernel does not support `last_dim_is_batch`."
          )
      K_ortho = self._orthogonal_base_kernels(
          x1, x2
      )  # batch_shape x d x n1 x n2
  
      # contracting over d, leading to `batch_shape x n x n`-dim tensor, i.e.:
      #   K1 = torch.sum(self.coeffs_1[..., None, None] * K_ortho, dim=-3)
      K1 = torch.einsum(
          self.coeffs_1, [..., 0], K_ortho, [..., 0, 1, 2], [..., 1, 2]
      )
      # adding the non-batch dimensions to offset
      K = K1 + self.offset[..., None, None]
      if self.coeffs_2 is not None:
          # Computing the tensor of second order interactions K2.
          # NOTE: K2 here is equivalent to:
          #   K2 = K_ortho.unsqueeze(-4) * K_ortho.unsqueeze(-3)  # d x d x n x n
          #   K2 = (self.coeffs_2[..., None, None] * K2).sum(dim=(-4, -3))
          # but avoids forming the `batch_shape x d x d x n x n`-dim tensor in memory.
          # Reducing over the dimensions with the O(d^2) quadratic terms:
          K2 = torch.einsum(
              K_ortho,
              [..., 0, 2, 3],
              K_ortho,
              [..., 1, 2, 3],
              self.coeffs_2,
              [..., 0, 1],
              [
                  ...,
                  2,
                  3,
              ],  # i.e. contracting over the first two non-batch dims
          )
          K = K + K2
  
      return K if not diag else K.diag()
  
imports: import math
  from typing import List, Optional, Tuple
  import numpy
  import torch
  from botorch.exceptions.errors import UnsupportedError
  from gpytorch.constraints import Interval, Positive
  from gpytorch.kernels import Kernel
  from torch import nn, Tensor
label_desc: Use image node_id 6 for calling the OrthogonalAdditiveKernel obj's underlying member method code with example usage: obj.forward(x1, x2, diag, last_dim_is_batch) and returns: unknown