code: def test_ard(self):
      a = torch.tensor([[1, 2], [2, 4]], dtype=torch.float)
      b = torch.tensor([[1, 3], [0, 4]], dtype=torch.float)
      lengthscales = torch.tensor([1, 2], dtype=torch.float).view(1, 2)
  
      kernel = RQKernel(ard_num_dims=2)
      kernel.initialize(lengthscale=lengthscales)
      kernel.initialize(alpha=3.0)
      kernel.eval()
  
      scaled_a = a.div(lengthscales)
      scaled_b = b.div(lengthscales)
      dist = (
          (scaled_a.unsqueeze(-2) - scaled_b.unsqueeze(-3))
          .pow(2)
          .sum(dim=-1)
      )
      actual = dist.div_(2 * kernel.alpha).add_(1.0).pow(-kernel.alpha)
      res = kernel(a, b).to_dense()
      self.assertLess(torch.norm(res - actual), 1e-5)
  
      # Diag
      res = kernel(a, b).diagonal(dim1=-1, dim2=-2)
      actual = actual.diagonal(dim1=-1, dim2=-2)
      self.assertLess(torch.norm(res - actual), 1e-5)
  
      # batch_dims
      diff = scaled_a.transpose(-1, -2).unsqueeze(
          -1
      ) - scaled_b.transpose(-1, -2).unsqueeze(-2)
      actual = (
          diff.pow(2)
          .div_(2 * kernel.alpha)
          .add_(1.0)
          .pow(-kernel.alpha)
      )
      res = kernel(a, b, last_dim_is_batch=True).to_dense()
      self.assertLess(torch.norm(res - actual), 1e-5)
  
      # batch_dims and diag
      res = kernel(a, b, last_dim_is_batch=True).diagonal(
          dim1=-1, dim2=-2
      )
      actual = actual.diagonal(dim1=-1, dim2=-2)
      self.assertLess(torch.norm(res - actual), 1e-5)
  
file_path: gpytorch/test/kernels/test_rq_kernel.py
imports: import math
  import unittest
  import torch
  from gpytorch.kernels import RQKernel
  from gpytorch.test.base_kernel_test_case import BaseKernelTestCase
label_desc: Use image node_id 3 for calling the TestRQKernel obj's underlying member method code with example usage: obj.test_ard() without return types