code: def forward(self, preds: Tensor, targets: Tensor) -> Tensor:
      targets = targets.view(-1)
      preds = preds.view(-1)
  
      if self.ignore_index is not None:
          # Filter predictions with ignore label from loss computation
          not_ignored = targets != self.ignore_index
          preds = preds[not_ignored]
          targets = targets[not_ignored]
  
          if targets.numel() == 0:
              return torch.tensor(
                  0, dtype=preds.dtype, device=preds.device
              )
  
      preds = preds.sigmoid().clamp(self.eps, 1 - self.eps)
      return soft_micro_f1(preds.view(-1, 1), targets.view(-1, 1))
  
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 2 for calling the BinarySoftF1Loss obj's underlying member method code with example usage: obj.forward(preds, targets) and returns: soft_micro_f1, torch