class_docstr: A class that represents Random Fourier Features.
class_docstr_tok: ["A","class","that","represents","Random","Fourier","Features","."]
docstr: Sample weights for RFF.
  
  Args:
      kernel: The GP base kernel.
      input_dim: The input dimension to the GP kernel.
      num_rff_features: The number of Fourier features.
      sample_shape: The sample shape of weights.
  Returns:
      A tensor of weights with shape
      `(*sample_shape, *kernel_batch_shape, input_dim, num_rff_features)`.
docstr_tok: ["Sample","weights","for","RFF",".","Args",":","kernel",":","The","GP","base","kernel",".","input_dim",":","The","input","dimension","to","the","GP","kernel",".","num_rff_features",":","The","number","of","Fourier","features",".","sample_shape",":","The","sample","shape","of","weights",".","Returns",":","A","tensor","of","weights","with","shape","`","(","*","sample_shape",",","*","kernel_batch_shape",",","input_dim",",","num_rff_features",")","`","."]
code: def _get_weights(
      self,
      base_kernel: Kernel,
      input_dim: int,
      num_rff_features: int,
      sample_shape: Optional[torch.Size] = None,
  ) -> Tensor:
      r"""Sample weights for RFF.
  
      Args:
          kernel: The GP base kernel.
          input_dim: The input dimension to the GP kernel.
          num_rff_features: The number of Fourier features.
          sample_shape: The sample shape of weights.
      Returns:
          A tensor of weights with shape
          `(*sample_shape, *kernel_batch_shape, input_dim, num_rff_features)`.
      """
      sample_shape = (
          torch.Size() if sample_shape is None else sample_shape
      )
      weights = torch.randn(
          *sample_shape,
          *self.kernel_batch_shape,
          input_dim,
          num_rff_features,
          dtype=base_kernel.lengthscale.dtype,
          device=base_kernel.lengthscale.device,
      )
      if isinstance(base_kernel, MaternKernel):
          gamma_dist = torch.distributions.Gamma(
              base_kernel.nu, base_kernel.nu
          )
          gamma_samples = gamma_dist.sample(
              torch.Size([1, num_rff_features])
          ).to(weights)
          weights = torch.rsqrt(gamma_samples) * weights
      return weights
  
imports: from __future__ import annotations
  from copy import deepcopy
  from math import pi
  from typing import List, Optional
  import torch
  from botorch.models.converter import batched_to_model_list
  from botorch.models.deterministic import GenericDeterministicModel
  from botorch.models.model import Model, ModelList
  from botorch.models.model_list_gp_regression import ModelListGP
  from botorch.models.multitask import MultiTaskGP
  from botorch.utils.sampling import manual_seed
  from botorch.utils.transforms import is_ensemble
  from gpytorch.kernels import Kernel, MaternKernel, RBFKernel, ScaleKernel
  from linear_operator.utils.cholesky import psd_safe_cholesky
  from torch import Tensor
  from torch.distributions import MultivariateNormal
  from torch.nn import Module
label_desc: Use image node_id 2 for calling the RandomFourierFeatures obj's underlying member method code with example usage: obj._get_weights(base_kernel, input_dim, num_rff_features, sample_shape) and returns: weights