code: def _test_gen_kernel_features(
      self,
      kernel: Kernel,
      feature_map: FeatureMap,
      X: Tensor,
      atol: float = 3.0,
  ):
      with self.subTest("test_initialization"):
          self.assertEqual(feature_map.weight.dtype, kernel.dtype)
          self.assertEqual(feature_map.weight.device, kernel.device)
          self.assertEqual(
              feature_map.weight.shape[-1],
              self.num_inputs
              if kernel.active_dims is None
              else len(kernel.active_dims),
          )
  
      with self.subTest("test_covariance"):
          features = feature_map(X)
          test_shape = torch.broadcast_shapes(
              (*X.shape[:-1], self.num_features),
              kernel.batch_shape + (1, 1),
          )
          self.assertEqual(features.shape, test_shape)
          K0 = features @ features.transpose(-2, -1)
          K1 = kernel(X).to_dense()
          self.assertTrue(
              K0.allclose(
                  K1, atol=atol * self.num_features**-0.5, rtol=0
              )
          )
  
      # Test passing the wrong dimensional shape to `weight_generator`
      with self.assertRaisesRegex(
          UnsupportedError, "2-dim"
      ), patch.object(
          generators,
          "_gen_fourier_features",
          side_effect=lambda **kwargs: kwargs["weight_generator"](
              Size([])
          ),
      ):
          gen_kernel_features(
              kernel=kernel,
              num_inputs=self.num_inputs,
              num_outputs=self.num_features,
          )
  
      # Test requesting an odd number of features
      with self.assertRaisesRegex(
          UnsupportedError, "Expected an even number"
      ):
          gen_kernel_features(
              kernel=kernel, num_inputs=self.num_inputs, num_outputs=3
          )
  
file_path: botorch/test/sampling/pathwise/features/test_generators.py
imports: from __future__ import annotations
  from math import ceil
  from unittest.mock import patch
  import torch
  from botorch.exceptions.errors import UnsupportedError
  from botorch.sampling.pathwise.features import generators
  from botorch.sampling.pathwise.features.generators import gen_kernel_features
  from botorch.sampling.pathwise.features.maps import FeatureMap
  from botorch.utils.testing import BotorchTestCase
  from gpytorch.kernels import MaternKernel, RBFKernel, ScaleKernel
  from gpytorch.kernels.kernel import Kernel
  from torch import Size, Tensor
label_desc: Use image node_id 3 for calling the TestFeatureGenerators obj's underlying member method code with example usage: obj._test_gen_kernel_features(kernel, feature_map, X, atol) without return types