import csv


def find_unique(annotations: str) -> dict:
    """
    find_unique will loop through the annotations csv, and generate a dictionary which contains
    the unique images, and all associated rows. This is neccesary as the csv sometimes contains
    multiple entries for an image, specifically when an image has more than 1 lesion present. 

    Parameters
    ----------
    annotations : str
        path to csv file containing annotations.

    Returns
    -------
    dict
        Dictionary containing unique images. Of the form
        {Unique_image: [[row1],[row2],...,[rowN]]}

    """

    
    return_dict = {}
    
    with open(annotations, "r") as f:
        reader = csv.reader(f)
        
        next(reader)
        
        for line in reader:
            if line[0] in return_dict.keys():
                return_dict[line[0]].append(line)
            else:
                return_dict.update({line[0]:[line]})
    
    return return_dict