import torch


def exact_gaussian_kernel(x1, x2):
    """Computes exact Gaussian kernel value(s) for tensors x1 and x2."""
    x1 = torch.tensor(x1, dtype=torch.float32)
    x2 = torch.tensor(x2, dtype=torch.float32)
    x1_squared = torch.sum(x1 ** 2, list(range(1, len(x1.shape))))
    x2_squared = torch.sum(x2 ** 2, list(range(1, len(x2.shape))))
    square = x1_squared[:, None] + x2_squared[None, :] - 2 * x1 @ x2.T
    return torch.exp(-square / 2.)