The cust_Loss function you implement must have backward() defined. In fact, your cust_Loss can’t be any python function but must be a class that inherits from torch.autograd.Function and implements the .forward() and .backward() methods.
So in the MultiLabelSoftMarginLoss, the backward function is the one implemented in F.binary_cross_entropy.