def visualize(self, x):
        """
        Parameters
        ----------
        x: Dict
            One 'dataset_dict'.

        Returns
        -------
        viz_images: Dict[np.array]
            Visualizations as RGB images.
        """
        # Load image.
        img = d2_utils.read_image(x["file_name"], format=self._input_format)
        img = d2_utils.convert_image_to_rgb(img, self._input_format)

        viz_images = OrderedDict()

        # d2 groundtruth instances viz (2D box, mask, keypoints)
        if 'annotations' in x:
            # Visualizer.draw_datset_dict() renders various types of annotations.
            # But here we only use its capability to render *instance() annotations.
            _x = {'annotations': x['annotations']}
            viz = Visualizer(img, self._metadata, scale=self._scale, instance_mode=self._d2_viz_color_mode)
            viz_image = viz.draw_dataset_dict(_x).get_image()
            viz_images["viz_gt_instances_d2"] = viz_image

        # d2 instance predictions viz (2D box, mask, keypoints)
        if self.pred_instances_by_image is not None:
            pred_instances = self.pred_instances_by_image[x['image_id']]
            viz = Visualizer(img, self._metadata, scale=self._scale, instance_mode=self._d2_viz_color_mode)
            viz_image = viz.draw_instance_predictions(pred_instances).get_image()
            viz_images["viz_pred_instance_d2"] = viz_image

        return viz_images

        Parameters
        ----------
        x: Dict
            One 'dataset_dict'.

        Returns
        -------
        viz_images: Dict[np.array]
            Visualizations as RGB images.
        
tridet/visualizers/d2_visualizer.py