class_docstr: :class:`SMCFilter` is the top-level interface for filtering via sequential
  monte carlo.
  
  The model and guide should be objects with two methods:
  ``.init(state, ...)`` and ``.step(state, ...)``, intended to be called
  first with :meth:`init` , then with :meth:`step` repeatedly.  These two
  methods should have the same signature as :class:`SMCFilter` 's
  :meth:`init` and :meth:`step` of this class, but with an extra first
  argument ``state`` that should be used to store all tensors that depend on
  sampled variables. The ``state`` will be a dict-like object,
  :class:`SMCState` , with arbitrary keys and :class:`torch.Tensor` values.
  Models can read and write ``state`` but guides can only read from it.
  
  Inference complexity is ``O(len(state) * num_time_steps)``, so to avoid
  quadratic complexity in Markov models, ensure that ``state`` has fixed size.
  
  :param object model: probabilistic model with ``init`` and ``step`` methods
  :param object guide: guide used for sampling,  with ``init`` and ``step``
      methods
  :param int num_particles: The number of particles used to form the
      distribution.
  :param int max_plate_nesting: Bound on max number of nested
      :func:`pyro.plate` contexts.
  :param float ess_threshold: Effective sample size threshold for deciding
      when to importance resample: resampling occurs when
      ``ess < ess_threshold * num_particles``.
docstr: Perform any initialization for sequential importance resampling.
  Any args or kwargs are passed to the model and guide
docstr_tok: ["Perform","any","initialization","for","sequential","importance","resampling",".","Any","args","or","kwargs","are","passed","to","the","model","and","guide"]
code: def init(self, *args, **kwargs):
      """
      Perform any initialization for sequential importance resampling.
      Any args or kwargs are passed to the model and guide
      """
      self.particle_plate = pyro.plate(
          "particles",
          self.num_particles,
          dim=-1 - self.max_plate_nesting,
      )
      with poutine.block(), self.particle_plate:
          with self.state._lock():
              guide_trace = poutine.trace(self.guide.init).get_trace(
                  self.state, *args, **kwargs
              )
          model = poutine.replay(self.model.init, guide_trace)
          model_trace = poutine.trace(model).get_trace(
              self.state, *args, **kwargs
          )
  
      self._update_weights(model_trace, guide_trace)
      self._maybe_importance_resample()
  
imports: import contextlib
  import math
  import torch
  import pyro
  import pyro.distributions
  import pyro.poutine
  from pyro.infer.util import is_validation_enabled
  from pyro.poutine.util import prune_subsample_sites
label_desc: Use image node_id 2 for calling the SMCFilter obj's underlying member method code with example usage: obj.init() without return types