code: def test_torch_image_patches_dataset():
      image_path = "/path/to/an/image.png"
  
      dataset = fo.Dataset()
  
      sample = fo.Sample(filepath=image_path)
  
      polylines = fo.Polylines(
          polylines=[
              fo.Polyline(
                  label="square",
                  points=[
                      [(0.1, 0.1), (0.1, 0.4), (0.4, 0.4), (0.4, 0.1)]
                  ],
                  closed=True,
                  filled=True,
              ),
              fo.Polyline(
                  label="triangle",
                  points=[[(0.6, 0.1), (0.9, 0.1), (0.9, 0.4)]],
                  closed=True,
                  filled=True,
              ),
              fo.Polyline(
                  label="diamond",
                  points=[
                      [
                          (0.1, 0.75),
                          (0.25, 0.6),
                          (0.4, 0.75),
                          (0.25, 0.9),
                      ]
                  ],
                  closed=True,
                  filled=True,
              ),
              fo.Polyline(
                  label="triangle",
                  points=[[(0.6, 0.6), (0.6, 0.9), (0.9, 0.9)]],
                  closed=True,
                  filled=True,
              ),
          ]
      )
  
      sample["polylines"] = polylines
      sample["detections"] = sample["polylines"].to_detections(
          mask_size=(64, 64)
      )
      sample["polylines2"] = sample["detections"].to_polylines()
  
      dataset.add_sample(sample)
  
      image_paths = [sample.filepath]
      patches = [sample.detections]
  
      transform = torchvision.transforms.Compose(
          [
              torchvision.transforms.Resize(
                  size=[32, 32], interpolation=Image.BILINEAR
              ),
              torchvision.transforms.ToTensor(),
          ]
      )
  
      torch_dataset = fout.TorchImagePatchesDataset(
          image_paths=image_paths, patches=patches, transform=transform
      )
  
      data_loader = torch.utils.data.DataLoader(
          torch_dataset, batch_size=1
      )
  
      patches = next(iter(data_loader))
      patches = torch.squeeze(patches, dim=0)
      imgs = np.transpose(patches.numpy(), axes=(0, 2, 3, 1))
      imgs = np.array(255.0 * imgs, dtype=np.uint8)
      dataset.ingest_images(imgs)
  
      print(dataset)
  
      #
      # Inspect App to verity that detection <-> polyline conversion happened as
      # expected, and that the appropriate image patches were extracted from the
      # source image
      #
  
      session = fo.launch_app(dataset)
      session.wait()
  
file_path: fiftyone/tests/misc/torch_tests.py
imports: import unittest
  import numpy
  from PIL import Image
  import torch
  import torchvision
  import fiftyone
  import fiftyone.utils.torch
label_desc: Use image node_id 4 for calling a global function with example usage: test_torch_image_patches_dataset() without return types