Well alternatively you can do t = preds[0][0].argmax(dim=0) which has shape [H, W]. If you want something of shape [1, H, W], you can do t = preds[0][0].argmax(dim=0, keepdim=True). Your solution is absolutely fine though, just wasn’t my first intuition.
EDIT: looking back, your solution is better as it makes more sense to always have the same prediction pipeline, which here is using argmax(dim=1).