Following, is a simple example of what i am trying to achieve. The model takes in a label (forget x for now) and the shape is (_, 7) where the first three indices belong to a label type 1 (action) and the last 4 indices belong to a label type2 (reaction). Both together form the labels as they are observed.

```
def model(self, x,y):
# sample y looks like 0 0 1 0 0 1 0
# The first three index covers action and the next four index covers reaction.
# register PyTorch module `decoder` with Pyro
options = dict(dtype=x.dtype, device=x.device)
with pyro.plate("data", x.shape[0]):
# Using a pre-defined cpt.
action_type = pyro.sample("action_type", dist.Categorical(cpts["action_type"]))
reaction_type = pyro.sample("reaction_type", dist.Categorical(cpts["reaction_type"]))
# Slicing the labels
action= pyro.sample("action", dist.Categorical(cpts["action"][action_type]), obs= y.squeeze(0)[:3])
reaction = pyro.sample("reaction", dist.Categorical(cpts["character"]), obs=y.squeeze(0)[3:])
def guide(self, x, y):
# register PyTorch module `encoder` with Pyro
with pyro.plate("data", x.shape[0]): # Iterate every batch
print(f"size of y is {y.shape}") # (batchsize, 7)
# sample y looks like 0 0 1 0 0 1 0
# The first three index covers action and the next four index covers reaction.
action = (y.squeeze(0)[:3])]!=0).nonzero().squeeze(1)[0] # Trying to get the index where there was a non -zero entry.
#If 0 0 1 is the label then need action as 2
reaction = (y.squeeze(0)[3:]!=0).nonzero().squeeze(1)[0]
action_type = pyro.sample("action_type", dist.Categorical(inverse_cpts["action_type"][action]))
reaction_type = pyro.sample("reaction_type", dist.Categorical(inverse_cpts["reaction_type"][reaction]))
```

I am not able to slice the y tensor according to my liking . Whenever i try to slice y i am getting the whole batch tensor whereas the inverse_cpts needs a scalar tensor for each observation.

How do i slice the tensor correctly or is there any other way to do this ?