class_docstr: **Operator based on Kernelized Stein Discrepancy**
  
  Input: A target distribution with density function :math:`p(x)`
      and a set of initial particles :math:`\{x^0_i\}^n_{i=1}`
  
  Output: A set of particles :math:`\{x_i\}^n_{i=1}` that approximates the target distribution.
  
  .. math::
  
      x_i^{l+1} \leftarrow \epsilon_l \hat{\phi}^{*}(x_i^l) \\
      \hat{\phi}^{*}(x) = \frac{1}{n}\sum^{n}_{j=1}[k(x^l_j,x) \nabla_{x^l_j} logp(x^l_j)/temp +
      \nabla_{x^l_j} k(x^l_j,x)]
  
  Parameters
  ----------
  approx: :class:`Approximation`
      Approximation used for inference
  temperature: float
      Temperature for Stein gradient
  
  References
  ----------
  -   Qiang Liu, Dilin Wang (2016)
      Stein Variational Gradient Descent: A General Purpose Bayesian Inference Algorithm
      arXiv:1608.04471
class_docstr_tok: ["*","*","Operator","based","on","Kernelized","Stein","Discrepancy","*","*","Input",":","A","target","distribution","with","density","function",":","math",":","`","p","(","x",")","`","and","a","set","of","initial","particles",":","math",":","`","\\","{","x^0_i\\","}","^n_","{","i=1","}","`","Output",":","A","set","of","particles",":","math",":","`","\\","{","x_i\\","}","^n_","{","i=1","}","`","that","approximates","the","target","distribution",".","..","math",":",":","x_i^","{","l+1","}","\\leftarrow","\\epsilon_l","\\hat","{","\\phi","}","^","{","*","}","(","x_i^l",")","\\\\","\\hat","{","\\phi","}","^","{","*","}","(","x",")","=","\\frac","{","1","}","{","n","}","\\sum^","{","n","}","_","{","j=1","}","[","k","(","x^l_j",",","x",")","\\nabla_","{","x^l_j","}","logp","(","x^l_j",")","\/temp","+","\\nabla_","{","x^l_j","}","k","(","x^l_j",",","x",")","]","Parameters","--","--","--","--","--","approx",":",":","class",":","`","Approximation","`","Approximation","used","for","inference","temperature",":","float","Temperature","for","Stein","gradient","References","--","--","--","--","--","-","Qiang","Liu",",","Dilin","Wang","(","2016",")","Stein","Variational","Gradient","Descent",":","A","General","Purpose","Bayesian","Inference","Algorithm","arXiv:1608.04471"]
code: def apply(self, f):
      # f: kernel function for KSD f(histogram) -> (k(x,.), \nabla_x k(x,.))
      if _known_scan_ignored_inputs([self.approx.model.logp()]):
          raise NotImplementedInference(
              "SVGD does not currently support Minibatch or Simulator RV"
          )
      stein = Stein(
          approx=self.approx,
          kernel=f,
          use_histogram=self.approx.all_histograms,
          temperature=self.temperature,
      )
      return pm.floatX(-1) * stein.grad
  
file_path: pymc/pymc/variational/operators.py
imports: from __future__ import annotations
  import pytensor
  from pytensor.graph.basic import Variable
  import pymc
  from pymc.variational import opvi
  from pymc.variational.opvi import NotImplementedInference, ObjectiveFunction, Operator, _known_scan_ignored_inputs
  from pymc.variational.stein import Stein
label_desc: Use image node_id 2 for calling the KSD obj's underlying member method code with example usage: obj.apply(f) and returns: unknown