def __getitem__(self, index: int) -> ImageItem:
        """Get a dataset item.

        Args:
            index (int): Index of the item to get.

        Returns:
            ImageItem: The dataset item.
        """
        image_path = self.samples.iloc[index].image_path
        mask_path = self.samples.iloc[index].mask_path
        label_index = self.samples.iloc[index].label_index

        image = read_image(image_path, as_tensor=True)
        item = {"image_path": image_path, "gt_label": label_index}

        # Some of the categories in MVTec LOCO have multiple masks for the same image.
        if isinstance(mask_path, str):
            mask_path = [mask_path]

        # Only Anomalous (1) images have masks in anomaly datasets
        # Therefore, create empty mask for Normal (0) images.
        semantic_mask = (
            Mask(torch.zeros(image.shape[-2:], dtype=torch.bool))
            if label_index == LabelName.NORMAL
            else Mask(torch.stack([read_mask(path, as_tensor=True) for path in mask_path]))
        )

        binary_mask = Mask(semantic_mask.view(-1, *semantic_mask.shape[-2:]).any(dim=0))
        item["image"], item["gt_mask"] = (
            self.augmentations(image, binary_mask) if self.augmentations else (image, binary_mask)
        )

        item["mask_path"] = mask_path
        # List of masks with the original size for saturation based metrics calculation
        item["semantic_mask"] = semantic_mask

        return ImageItem(
            image=item["image"],
            gt_mask=item["gt_mask"],
            gt_label=torch.tensor(label_index),
            image_path=image_path,
            mask_path=item["mask_path"][0] if isinstance(item["mask_path"], list) else item["mask_path"],
        )
Get a dataset item.

        Args:
            index (int): Index of the item to get.

        Returns:
            ImageItem: The dataset item.
        
src/anomalib/data/datasets/image/mvtec_loco.py