I am not sure if I understand you correctly, so I am not sure if this is what you are looking for.
So the output of your model is of shape (B, C, H, W) , correct? And at each location, there are unnormalized probabilities corresponding to the prediction of each class?  Which would be the normal output of, for example torchvision.models.segmentation.deeplabv3_resnet101()['out'].
If so, to then get the maximum prediction of each class, and then use it for a downstream task, you can do output_predictions = output.argmax(0).
So for example (example with 21 classes):
with torch.no_grad():
    output = model(input_batch)['out'][0]
output_predictions = output.argmax(0)

# create a color pallette, selecting a color for each class
palette = torch.tensor([2 ** 25 - 1, 2 ** 15 - 1, 2 ** 21 - 1])
colors = torch.as_tensor([i for i in range(21)])[:, None] * palette
colors = (colors % 255).numpy().astype("uint8")

# plot the semantic segmentation predictions of 21 classes in each color
r = Image.fromarray(output_predictions.byte().cpu().numpy()).resize(input_image.size)
r.putpalette(colors)

import matplotlib.pyplot as plt
plt.imshow(r)
# plt.show()