code: def prepare_data(
      data_path: Path, read_func: Callable = read_image_tensor
  ) -> Dict:
      """
      Takes a data_path of a folder which contains subfolders with input, target, etc.
      lablelled by the same names.
  
      :param data_path: Path of the folder containing data
      :param read_func: function that reads data and returns a tensor
      """
      data_dict = {}
  
      subdir_names = ["target", "input", "mask"]  # ,"helper"
  
      # checks only files for which there is an target
      # TODO check for images
      name_ls = [
          file.name
          for file in (data_path / "target").iterdir()
          if file.is_file()
      ]
  
      subdirs = [data_path / sdn for sdn in subdir_names]
      for sd in subdirs:
          if sd.is_dir():
              data_ls = []
              files = [sd / name for name in name_ls]
              for file in files:
                  tensor = read_func(file)
                  H, W = tensor.shape[-2:]
                  data_ls.append(tensor)
              # TODO check that all sizes match
              data_dict[sd.name] = torch.stack(data_ls, dim=0)
  
      data_dict["name"] = name_ls
      data_dict["len"] = len(data_dict["name"])
      data_dict["H"] = H
      data_dict["W"] = W
      return data_dict
  
imports: from typing import Callable, Dict
  import torch
  from torch.utils.data import Dataset
  import torchvision.transforms.functional
  from torchvision import transforms
  import pytorch_lightning
  from collections.abc import Iterable
  from pathlib import Path
  from PIL import Image
  from typing import Tuple
label_desc: Use image node_id 7 for calling a global function with example usage: prepare_data(data_path, read_func) and returns: data_dict