def svgd_kernel(self, h=(- 1)):
    (n, d) = self.theta.shape
    sq_dist = pdist(self.theta)
    pairwise_dists = (squareform(sq_dist) ** 2)
    if (h < 0):
        h = np.median(pairwise_dists)
        h = np.sqrt(((0.5 * h) / np.log((n + 1))))
    Kxy = np.exp((((- pairwise_dists) / (h ** 2)) / 2))
    dxkxy = (- np.matmul(Kxy, self.theta))
    sumkxy = np.sum(Kxy, axis=1)
    for i in range(d):
        dxkxy[:, i] = (dxkxy[:, i] + np.multiply(self.theta[:, i], sumkxy))
    dxkxy = (dxkxy / (h ** 2))
    grad_theta = ((np.matmul(Kxy, self.Sqx) + dxkxy) / n)
    return grad_theta
def svgd_kernel(self, h=(- 1)):
    (n, d) = self.theta.shape
    sq_dist = pdist(self.theta)
    pairwise_dists = (squareform(sq_dist) ** 2)
    if (h < 0):
        h = np.median(pairwise_dists)
        h = np.sqrt(((0.5 * h) / np.log((n + 1))))
    Kxy = np.exp((((- pairwise_dists) / (h ** 2)) / 2))
    dxkxy = (- np.matmul(Kxy, self.theta))
    sumkxy = np.sum(Kxy, axis=1)
    for i in range(d):
        dxkxy[:, i] = (dxkxy[:, i] + np.multiply(self.theta[:, i], sumkxy))
    dxkxy = (dxkxy / (h ** 2))
    grad_theta = ((np.matmul(Kxy, self.Sqx) + dxkxy) / n)
    return grad_theta