def kernel(
kernel_name: str,
x: torch.Tensor = None,
x2: torch.Tensor = None,
*args, **kwargs
):
if 'batch' in kernel_name:
assert x is not None and x2 is None
else:
assert x is not None and x2 is not None
match kernel_name:
case 'linear_kernel' | 'inner_product' | 'dot_product': return linear_kernel(x=x, x2=x2, *args, **kwargs)
case 'polynomial_kernel' | 'polynomial': return polynomial_kernel(x=x, x2=x2, *args, **kwargs)
case 'hyperbolic_tangent_kernel' | 'hyperbolic_tangent': return hyperbolic_tangent_kernel(x=x, x2=x2, *args, **kwargs)
case 'exponential_kernel' | 'exponential': return exponential_kernel(x=x, x2=x2, *args, **kwargs)
case 'cosine_similarity_kernel' | 'cosine_similarity': return cosine_similarity_kernel(x=x, x2=x2, *args, **kwargs)
case 'euclidean_distance': return euclidean_distance(x=x, x2=x2, *args, **kwargs)
case 'minkowski_distance': return minkowski_distance(x=x, x2=x2, *args, **kwargs)
case 'manhattan_distance': return manhattan_distance(x=x, x2=x2, *args, **kwargs)
case 'chebyshev_distance': return chebyshev_distance(x=x, x2=x2, *args, **kwargs)
case 'canberra_distance': return canberra_distance(x=x, x2=x2, *args, **kwargs)
case 'euclidean_distance_kernel': return euclidean_distance_kernel(x=x, x2=x2, *args, **kwargs)
case 'minkowski_distance_kernel': return minkowski_distance_kernel(x=x, x2=x2, *args, **kwargs)
case 'manhattan_distance_kernel': return manhattan_distance_kernel(x=x, x2=x2, *args, **kwargs)
case 'chebyshev_distance_kernel': return chebyshev_distance_kernel(x=x, x2=x2, *args, **kwargs)
case 'canberra_distance_kernel': return canberra_distance_kernel(x=x, x2=x2, *args, **kwargs)
case 'gaussian_rbf_kernel' | 'gaussian_rbf': return gaussian_rbf_kernel(x=x, x2=x2, *args, **kwargs)
case 'laplacian_kernel' | 'laplacian': return laplacian_kernel(x=x, x2=x2, *args, **kwargs)
case 'anisotropic_rbf_kernel' | 'anisotropic_rbf' | 'anisotropic': return anisotropic_rbf_kernel(x=x, x2=x2, *args, **kwargs)
case 'custom_hybrid_kernel' | 'custom_hybrid' | 'custom': return custom_hybrid_kernel(x=x, x2=x2, *args, **kwargs)