I thought that maybe instead of multiplying your tensor with a one-hot mask, you could simply slice the desired location, e.g.:
#output = tensor * mask
output = tensor[0, :]

But as I’ve mentioned, I’m not sure if that would be suitable for your use case.