code: def soft_micro_f1(preds: Tensor, targets: Tensor, eps=1e-6) -> Tensor:
      """Compute the macro soft F1-score as a cost.
      Average (1 - soft-F1) across all labels.
      Use probability values instead of binary predictions.
  
      Args:
          targets (Tensor): targets array of shape (Num Samples, Num Classes)
          preds (Tensor): probability matrix of shape (Num Samples, Num Classes)
  
      Returns:
          cost (scalar Tensor): value of the cost function for the batch
  
      References:
          https://towardsdatascience.com/the-unknown-benefits-of-using-a-soft-f1-loss-in-classification-systems-753902c0105d
      """
      tp = torch.sum(preds * targets, dim=0)
      fp = torch.sum(preds * (1 - targets), dim=0)
      fn = torch.sum((1 - preds) * targets, dim=0)
      soft_f1 = 2 * tp / (2 * tp + fn + fp + eps)
      loss = (
          1 - soft_f1
      )  # reduce 1 - soft-f1 in order to increase soft-f1
      return loss.mean()
  
file_path: pytorch-toolbelt/pytorch_toolbelt/losses/soft_f1.py
imports: import torch
  from torch import nn, Tensor
  from typing import Optional
label_desc: Use image node_id 1 for calling a global function with example usage: soft_micro_f1(preds, targets, eps) and returns: loss