def svgd_kernel_subset(self, h=(- 1), cf=False):
    (n, d) = self.theta.shape
    m = self.y.shape[0]
    pairwise_dists = (cdist(self.theta, self.y) ** 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))
    if (cf == True):
        sqxdy_part = np.array(([np.sum(np.multiply(self.Sqy, self.y), axis=1)] * m)).T
        sqxdy = ((- (np.matmul(self.Sqy, self.y.T) - sqxdy_part)) / (h ** 2))
        dxsqy = sqxdy.T
        dxdy = (((- pairwise_dists[self.yInd]) / (h ** 4)) + (d / (h ** 2)))
        KxySub = Kxy[self.yInd]
        KpMat = (((np.matmul(self.Sqy, self.Sqy.T) + sqxdy) + dxsqy) + dxdy)
        KpMat = np.multiply(KpMat, KxySub)
        weights = self.getWeights(KpMat)
        Kxy = np.multiply(Kxy, np.matlib.repmat(weights, n, 1))
    dxkxy = (- np.matmul(Kxy, self.y))
    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.Sqy) + dxkxy)
    if (cf == False):
        grad_theta = (grad_theta / m)
    return grad_theta
def svgd_kernel_subset(self, h=(- 1), cf=False):
    (n, d) = self.theta.shape
    m = self.y.shape[0]
    pairwise_dists = (cdist(self.theta, self.y) ** 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))
    if (cf == True):
        sqxdy_part = np.array(([np.sum(np.multiply(self.Sqy, self.y), axis=1)] * m)).T
        sqxdy = ((- (np.matmul(self.Sqy, self.y.T) - sqxdy_part)) / (h ** 2))
        dxsqy = sqxdy.T
        dxdy = (((- pairwise_dists[self.yInd]) / (h ** 4)) + (d / (h ** 2)))
        KxySub = Kxy[self.yInd]
        KpMat = (((np.matmul(self.Sqy, self.Sqy.T) + sqxdy) + dxsqy) + dxdy)
        KpMat = np.multiply(KpMat, KxySub)
        weights = self.getWeights(KpMat)
        Kxy = np.multiply(Kxy, np.matlib.repmat(weights, n, 1))
    dxkxy = (- np.matmul(Kxy, self.y))
    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.Sqy) + dxkxy)
    if (cf == False):
        grad_theta = (grad_theta / m)
    return grad_theta