code: def build_train_batch(records: Sequence[BaseRecord]):
      tensor_images, tensor_masks = [], []
      for record in records:
          # can be optimzed to be converted to tensor once at the end
          tensor_images.append(im2tensor(record.img))
          tensor_masks.append(
              tensor(record.segmentation.mask_array.data)
              .long()
              .squeeze()
          )
  
      tensor_images = torch.stack(tensor_images)
      tensor_masks = torch.stack(tensor_masks)
  
      return (tensor_images, tensor_masks), records
  
file_path: icevision/icevision/models/fastai/unet/dataloaders.py
imports: from icevision.imports import *
  from icevision.core import *
  from icevision.models.utils import *
label_desc: Use image node_id 4 for calling a global function with example usage: build_train_batch(records) and returns: tensor_images,  tensor_masks,  records