code: def test_dataset():
      # Test the format of the values returned by indexing the dataset
      dataset = get_dataset()
      assert (
          len(dataset) == 1
      )  # there is only one image in the dataset (label.xml)
      assert isinstance(dataset[0][0], torch.Tensor)
      assert isinstance(dataset[0][1], dict)
      assert dataset[0][0].shape == (3, 1080, 1720)
      assert "boxes" in dataset[0][1] and "labels" in dataset[0][1]
      assert dataset[0][1]["boxes"].shape == (2, 4)
      assert dataset[0][1]["labels"] == ["start_tick", "start_gate"]
  
      transform = transforms.Compose(
          [
              transforms.ToPILImage(),
              transforms.Resize(108),
              transforms.RandomHorizontalFlip(1),
              transforms.ToTensor(),
          ]
      )
  
      # Test that the transforms are properly applied
      dataset = get_dataset(transform=transform)
      assert dataset[0][0].shape == (3, 108, 172)
      assert torch.all(
          dataset[0][1]["boxes"][1] == torch.tensor([6, 41, 171, 107])
      )
  
      # Test works when given an XML folder
      path = os.path.dirname(__file__)
      input_folder = os.path.join(path, "static")
  
      dataset = Dataset(input_folder, input_folder)
      assert len(dataset) == 1
      assert dataset[0][0].shape == (3, 1080, 1720)
      assert "boxes" in dataset[0][1] and "labels" in dataset[0][1]
  
      dataset = Dataset(input_folder)
      assert len(dataset) == 1
      assert dataset[0][0].shape == (3, 1080, 1720)
      assert "boxes" in dataset[0][1] and "labels" in dataset[0][1]
  
file_path: detecto/detecto/tests/test_core.py
imports: import torch
  from detecto.core import *
  from detecto.utils import read_image
  from .helpers import get_dataset, get_image, get_model, empty_predictor
  from torchvision import transforms
  from torchvision.models.detection.faster_rcnn import FastRCNNPredictor
label_desc: Use image node_id 1 for calling a global function with example usage: test_dataset() without return types