How to get the joint distribution in Pyro?

Hi fehiepsi, it helps a lot – things start to make sense now :slight_smile:. But I still have two questions.

Question 1:
What exactly does the pyro.sample with obs= do in the example?
pyro.sample("obs_{}".format(i), dist.Bernoulli(f), obs=data[i])

Specifically, does it generate a sample of Bernoulli distributed random variable or calculate a probability p(obs|f) only? If the latter, it is totally different from the same statement without obs=data[i].

In the example above, the condition seems to be that the latent variable is equal to f. But in another example, the tutorial says that obs= is the condition. How do I reconcile the contradictory explanation?

Question 2:
In the example, it is assumed that the latent variable f influences the data through the Bernoulli distribution with parameter f. That is nice and makes things simple. In a more realistic application, for example, in image recognition using a neural network, how to we find the distribution?

Thanks.