code: def test_multilabel_jaccard_loss():
      eps = 1e-5
      criterion = L.JaccardLoss(mode="multilabel", from_logits=False)
  
      # Ideal case
      y_pred = torch.tensor(
          [[[1.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 1.0]]]
      )
      y_true = torch.tensor(
          [[[1.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 1.0]]]
      )
  
      loss = criterion(y_pred, y_true)
      assert float(loss) == pytest.approx(0.0, abs=eps)
  
      # Worst case
      y_pred = torch.tensor(
          [[[1.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 1.0]]]
      )
      y_true = 1 - y_pred
      loss = criterion(y_pred, y_true)
      assert float(loss) == pytest.approx(1.0, abs=eps)
  
      # 1 - 1/3 case
      y_pred = torch.tensor(
          [[[0.0, 1.0, 1.0, 0.0], [0.0, 1.0, 1.0, 0.0]]]
      )
      y_true = torch.tensor(
          [[[1.0, 1.0, 0.0, 0.0], [1.0, 1.0, 0.0, 0.0]]]
      )
  
      loss = criterion(y_pred, y_true)
      assert float(loss) == pytest.approx(1.0 - 1.0 / 3.0, abs=eps)
  
imports: import numpy
  import pytest
  import pytorch_toolbelt.losses.functional
  import torch
  from pytorch_toolbelt import losses
  from torch import nn
  from pytorch_toolbelt.losses import BinaryFocalLoss, CrossEntropyFocalLoss
label_desc: Use image node_id 9 for calling a global function with example usage: test_multilabel_jaccard_loss() without return types