def METHOD_NAME(
    self, images_and_categories: List[Tuple[torch.Tensor, Optional[str]]]
) -> Iterator[List[SampledData]]:
    """
    Produce batches of data from images
    Args:
      images_and_categories (List[Tuple[torch.Tensor, Optional[str]]]):
        list of images and corresponding categories to process
    Returns:
      Iterator over batches of data sampled from model outputs
    """
    data_batches: List[SampledData] = []
    category_to_class_mapping = self.category_to_class_mapping
    batched_images_and_categories = _grouper(images_and_categories, self.inference_batch_size)
    for batch in batched_images_and_categories:
        batch = [
            {
                "image": image_and_category["image"].to(self.model.device),
                "category": image_and_category["category"],
            }
            for image_and_category in batch
            if image_and_category is not None
        ]
        if not batch:
            continue
        with torch.no_grad():
            model_output = self.model(batch)
        for model_output_i, batch_i in zip(model_output, batch):
            assert len(batch_i["image"].shape) == 3
            model_output_i["image"] = batch_i["image"]
            instance_class = category_to_class_mapping.get(batch_i["category"], 0)
            model_output_i["instances"].dataset_classes = torch.tensor(
                [instance_class] * len(model_output_i["instances"])
            )
        model_output_filtered = (
            model_output if self.data_filter is None else self.data_filter(model_output)
        )
        data = (
            model_output_filtered
            if self.data_sampler is None
            else self.data_sampler(model_output_filtered)
        )
        for data_i in data:
            if len(data_i["instances"]):
                data_batches.append(data_i)
        if len(data_batches) >= self.batch_size:
            yield data_batches[: self.batch_size]
            data_batches = data_batches[self.batch_size :]
    if not self.drop_last and data_batches:
        yield data_batches