Naming when splitting dimensions of pyro.sample()

Let’s say I have two latent variables y,z in model() with factorized priors, e.g.

y = pyro.sample(“y”, …), z = pyro.sample(“z”, …).

How would I able to model the approximate posterior of y and z together, e.g. using a normalizing flow. If I do something like
sample = pyro.sample(“sample”, …)
y = sample[1]
z = sample[2]

I will have an error similar to this:
log_r_term = log_r_term - guide_trace.nodes[name][“log_prob”]

KeyError: ‘y’

Hi @timudk, in Pyro autoguides, we unpack the joint latent variable using _unpack_latent method. We also have AutoNormalizationFlow class, which makes it easier to construct a normalization flow as a guide. I guess you can mimic its implementation for your usage case.