There was the Amazon Forest competition 23 with F2 score loss which needed actual label and not scores as output.
To have adaptative threshold, I’ve used Basinhopping optimizer + L-BFGS 44 on a MultiLabelMarginLoss output 36
I’ve explored various way to avoid thresholding, including creating a RNN that would output labels but you should not that there is no easy answer, many papers are being published on that, you can start with the following:

A study on Threshold Selection for Multi-Label Classification 119

Thresholding classifiers to maximize F1 score 55 and Optimal thresholding for F1 measure 28

Optimizing F-Measure a tale of 2 approaches 28
All captioning, pictures to text/label, object detection are also dealing with that and worth checking

Note that Sigmoid/MultiLabelMarginLoss assume the classes probabilities are independent which is usually not true.