# Infer_discrete

• What tutorial are you running? Inference with Discrete Latent Variables

• What version of Pyro are you using? 0.3

• Please link or paste relevant code, and steps to reproduce.

serving_model = infer_discrete(model, first_available_dim=-1)
x, y, z = serving_model() # takes the same args as model(), here no args
print(“x = {}”.format(x))
print(“y = {}”.format(y))
print(“z = {}”.format(z))

I have no issue with reproducibility, but I do not understand when to use infer_discrete. There is very little written on this function. What does it actually do? What happens if one specifies parallel enumeration without using infer_discrete?
In the tutorial, this function is used when working with multiple latent variables. Why only then?

The following code enumerates without using discrete_infer. If possible, I would like to see a use case that uses discrete_infer that makes it clear why it is needed.

`````` def model():
z = pyro.sample("z", dist.Categorical(torch.ones(5)))
print('model z = {}'.format(z))

def guide():
z = pyro.sample("z", dist.Categorical(torch.ones(5)))
print('guide z = {}'.format(z))

elbo = Trace_ELBO()
elbo.loss(model, guide);``````

I’m not sure I understand your example, as there’s no enumeration happening at all - the sample sites aren’t marked for enumeration and only `TraceEnum_ELBO` uses enumeration to compute the ELBO. Is that what you meant to do?

`infer_discrete` is an experimental feature used for efficiently drawing samples from the joint posterior distribution over discrete latent variables given observations, or for computing maximum a posteriori values (i.e. values with the highest posterior probability) of those variables. See the documentation of `infer_discrete` for an example of computing the MAP state sequence in a hidden Markov model.