class_docstr: A basic implementation of Stein Variational Gradient Descent as described in reference [1].
  
  :param model: The model (callable containing Pyro primitives). Model must be fully vectorized
      and may only contain continuous latent variables.
  :param kernel: a SVGD compatible kernel like :class:`RBFSteinKernel`.
  :param optim: A wrapper for a PyTorch optimizer.
  :type optim: pyro.optim.PyroOptim
  :param int num_particles: The number of particles used in SVGD.
  :param int max_plate_nesting: The max number of nested :func:`pyro.plate` contexts in the model.
  :param str mode: Whether to use a Kernelized Stein Discrepancy that makes use of `multivariate`
      test functions (as in [1]) or `univariate` test functions (as in [2]). Defaults to `univariate`.
  
  Example usage:
  
  .. code-block:: python
  
      from pyro.infer import SVGD, RBFSteinKernel
      from pyro.optim import Adam
  
      kernel = RBFSteinKernel()
      adam = Adam({"lr": 0.1})
      svgd = SVGD(model, kernel, adam, num_particles=50, max_plate_nesting=0)
  
      for step in range(500):
          svgd.step(model_arg1, model_arg2)
  
      final_particles = svgd.get_named_particles()
  
  References
  
  [1] "Stein Variational Gradient Descent: A General Purpose Bayesian Inference Algorithm,"
      Qiang Liu, Dilin Wang
  [2] "Kernelized Complete Conditional Stein Discrepancy,"
      Raghav Singhal, Saad Lahlou, Rajesh Ranganath
code: def __init__(
      self,
      model,
      kernel,
      optim,
      num_particles,
      max_plate_nesting,
      mode="univariate",
  ):
      assert callable(model)
      assert isinstance(
          kernel, SteinKernel
      ), "Must provide a valid SteinKernel"
      assert isinstance(
          optim, pyro.optim.PyroOptim
      ), "Must provide a valid Pyro optimizer"
      assert num_particles > 1, "Must use at least two particles"
      assert max_plate_nesting >= 0
      assert mode in [
          "univariate",
          "multivariate",
      ], "mode must be one of (univariate, multivariate)"
  
      self.model = vectorize(model, num_particles, max_plate_nesting)
      self.kernel = kernel
      self.optim = optim
      self.num_particles = num_particles
      self.max_plate_nesting = max_plate_nesting
      self.mode = mode
  
      self.loss = Trace_ELBO().differentiable_loss
      self.guide = _SVGDGuide(self.model)
  
imports: import math
  from abc import ABCMeta, abstractmethod
  import torch
  from torch.distributions import biject_to
  import pyro
  from pyro import poutine
  from pyro.distributions import Delta
  from pyro.distributions.util import copy_docs_from
  from pyro.infer.autoguide.guides import AutoContinuous
  from pyro.infer.autoguide.initialization import init_to_sample
  from pyro.infer.trace_elbo import Trace_ELBO
label_desc: Use image node_id 1 to create a new SVGD object  with example: obj = SVGD(model, kernel, optim, num_particles, max_plate_nesting, mode)