The workflow to get the predictions sounds correct for the inference use case, but I assume won’t be used to train the model.
Here is a small example of what I had in mind:
# setup
batch_size, nb_classes, seq_len = 2, 3, 4
output = torch.randn(batch_size, nb_classes, seq_len, requires_grad=True)
target = torch.randint(0, 2, (batch_size, nb_classes, seq_len)).float()
criterion = nn.BCEWithLogitsLoss(reduction='none')

# create decreasing weight
weights = torch.arange(seq_len, 0, -1).view(1, 1, seq_len).float()

# calculate loss
loss = criterion(output, target)

# apply weights
loss = loss * weights

# reduce and calculate gradients
loss.mean().backward()