from typing import List


def remove_bad_samples(instance_annotation: dict,
                       minimum_bb_area: float,
                       minimum_visibility: str,
                       image_area: int = 1600 * 900) -> List:
    """
    Removes bad samples from an instance annotation's sample sequence

    :param instance_annotation: an instance annotation
    :param minimum_bb_area: The minimum fraction of a frame a bounding box take up to be used (0, 1)
    :param minimum_visibility: The minimum visibility a frame is allowed to haev ('', '1', '2', '3', '4')
    :param image_area: The area of an image frame. Defaults to 1600*900.
    :return: A cleaned list of sample annotation tokens that meet requirements
    """
    sample_token_sequence = instance_annotation['sample_annotation_sequence']
    cleaned = []

    for sample_token in sample_token_sequence:
        area = instance_annotation[sample_token]['best_annotation']['bbox_area']
        visibility = instance_annotation[sample_token]['best_annotation']['visibility_token']
        if area / image_area > minimum_bb_area and visibility >= minimum_visibility:
            cleaned.append(sample_token)

    return cleaned