def METHOD_NAME(xml_writer, img_height, wkt_data, label):
    polygons = []
    if isinstance(wkt_data, list):  # V3+
        polygons = (wkt.loads(x["geometry"]) for x in wkt_data)
    else:  # V2
        polygons = wkt.loads(wkt_data)
    for m in polygons:
        xy_coords = []
        for x, y in m.exterior.coords:
            xy_coords.extend([x, img_height - y])
        # remove last polygon if it is identical to first point
        if xy_coords[-2:] == xy_coords[:2]:
            xy_coords = xy_coords[:-2]
        xml_writer.addObject(name=label, xy_coords=xy_coords)
    return xml_writer