code: def test_serialize():
      serial = SegmentationLabelsOutput()
  
      sample = torch.zeros(5, 2, 3)
      sample[1, 1, 2] = 1  # add peak in class 2
      sample[3, 0, 1] = 1  # add peak in class 4
  
      classes = serial.serialize({DataKeys.PREDS: sample})
      assert torch.tensor(classes)[1, 2] == 1
      assert torch.tensor(classes)[0, 1] == 3
  
file_path: lightning-flash/tests/image/semantic_segm/test_output.py
imports: import pytest
  import torch
  from flash.core.data.io.input import DataKeys
  from flash.core.utilities.imports import _FIFTYONE_AVAILABLE, _SEGMENTATION_MODELS_AVAILABLE, _TOPIC_IMAGE_AVAILABLE, _TOPIC_SERVE_AVAILABLE
  from flash.image.segmentation.output import FiftyOneSegmentationLabelsOutput, SegmentationLabelsOutput
label_desc: Use image node_id 3 for calling the TestSemanticSegmentationLabelsOutput obj's underlying member method code with example usage: obj.test_serialize() without return types