def retrieve_sample(data, ann_index):
    """Retrieve an annotation-image pair from the dataset.

    Args:
        data: Hand mesh dataset.
        ann_index: Annotation index.

    Returns:
        A sample from the hand mesh dataset.
    """
    ann = data['annotations'][ann_index]
    images = data['images']
    img_idxs = [im['id'] for im in images]

    img = images[img_idxs.index(ann['image_id'])]
    return ann, img