code: def test_map_labels(tmpdir):
      tmp_dir = Path(tmpdir)
  
      # create random dummy data
  
      images = [
          str(tmp_dir / "img1.png"),
          str(tmp_dir / "img2.png"),
          str(tmp_dir / "img3.png"),
      ]
  
      targets = [
          str(tmp_dir / "labels_img1.png"),
          str(tmp_dir / "labels_img2.png"),
          str(tmp_dir / "labels_img3.png"),
      ]
  
      labels_map: Dict[int, Tuple[int, int, int]] = {
          0: [0, 0, 0],
          1: [255, 255, 255],
      }
  
      num_classes: int = len(labels_map.keys())
      img_size: Tuple[int, int] = (128, 128)
      create_random_data(images, targets, img_size, num_classes)
  
      # instantiate the data module
  
      dm = SemanticSegmentationData.from_files(
          train_files=images,
          train_targets=targets,
          val_files=images,
          val_targets=targets,
          batch_size=2,
          num_workers=0,
          num_classes=num_classes,
      )
      assert dm is not None
      assert dm.train_dataloader() is not None
  
      # disable visualisation for testing
      assert dm.data_fetcher.block_viz_window is True
      dm.set_block_viz_window(False)
      assert dm.data_fetcher.block_viz_window is False
  
      dm.show_train_batch("load_sample")
      dm.show_train_batch("per_sample_transform")
  
      # check training data
      data = next(iter(dm.train_dataloader()))
      imgs, labels = data[DataKeys.INPUT], data[DataKeys.TARGET]
      assert imgs.shape == (2, 3, 128, 128)
      assert labels.shape == (2, 128, 128)
      assert labels.min().item() == 0
      assert labels.max().item() == 1
      assert labels.dtype == torch.int64
  
      # now train with `fast_dev_run`
      model = SemanticSegmentation(
          num_classes=2, backbone="resnet50", head="fpn"
      )
      trainer = Trainer(default_root_dir=tmpdir, fast_dev_run=True)
      trainer.finetune(model, dm, strategy="freeze")
  
imports: import os
  from pathlib import Path
  from typing import Callable, Dict, List, Tuple
  import numpy
  import pytest
  import torch
  from flash import Trainer
  from flash.core.data.io.input import DataKeys
  from flash.core.data.io.input_transform import InputTransform
  from flash.core.data.transforms import ApplyToKeys
  from flash.core.utilities.imports import _FIFTYONE_AVAILABLE, _MATPLOTLIB_AVAILABLE, _PIL_AVAILABLE, _SEGMENTATION_MODELS_AVAILABLE, _TOPIC_IMAGE_AVAILABLE
  from flash.image import SemanticSegmentation, SemanticSegmentationData
label_desc: Use image node_id 9 for calling the TestSemanticSegmentationData obj's underlying member method code with example usage: obj.test_map_labels(tmpdir) without return types