code: def _gen_fourier_features(
      kernel: kernels.Kernel,
      weight_generator: Callable[[Size], Tensor],
      num_inputs: int,
      num_outputs: int,
  ) -> KernelFeatureMap:
      r"""Generate a feature map :math:`\phi: \mathcal{X} \to \mathbb{R}^{2l}` that
      approximates a stationary kernel so that :math:`k(x, x') ≈ \phi(x)^\top \phi(x')`.
  
      Following [sutherland2015error]_, we represent complex exponentials by pairs of
      basis functions :math:`\phi_{i}(x) = \sin(x^\top w_{i})` and
      :math:`\phi_{i + l} = \cos(x^\top w_{i}).
  
      Args:
          kernel: A stationary kernel :math:`k(x, x') = k(x - x')`.
          weight_generator: A callable used to generate weight vectors :math:`w`.
          num_inputs: The number of input features.
          num_outputs: The number of Fourier features.
      """
      if num_outputs % 2:
          raise UnsupportedError(
              f"Expected an even number of output features, but received {num_outputs=}."
          )
  
      input_transform = InverseLengthscaleTransform(kernel)
      if kernel.active_dims is not None:
          num_inputs = len(kernel.active_dims)
          input_transform = ChainedTransform(
              input_transform,
              FeatureSelector(indices=kernel.active_dims),
          )
  
      weight = weight_generator(
          Size(
              [
                  kernel.batch_shape.numel() * num_outputs // 2,
                  num_inputs,
              ]
          )
      ).reshape(*kernel.batch_shape, num_outputs // 2, num_inputs)
  
      output_transform = SineCosineTransform(
          torch.tensor(
              (2 / num_outputs) ** 0.5,
              device=kernel.device,
              dtype=kernel.dtype,
          )
      )
      return KernelFeatureMap(
          kernel=kernel,
          weight=weight,
          input_transform=input_transform,
          output_transform=output_transform,
      )
  
file_path: botorch/botorch/sampling/pathwise/features/generators.py
imports: from __future__ import annotations
  from typing import Any, Callable
  import torch
  from botorch.exceptions.errors import UnsupportedError
  from botorch.sampling.pathwise.features.maps import KernelFeatureMap
  from botorch.sampling.pathwise.utils import ChainedTransform, FeatureSelector, InverseLengthscaleTransform, OutputscaleTransform, SineCosineTransform
  from botorch.utils.dispatcher import Dispatcher
  from botorch.utils.sampling import draw_sobol_normal_samples
  from gpytorch import kernels
  from gpytorch.kernels.kernel import Kernel
  from torch import Size, Tensor
  from torch.distributions import Gamma
label_desc: Use image node_id 2 for calling a global function with example usage: _gen_fourier_features(kernel, weight_generator, num_inputs, num_outputs) and returns: KernelFeatureMap