Thank you - this is great! I ended up using the gather function(which I was previously unaware of) to sample from my a and b tensors after stacking them in dim=0 with the indices I got from torch.multinomial()