Hello,

first off, amazing job on Pyro! Major kudos

How do I sample from the posterior predictive for an SVI-trained model efficiently? At the moment, I sample a guide trace for each desired posterior predictive sample, replay the model with the guide trace, and sample once from it, like this:

```
ppc = []
dummy_obs = torch.zeros((1,self.D))
for sample in range(n_samples):
guide_trace = pyro.poutine.trace(self.guide).get_trace(dummy_obs)
posterior_predictive = pyro.poutine.trace(pyro.poutine.replay(self.model, guide_trace)).get_trace(dummy_obs)
ppc.append(posterior_predictive.nodes['obs']['value'].detach().numpy())
np.squeeze(np.array(ppc))
```

Is there a better way?

edit:

After a bit more trial and error, I arrived at this:

```
def posterior_predictive(self, n_samples = None):
if n_samples is None:
n_samples = self.N
dummy_obs = torch.zeros((1,D))
with pyro.plate('n_samples', n_samples, dim=-2):
# sample latent variables from guide
guide_trace = pyro.poutine.trace(self.guide).get_trace(dummy_obs)
# sample observations given latent variables
blockreplay = pyro.poutine.block(fn = pyro.poutine.replay(self.model, guide_trace),expose=['obs'])
posterior_predictive = pyro.sample('pred_obs', blockreplay, dummy_obs)
return posterior_predictive
```