code: def test_serialize_fiftyone():
      serial = FiftyOneSegmentationLabelsOutput()
      filepath_serial = FiftyOneSegmentationLabelsOutput(
          return_filepath=True
      )
  
      preds = torch.zeros(5, 2, 3)
      preds[1, 1, 2] = 1  # add peak in class 2
      preds[3, 0, 1] = 1  # add peak in class 4
  
      sample = {
          DataKeys.PREDS: preds,
          DataKeys.METADATA: {"filepath": "something"},
      }
  
      segmentation = serial.transform(sample)
      assert segmentation.mask[1, 2] == 1
      assert segmentation.mask[0, 1] == 3
  
      segmentation = filepath_serial.transform(sample)
      assert segmentation["predictions"].mask[1, 2] == 1
      assert segmentation["predictions"].mask[0, 1] == 3
      assert segmentation["filepath"] == "something"
  
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 4 for calling the TestSemanticSegmentationLabelsOutput obj's underlying member method code with example usage: obj.test_serialize_fiftyone() without return types