def METHOD_NAME(result, confidence_thresh=None):
    if result.masks is None:
        return None
    classes = np.rint(result.boxes.cls.detach().cpu().numpy()).astype(int)
    boxes = result.boxes.xywhn.detach().cpu().numpy().astype(float)
    bounds = np.rint(result.boxes.xyxy.detach().cpu().numpy()).astype(int)
    masks = result.masks.data.detach().cpu().numpy() > 0.5
    confs = result.boxes.conf.detach().cpu().numpy().astype(float)
    detections = []
    for cls, box, bound, mask, conf in zip(
        classes, boxes, bounds, masks, confs
    ):
        if confidence_thresh is not None and conf < confidence_thresh:
            continue
        label = result.names[cls]
        xc, yc, w, h = box
        x1, y1, x2, y2 = bound
        detection = fol.Detection(
            label=label,
            bounding_box=[xc - 0.5 * w, yc - 0.5 * h, w, h],
            mask=mask[y1:y2, x1:x2],
            confidence=conf,
        )
        detections.append(detection)
    return fol.Detections(detections=detections)