def _calculate_loss(self, scores, labels):
    if (not any(labels)):
        return (torch.tensor(0.0, requires_grad=True, device=flair.device), 1)
    if self.multi_label:
        labels = torch.tensor([[(1 if (l in all_labels_for_point) else 0) for l in self.label_dictionary.get_items()] for all_labels_for_point in labels], dtype=torch.float, device=flair.device)
    else:
        labels = torch.tensor([(self.label_dictionary.get_idx_for_item(label[0]) if (len(label) > 0) else self.label_dictionary.get_idx_for_item('O')) for label in labels], dtype=torch.long, device=flair.device)
    return (self.loss_function(scores, labels), len(labels))
def _calculate_loss(self, scores, labels):
    if (not any(labels)):
        return (torch.tensor(0.0, requires_grad=True, device=flair.device), 1)
    if self.multi_label:
        labels = torch.tensor([[(1 if (l in all_labels_for_point) else 0) for l in self.label_dictionary.get_items()] for all_labels_for_point in labels], dtype=torch.float, device=flair.device)
    else:
        labels = torch.tensor([(self.label_dictionary.get_idx_for_item(label[0]) if (len(label) > 0) else self.label_dictionary.get_idx_for_item('O')) for label in labels], dtype=torch.long, device=flair.device)
    return (self.loss_function(scores, labels), len(labels))