docstr: Gaussian RBF kernel: :math:`k(x,y) = \exp(-\frac{||x-y||^2}{2\sigma^2})`.
  A forward pass takes a batch of instances `x` of size `Nx x f1 x f2 x ...` and
  `y` of size `Ny x f1 x f2 x ... ` and returns the kernel matrix of size `Nx x Ny`.
  
  Parameters
  ----------
  sigma
      Kernel bandwidth. Not to be specified if being inferred or trained.
      Can pass multiple values to evaluate the kernel with and then average.
docstr_tok: ["Gaussian","RBF","kernel",":",":","math",":","`","k","(","x",",","y",")","=","\\exp","(","-\\frac","{","||x-y||^2","}","{","2\\sigma^2","}",")","`",".","A","forward","pass","takes","a","batch","of","instances","`","x","`","of","size","`","Nx","x","f1","x","f2","x","...","`","and","`","y","`","of","size","`","Ny","x","f1","x","f2","x","...","`","and","returns","the","kernel","matrix","of","size","`","Nx","x","Ny","`",".","Parameters","--","--","--","--","--","sigma","Kernel","bandwidth",".","Not","to","be","specified","if","being","inferred","or","trained",".","Can","pass","multiple","values","to","evaluate","the","kernel","with","and","then","average","."]
code: def __init__(
      self, sigma: Optional[Union[float, np.ndarray]] = None
  ) -> None:
      """
      Gaussian RBF kernel: :math:`k(x,y) = \\exp(-\\frac{||x-y||^2}{2\\sigma^2})`.
      A forward pass takes a batch of instances `x` of size `Nx x f1 x f2 x ...` and
      `y` of size `Ny x f1 x f2 x ... ` and returns the kernel matrix of size `Nx x Ny`.
  
      Parameters
      ----------
      sigma
          Kernel bandwidth. Not to be specified if being inferred or trained.
          Can pass multiple values to evaluate the kernel with and then average.
      """
      super().__init__()
      self.config = {"sigma": sigma}
  
      if sigma is None:
          self.log_sigma = np.empty(1, dtype=np.float32)
          self.init_required = True
      else:
          if not isinstance(sigma, np.ndarray):
              sigma = np.array(sigma)
  
          sigma = sigma.reshape(
              -1,
          ).astype(
              np.float32
          )  # [Ns,]
          self.log_sigma = np.log(sigma)
          self.init_required = False
  
file_path: alibi/alibi/utils/kernel.py
imports: import numpy
  from typing import Union, Optional
  from alibi.utils.distance import squared_pairwise_distance
label_desc: Use image node_id 1 to create a new GaussianRBF object  with example: obj = GaussianRBF(sigma)