docstr: Computes the kernel matrix between `x` and `y`.
  
  Parameters
  ----------
  x
      The first array of data instances.
  y
      The second array of data instances.
  infer_sigma
      Whether to infer `sigma` automatically. The `sigma` value is computed based on the median distance value
      between the instances from `x` and `y`.
  
  Returns
  -------
  Kernel matrix between `x` and `y` having the size of `Nx x Ny` where `Nx` is the number of instances in `x`         and `y` is the number of instances in `y`.
docstr_tok: ["Computes","the","kernel","matrix","between","`","x","`","and","`","y","`",".","Parameters","--","--","--","--","--","x","The","first","array","of","data","instances",".","y","The","second","array","of","data","instances",".","infer_sigma","Whether","to","infer","`","sigma","`","automatically",".","The","`","sigma","`","value","is","computed","based","on","the","median","distance","value","between","the","instances","from","`","x","`","and","`","y","`",".","Returns","--","--","--","-","Kernel","matrix","between","`","x","`","and","`","y","`","having","the","size","of","`","Nx","x","Ny","`","where","`","Nx","`","is","the","number","of","instances","in","`","x","`","and","`","y","`","is","the","number","of","instances","in","`","y","`","."]
code: def __call__(
      self, x: np.ndarray, y: np.ndarray, infer_sigma: bool = False
  ) -> np.ndarray:
      """
          Computes the kernel matrix between `x` and `y`.
  
          Parameters
          ----------
          x
              The first array of data instances.
          y
              The second array of data instances.
          infer_sigma
              Whether to infer `sigma` automatically. The `sigma` value is computed based on the median distance value
              between the instances from `x` and `y`.
  
          Returns
          -------
          Kernel matrix between `x` and `y` having the size of `Nx x Ny` where `Nx` is the number of instances in `x` \
          and `y` is the number of instances in `y`.
          """
      y = y.astype(x.dtype)
      x, y = x.reshape((x.shape[0], -1)), y.reshape(
          (y.shape[0], -1)
      )  # flatten
      dist = squared_pairwise_distance(x, y)  # [Nx, Ny]
  
      if infer_sigma or self.init_required:
          n = min(x.shape[0], y.shape[0])
          n = n if np.all(x[:n] == y[:n]) and x.shape == y.shape else 0
          n_median = n + (np.prod(dist.shape) - n) // 2 - 1
          sigma = np.expand_dims(
              (0.5 * np.sort(dist.reshape(-1))[n_median]) ** 0.5, axis=0
          )
          self.log_sigma = np.log(sigma)
          self.init_required = False
  
      gamma = np.array(
          1.0 / (2.0 * self.sigma**2), dtype=x.dtype
      )  # [Ns,]
      # TODO: do matrix multiplication after all?
      kernel_mat = np.exp(
          -np.concatenate(
              [(g * dist)[None, :, :] for g in gamma], axis=0
          )
      )  # [Ns, Nx, Ny]
      return np.mean(kernel_mat, axis=0)
  
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 3 for calling the GaussianRBF obj's underlying member method code with example usage: obj.__call__(x, y, infer_sigma) and returns: np