I used this code a while ago for a classification problem. Don’t really remember on which StackOverflow thread. But thank you for googling and pointing out the github repo (it may not be the original repo).
But my problem still remains. The implementation works for classification (binary of multi class), not for multi-label classification. In multi-label classification, a sample can have more than one category.
For instance, for 5 classes, a target for a sample x could be
target_x = [1, 0, 1, 0, 0]
# then for 64 samples, the targets are [64, 5] not [64] 
# I'm using  134 categories

Multi-label classification is mostly used in attribute classification where a given image can have more than one attribute. Each attribute is treated as binary classification problem. Hope you understand now