code: def test_asserts(self):
      batch_size = 1
      n_class = 2
      predictions = torch.zeros((batch_size, 80, 80), dtype=torch.int64)
      labels = torch.zeros((batch_size, 80, 80), dtype=torch.int64)
      predictions[0, 10:20, 10:20] = 1
      labels[0, 20:30, 20:30] = 1
      predictions_hot = F.one_hot(
          predictions, num_classes=n_class
      ).permute(0, 3, 1, 2)
      labels_hot = F.one_hot(labels, num_classes=n_class).permute(
          0, 3, 1, 2
      )
  
      # no torch tensor
      with self.assertRaises(ValueError) as context:
          SurfaceDiceMetric(
              class_thresholds=[1, 1], include_background=True
          )(predictions_hot.numpy(), labels_hot)
      self.assertEqual(
          "y_pred or y must be a list/tuple of `channel-first` Tensors or a `batch-first` Tensor.",
          str(context.exception),
      )
      with self.assertRaises(ValueError) as context:
          SurfaceDiceMetric(
              class_thresholds=[1, 1], include_background=True
          )(predictions_hot, labels_hot.numpy())
      self.assertEqual(
          "y_pred and y must be PyTorch Tensor.", str(context.exception)
      )
  
      # wrong dimensions
      with self.assertRaises(ValueError) as context:
          SurfaceDiceMetric(
              class_thresholds=[1, 1], include_background=True
          )(predictions, labels_hot)
      self.assertEqual(
          "y_pred and y should be one-hot encoded: [B,C,H,W] or [B,C,H,W,D].",
          str(context.exception),
      )
      with self.assertRaises(ValueError) as context:
          SurfaceDiceMetric(
              class_thresholds=[1, 1], include_background=True
          )(predictions_hot, labels)
      self.assertEqual(
          "y_pred and y should be one-hot encoded: [B,C,H,W] or [B,C,H,W,D].",
          str(context.exception),
      )
  
      # mismatch of shape of input tensors
      input_bad_shape = torch.clone(predictions_hot)
      input_bad_shape = input_bad_shape[:, :, :, :50]
  
      with self.assertRaises(ValueError) as context:
          SurfaceDiceMetric(
              class_thresholds=[1, 1], include_background=True
          )(predictions_hot, input_bad_shape)
      self.assertEqual(
          "y_pred and y should have same shape, but instead, shapes are torch.Size([1, 2, 80, 80]) (y_pred) and "
          "torch.Size([1, 2, 80, 50]) (y).",
          str(context.exception),
      )
  
      # wrong number of class thresholds
      with self.assertRaises(ValueError) as context:
          SurfaceDiceMetric(
              class_thresholds=[1, 1, 1], include_background=True
          )(predictions_hot, labels_hot)
      self.assertEqual(
          "number of classes (2) does not match number of class thresholds (3).",
          str(context.exception),
      )
  
      # inf and nan values in class thresholds
      with self.assertRaises(ValueError) as context:
          SurfaceDiceMetric(
              class_thresholds=[np.inf, 1], include_background=True
          )(predictions_hot, labels_hot)
      self.assertEqual(
          "All class thresholds need to be finite.",
          str(context.exception),
      )
  
      with self.assertRaises(ValueError) as context:
          SurfaceDiceMetric(
              class_thresholds=[np.nan, 1], include_background=True
          )(predictions_hot, labels_hot)
          self.assertEqual(
              "All class thresholds need to be finite.",
              str(context.exception),
          )
  
      # negative values in class thresholds:
      with self.assertRaises(ValueError) as context:
          SurfaceDiceMetric(
              class_thresholds=[-0.22, 1], include_background=True
          )(predictions_hot, labels_hot)
      self.assertEqual(
          "All class thresholds need to be >= 0.",
          str(context.exception),
      )
  
file_path: MONAI/tests/test_surface_dice.py
imports: from __future__ import annotations
  import unittest
  import numpy
  import torch
  import torch.nn.functional
  from monai.metrics.surface_dice import SurfaceDiceMetric, compute_surface_dice
  from tests.utils import assert_allclose
label_desc: Use image node_id 5 for calling the TestAllSurfaceDiceMetrics obj's underlying member method code with example usage: obj.test_asserts() without return types