code: def test_deep_kernel(deep_kernel_params):
      (
          n_features,
          n_instances,
          kernel_a,
          kernel_b,
          eps,
      ) = deep_kernel_params
  
      proj = nn.Linear(n_features, n_features)
      kernel_a = (
          MyKernel()
          if kernel_a == "MyKernel"
          else GaussianRBF(trainable=True)
      )
      if kernel_b == "MyKernel":
          kernel_b = MyKernel()
      elif kernel_b == "GaussianRBF":
          kernel_b = GaussianRBF(trainable=True)
      kernel = DeepKernel(
          proj, kernel_a=kernel_a, kernel_b=kernel_b, eps=eps
      )
  
      xshape, yshape = (n_instances[0], n_features), (
          n_instances[1],
          n_features,
      )
      x = torch.as_tensor(np.random.random(xshape).astype("float32"))
      y = torch.as_tensor(np.random.random(yshape).astype("float32"))
      x_proj, y_proj = kernel.proj(x), kernel.proj(y)
      x2_proj, x_proj = LazyTensor(x_proj[None, :, :]), LazyTensor(
          x_proj[:, None, :]
      )
      y2_proj, y_proj = LazyTensor(y_proj[None, :, :]), LazyTensor(
          y_proj[:, None, :]
      )
      if kernel_b:
          x2, x = LazyTensor(x[None, :, :]), LazyTensor(x[:, None, :])
          y2, y = LazyTensor(y[None, :, :]), LazyTensor(y[:, None, :])
      else:
          x, x2, y, y2 = None, None, None, None
  
      k_xy = kernel(x_proj, y2_proj, x, y2)
      k_yx = kernel(y_proj, x2_proj, y, x2)
      k_xx = kernel(x_proj, x2_proj, x, x2)
      assert k_xy.shape == n_instances and k_xx.shape == (
          xshape[0],
          xshape[0],
      )
      assert (k_xx.Kmin_argKmin(1, axis=1)[0] > 0.0).all()
      assert (
          torch.abs(k_xy.sum(1).sum(1) - k_yx.t().sum(1).sum(1)) < 1e-5
      ).all()
  
file_path: alibi-detect/alibi_detect/utils/keops/tests/test_kernels_keops.py
imports: from itertools import product
  import numpy
  from alibi_detect.utils.frameworks import has_keops
  import pytest
  import torch
  import torch.nn
label_desc: Use image node_id 4 for calling a global function with example usage: test_deep_kernel(deep_kernel_params) without return types